Created
March 19, 2016 17:21
-
-
Save t0chas/fc57dbea5fce4aaf83b9 to your computer and use it in GitHub Desktop.
Manage your Unity3D symbols easily within the Editor by defining menu items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public class CustomDefines { | |
[MenuItem("Global Defines/My Symbol/Enable")] | |
public static void EnableDebug(){ | |
Debug.LogWarning("Enabling MY_SYMBOL"); | |
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); | |
string newDefine = "MY_SYMBOL"; | |
if(!defines.Contains(newDefine)){ | |
defines= string.Format("{0},{1}", defines, newDefine); | |
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, defines); | |
AssetDatabase.SaveAssets(); | |
} | |
} | |
[MenuItem("Global Defines/My Symbol/Enable", true)] | |
public static bool EnableDebugEval(){ | |
#if !MY_SYMBOL | |
return true; | |
#else | |
return false; | |
#endif | |
} | |
[MenuItem("Global Defines/My Symbol/Disable")] | |
public static void DisableDebug(){ | |
Debug.LogWarning("Disabling MY_SYMBOL"); | |
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); | |
string newDefine = "MY_SYMBOL"; | |
if(defines.Contains(newDefine)){ | |
defines = defines.Replace(newDefine, ""); | |
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, defines); | |
AssetDatabase.SaveAssets(); | |
} | |
} | |
[MenuItem("Global Defines/My Symbol/Disable", true)] | |
public static bool DisableDebugEval(){ | |
#if MY_SYMBOL | |
return true; | |
#else | |
return false; | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment