I’m using Unity 5.3.4 on a mac machine. I’m adding global defines to my unity project but they don’t seem to reflect in MonoDevelop. I don’t want to define them in the Player settings (Scripting Define Symbol section), instead I want to go the smcs.rsp (placed in Assets folder) route. The content of my smcs.rsp file is
-define:ENABLE_A
And I am using it as following :
#if ENABLE_A
Debug.Log("WORKS");
#endif
But the debug statement is always greyed out. What am I doing wrong here?
Make a EditorWindow and handle all your defines in there make use of PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, GetMCSDefines() + GetCustomDefines());
or
Make a python script, call it from C# when scripts compile, modify the csproj, it is just a xml. (a little ok method), below is a sample, but get the namespace during runtime, I hardcoded it
import xml.etree.ElementTree as ET
import os
namespaces = {'ns': 'http://schemas.microsoft.com/developer/msbuild/2003'}
ET.register_namespace('',"http://schemas.microsoft.com/developer/msbuild/2003")
csproj = os.path.dirname(os.getcwd()) + '/' + 'Assembly-CSharp.csproj'
# print os.path.dirname("Assembly-CSharp.csproj")
tree = ET.parse(csproj)
root = tree.getroot()
for elem in root.iterfind('.//ns:PropertyGroup[@Condition]', namespaces = namespaces):
defines = elem.find('.//ns:DefineConstants', namespaces = namespaces);
if(defines != None):
defines.text = defines.text + "MY_DEFINES"
tree.write(csproj)