Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
using System.Linq;
using Fluctio.FluctioSim.EditorUtils.EditorGeneral;
using Fluctio.FluctioSim.Utils.General;
using UnityEditor;
using UnityEditor.Build;

namespace Fluctio.FluctioSim.EditorCore.AccountManagement
{
	internal static class DebugMode
	{
		private const string DebugSymbol = "FLUCTIO_DEBUG";
		public const string DebugPermission = "debug:local";
		
		[InitializeOnLoadMethod]
		private static void Init()
		{
			Account.InfoChanged += UpdateDebugMode;
			if (EditorUtil.DidEditorJustOpen)
			{
				UpdateDebugMode();
			}
		}

		private static void UpdateDebugMode()
		{
			var namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
			PlayerSettings.GetScriptingDefineSymbols(namedBuildTarget, out var scriptingSymbols);
			var isEnabled = scriptingSymbols.Contains(DebugSymbol);
			var shouldBeEnabled = Account.IsLoggedIn && Account.Info.EnableDebug;
			if (isEnabled == shouldBeEnabled)
			{
				return;
			}

			var newScriptingSymbols = shouldBeEnabled
				? scriptingSymbols.Append(DebugSymbol)
				: scriptingSymbols.Where(Util.Not(DebugSymbol));
			PlayerSettings.SetScriptingDefineSymbols(namedBuildTarget, newScriptingSymbols.ToArray());
		}
	}
}