96 lines
2.6 KiB
C#
96 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
namespace Beyond {
|
|
public class DebugDisableEnemies
|
|
{
|
|
[MenuItem("Debug/Enemies/Enable")]
|
|
private static void Enable()
|
|
{
|
|
SetDefineSymbol("ENEMIES_DISABLED", false);
|
|
EditorUtility.DisplayDialog("Enemies Debug", "Enemies have been enabled.", "OK");
|
|
}
|
|
|
|
[MenuItem("Debug/Enemies/Enable", true)]
|
|
private static bool EnableValidate()
|
|
{
|
|
return IsDefineSymbolSet("ENEMIES_DISABLED");
|
|
}
|
|
|
|
[MenuItem("Debug/Enemies/Disable")]
|
|
private static void Disable()
|
|
{
|
|
SetDefineSymbol("ENEMIES_DISABLED", true);
|
|
EditorUtility.DisplayDialog("Enemies Debug", "Enemies have been disabled.", "OK");
|
|
}
|
|
|
|
[MenuItem("Debug/Enemies/Disable", true)]
|
|
private static bool DisableValidate()
|
|
{
|
|
return !IsDefineSymbolSet("ENEMIES_DISABLED");
|
|
}
|
|
|
|
private static void SetDefineSymbol(string defineName, bool enable)
|
|
{
|
|
BuildTargetGroup[] buildTargetGroups = new BuildTargetGroup[]
|
|
{
|
|
BuildTargetGroup.Standalone,
|
|
BuildTargetGroup.Android,
|
|
BuildTargetGroup.iOS
|
|
};
|
|
|
|
foreach (var group in buildTargetGroups)
|
|
{
|
|
var defines = GetDefinesList(group);
|
|
if (enable)
|
|
{
|
|
if (!defines.Contains(defineName))
|
|
{
|
|
defines.Add(defineName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (defines.Contains(defineName))
|
|
{
|
|
defines.Remove(defineName);
|
|
}
|
|
}
|
|
|
|
string definesString = string.Join(";", defines.ToArray());
|
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, definesString);
|
|
}
|
|
}
|
|
|
|
private static List<string> GetDefinesList(BuildTargetGroup group)
|
|
{
|
|
return new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(group).Split(';'));
|
|
}
|
|
|
|
private static bool IsDefineSymbolSet(string defineName)
|
|
{
|
|
BuildTargetGroup[] buildTargetGroups = new BuildTargetGroup[]
|
|
{
|
|
BuildTargetGroup.Standalone,
|
|
BuildTargetGroup.Android,
|
|
BuildTargetGroup.iOS
|
|
};
|
|
|
|
foreach (var group in buildTargetGroups)
|
|
{
|
|
var defines = GetDefinesList(group);
|
|
if (defines.Contains(defineName))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |