Last active
June 19, 2017 02:02
-
-
Save Geri-Borbas/a92ac7993239608a3891752d2bbdba75 to your computer and use it in GitHub Desktop.
Create Scripting Define Symbol from script for the selected Build Target in Unity.
This file contains hidden or 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 System; | |
using UnityEngine; | |
using UnityEditor; | |
[InitializeOnLoad] | |
public class Define | |
{ | |
const string define = "LIBRARY_IS_AVAILABLE"; | |
static Define() | |
{ AddDefineIfNeeded(); } | |
static void AddDefineIfNeeded() | |
{ | |
// Get selected target defines. | |
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; | |
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); | |
// Only if not defined already. | |
if (defines.Contains(define)) | |
{ | |
Debug.LogWarning("Selected build target ("+EditorUserBuildSettings.activeBuildTarget.ToString()+") already contains <b>"+define+"</b> <i>Scripting Define Symbol</i>."); | |
return; | |
} | |
// Append. | |
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, (defines + ";" + define)); | |
Debug.LogWarning("<b>"+define+"</b> added to <i>Scripting Define Symbols</i> for selected build target ("+EditorUserBuildSettings.activeBuildTarget.ToString()+")."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment