Skip to content

Instantly share code, notes, and snippets.

@sanukin39
Created June 30, 2016 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanukin39/7b987e3b2405e92d887db4dfb71be574 to your computer and use it in GitHub Desktop.
Save sanukin39/7b987e3b2405e92d887db4dfb71be574 to your computer and use it in GitHub Desktop.
Unity Environment Swicher
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class ChangeEnvironment {
[MenuItem("Environment/Develop")]
static void Develop(){
var symbols = GetSymbols();
symbols.Add("DEVELOP");
symbols.Remove("RELEASE");
SetSymbols(symbols);
}
[MenuItem("Environment/Release")]
static void Release(){
var symbols = GetSymbols();
symbols.Add("RELEASE");
symbols.Remove("DEVELOP");
SetSymbols(symbols);
}
static List<string> GetSymbols(){
return PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup).Split(';').ToList();
}
static void SetSymbols(List<string> symbols){
var symbolStr = string.Empty;
symbols.ForEach(s => symbolStr += s + ";");
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, symbolStr);
}
}
@dotsquid
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment