Here is an advanced version, Just for fun.
Features
- Multiple Define Symbols
- Safety
- Runs when Compile ends
- Removes Duplicates
Installation
- Download the Script or Copy/Paste it from the Below
- Open Script
- Go to Symbols property and add your own symbols
- Go back to Unity and wait for compile ends
- All done, now check Player Settings, The symbols added
Code (CSharp):
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
/// <summary>
/// Adds the given define symbols to PlayerSettings define symbols.
/// Just add your own define symbols to the Symbols property at the below.
/// </summary>
[InitializeOnLoad]
public class AddDefineSymbols
: Editor {
/// <summary>
/// Symbols that will be added to the editor
/// </summary>
public static readonly string [] Symbols = new string[] {
"MYCOMPANY",
"MYCOMPANY_MYPACKAGE"
};
/// <summary>
/// Add define symbols as soon as Unity gets done compiling.
/// </summary>
static AddDefineSymbols ()
{
List<string> allDefines = definesString.Split ( ';' ).ToList ();
allDefines.AddRange ( Symbols.Except ( allDefines ) );
string.
Join ( ";", allDefines.
ToArray () ) );
}
}
Thanks.
[출처] https://forum.unity.com/threads/scripting-define-symbols-access-in-code.174390/