mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
// ---------------------------------------------------------------------------------------------
|
|
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
|
// See LICENSE file in the project root for license information.
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
namespace Editor
|
|
{
|
|
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEditor.Build;
|
|
|
|
public static class EditorHelper
|
|
{
|
|
public static BuildTargetGroup[] GetAllSupportedTargetGroups()
|
|
{
|
|
return new[]
|
|
{
|
|
BuildTargetGroup.Android,
|
|
BuildTargetGroup.Standalone,
|
|
BuildTargetGroup.iOS,
|
|
};
|
|
}
|
|
|
|
public static NamedBuildTarget[] GetAllSupportedNamedBuildTargets()
|
|
{
|
|
return new[]
|
|
{
|
|
NamedBuildTarget.Android,
|
|
NamedBuildTarget.Standalone,
|
|
NamedBuildTarget.iOS,
|
|
};
|
|
}
|
|
|
|
public static void AddSymbol(string symbolToAdd)
|
|
{
|
|
foreach (BuildTargetGroup targetGroup in GetAllSupportedTargetGroups())
|
|
{
|
|
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
|
|
var allDefines = defines.Split(';').ToList();
|
|
if (!allDefines.Any(_ => string.Equals(_, symbolToAdd)))
|
|
{
|
|
allDefines.Add(symbolToAdd);
|
|
}
|
|
allDefines.Sort();
|
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup,
|
|
string.Join(";", allDefines.ToArray()));
|
|
}
|
|
}
|
|
|
|
public static void RemoveSymbol(string symbolToDelete)
|
|
{
|
|
foreach (BuildTargetGroup targetGroup in GetAllSupportedTargetGroups())
|
|
{
|
|
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
|
|
var allDefines = defines.Split(';').ToList();
|
|
var newDefines = allDefines
|
|
.Where(_ => !string.Equals(_, symbolToDelete)).ToList();
|
|
newDefines.Sort();
|
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup,
|
|
string.Join(";", newDefines.ToArray()));
|
|
}
|
|
}
|
|
}
|
|
} |