Update
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using DA_Assets.DAI;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using DA_Assets.Extensions;
|
||||
|
||||
namespace DA_Assets.DM
|
||||
{
|
||||
internal class DependenciesWindow : EditorWindow
|
||||
{
|
||||
public DAInspector gui => BlackInspector.Instance.Inspector;
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
gui.DrawGroup(new Group
|
||||
{
|
||||
GroupType = GroupType.Vertical,
|
||||
Style = gui.ColoredStyle.TabBg2,
|
||||
Scroll = true,
|
||||
Body = () =>
|
||||
{
|
||||
gui.DrawGroup(new Group
|
||||
{
|
||||
GroupType = GroupType.Vertical,
|
||||
Scroll = true,
|
||||
Body = () =>
|
||||
{
|
||||
if (DependencyItems.Instance.Items.IsEmpty())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < DependencyItems.Instance.Items.Count; i++)
|
||||
{
|
||||
DependencyItem ac = DependencyItems.Instance.Items[i];
|
||||
ac.Enabled = gui.Toggle(new GUIContent(ac.Name), ac.Enabled);
|
||||
DependencyItems.Instance.Items[i] = ac;
|
||||
gui.Space10();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!DependencyItems.Instance.Items.IsEmpty())
|
||||
{
|
||||
gui.Space15();
|
||||
|
||||
if (gui.OutlineButton(new GUIContent("Apply"), true))
|
||||
{
|
||||
DefineModifier.Apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e12806a9a4594649ac69e4716b7a351
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using DA_Assets.Constants;
|
||||
using DA_Assets.Singleton;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.DM
|
||||
{
|
||||
[CreateAssetMenu(menuName = DAConstants.Publisher + "/DependencyItems")]
|
||||
[ResourcePath("")]
|
||||
public class DependencyItems : SingletonScriptableObject<DependencyItems>
|
||||
{
|
||||
[SerializeField] List<DependencyItem> items;
|
||||
public List<DependencyItem> Items => items;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct DependencyItem
|
||||
{
|
||||
public string Name;
|
||||
public string Type;
|
||||
public string ScriptingDefineName;
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed3ffb60402c43140bf0a3b0bf0cda9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DA_Assets.DM
|
||||
{
|
||||
public class DefineModifier
|
||||
{
|
||||
[DidReloadScripts]
|
||||
private static void OnScriptsReload()
|
||||
{
|
||||
_ = SearchAssets();
|
||||
}
|
||||
|
||||
public static void Apply()
|
||||
{
|
||||
List<string> enabled = new List<string>();
|
||||
List<string> disabled = new List<string>();
|
||||
|
||||
foreach (DependencyItem assemblyConfig in DependencyItems.Instance.Items)
|
||||
{
|
||||
if (assemblyConfig.Enabled)
|
||||
{
|
||||
enabled.Add(assemblyConfig.ScriptingDefineName);
|
||||
}
|
||||
else
|
||||
{
|
||||
disabled.Add(assemblyConfig.ScriptingDefineName);
|
||||
}
|
||||
}
|
||||
|
||||
Modify(enabled.ToArray(), disabled.ToArray());
|
||||
}
|
||||
|
||||
internal static async Task SearchAssets()
|
||||
{
|
||||
await Task.Delay(250);
|
||||
|
||||
List<DependencyItem> l = DependencyItems.Instance.Items;
|
||||
|
||||
for (int i = 0; i < l.Count; i++)
|
||||
{
|
||||
Type t = Type.GetType(l[i].Type);
|
||||
|
||||
if (t == null)
|
||||
continue;
|
||||
|
||||
DependencyItem ac = l[i];
|
||||
|
||||
// Ignore Unity.Plastic.Newtonsoft.Json.dll
|
||||
if (IsUnityPlasticNewtonsoftJson(t.Assembly))
|
||||
{
|
||||
ac.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ac.Enabled = true;
|
||||
}
|
||||
|
||||
l[i] = ac;
|
||||
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
Apply();
|
||||
}
|
||||
|
||||
private static bool IsUnityPlasticNewtonsoftJson(Assembly assembly)
|
||||
{
|
||||
string assemblyName = assembly.GetName().Name;
|
||||
string assemblyPath = Path.GetDirectoryName(assembly.Location);
|
||||
string targetPath = Path.Combine("Editor", "Data", "Managed");
|
||||
|
||||
bool endsWith = assemblyPath.EndsWith(targetPath);
|
||||
|
||||
//Debug.Log($"{assemblyName}\n{assemblyPath}\n{endsWith}");
|
||||
|
||||
if (endsWith && assemblyName == "Newtonsoft.Json")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static void Modify(string[] addDefines, string[] removeDefines)
|
||||
{
|
||||
List<string> finalDefines = GetDefines();
|
||||
|
||||
finalDefines.AddRange(addDefines);
|
||||
finalDefines.RemoveAll(x => removeDefines.Contains(x));
|
||||
finalDefines = finalDefines.Distinct().ToList();
|
||||
|
||||
SetDefines(finalDefines);
|
||||
}
|
||||
|
||||
internal static List<string> GetDefines()
|
||||
{
|
||||
string rawDefs;
|
||||
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
BuildTargetGroup group = BuildPipeline.GetBuildTargetGroup(target);
|
||||
UnityEditor.Build.NamedBuildTarget namedBuildTarget = UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(group);
|
||||
rawDefs = PlayerSettings.GetScriptingDefineSymbols(namedBuildTarget);
|
||||
#else
|
||||
rawDefs = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
#endif
|
||||
|
||||
if (string.IsNullOrWhiteSpace(rawDefs) == false)
|
||||
{
|
||||
return rawDefs.Split(';').ToList();
|
||||
}
|
||||
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
internal static void SetDefines(List<string> defines)
|
||||
{
|
||||
string joinedDefs = string.Join(";", defines);
|
||||
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
BuildTargetGroup group = BuildPipeline.GetBuildTargetGroup(target);
|
||||
UnityEditor.Build.NamedBuildTarget namedBuildTarget = UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(group);
|
||||
PlayerSettings.SetScriptingDefineSymbols(namedBuildTarget, joinedDefs);
|
||||
#else
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, joinedDefs);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87dca9be47530fa49bac45e5575b2108
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4411dae8bed16164296617ace5f17d9a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ed3ffb60402c43140bf0a3b0bf0cda9e, type: 3}
|
||||
m_Name: DependencyItems
|
||||
m_EditorClassIdentifier:
|
||||
items:
|
||||
- Name: Figma Converter for Unity
|
||||
Type: DA_Assets.FCU.SyncHelper, DA_Assets.FCU
|
||||
ScriptingDefineName: FCU_EXISTS
|
||||
- Name: Json.NET
|
||||
Type: Newtonsoft.Json.JsonConvert, Newtonsoft.Json
|
||||
ScriptingDefineName: JSONNET_EXISTS
|
||||
- Name: TextMeshPro
|
||||
Type: TMPro.TextMeshPro, Unity.TextMeshPro
|
||||
ScriptingDefineName: TextMeshPro
|
||||
- Name: TrueShadow
|
||||
Type: LeTai.TrueShadow.TrueShadow, LeTai.TrueShadow
|
||||
ScriptingDefineName: TRUESHADOW_EXISTS
|
||||
- Name: Modern Procedural UI Kit
|
||||
Type: MPUIKIT.MPImage, MPUIKit
|
||||
ScriptingDefineName: MPUIKIT_EXISTS
|
||||
- Name: Josh's Procedural UI Image
|
||||
Type: UnityEngine.UI.ProceduralImage.ProceduralImage, Assembly-CSharp
|
||||
ScriptingDefineName: JOSH_PUI_EXISTS
|
||||
- Name: I2Localization
|
||||
Type: I2.Loc.Localize, Assembly-CSharp
|
||||
ScriptingDefineName: I2LOC_EXISTS
|
||||
- Name: Shapes2D
|
||||
Type: Shapes2D.Shape, Assembly-CSharp
|
||||
ScriptingDefineName: SUBC_SHAPES_EXISTS
|
||||
- Name: UI Toolkit
|
||||
Type: UnityEngine.UIElements.UIDocument, UnityEngine.UIElementsModule
|
||||
ScriptingDefineName: UITK_EXISTS
|
||||
- Name: Figma to UITK Converter
|
||||
Type: DA_Assets.FCU.UitkExtensions, DA_Assets.UITK_Converter
|
||||
ScriptingDefineName: FCU_UITK_EXT_EXISTS
|
||||
- Name: DAButton
|
||||
Type: DA_Assets.DAB.DAButton, Assembly-CSharp
|
||||
ScriptingDefineName: DABUTTON_EXISTS
|
||||
- Name: D.A. Localizator
|
||||
Type: DA_Assets.DAL.ILocalizator, DA_Assets.DAL
|
||||
ScriptingDefineName: DALOC_EXISTS
|
||||
- Name: RTL Text Mesh Pro
|
||||
Type: RTLTMPro.RTLTextMeshPro, RTLTMPro
|
||||
ScriptingDefineName: RTLTMP_EXISTS
|
||||
- Name: DTT's Procedural UI
|
||||
Type: DTT.UI.ProceduralUI.RoundedImage, DTT.ProceduralUI.Runtime
|
||||
ScriptingDefineName: PROCEDURAL_UI_ASSET_STORE_RELEASE
|
||||
- Name: UITK Element Linker
|
||||
Type: DA_Assets.UEL.UitkLinkerBase, DA_Assets.UEL
|
||||
ScriptingDefineName: UITK_LINKER_EXISTS
|
||||
- Name: Nova UI
|
||||
Type: Nova.UIBlock2D, Nova
|
||||
ScriptingDefineName: NOVA_UI_EXISTS
|
||||
- Name: Unity UI Extensions
|
||||
Type: UnityEngine.UI.Extensions.FlowLayoutGroup, UnityUIExtensions
|
||||
ScriptingDefineName: UNITY_UI_EXTENSIONS_EXISTS
|
||||
- Name: Vector Graphics
|
||||
Type: Unity.VectorGraphics.SVGImage, Unity.VectorGraphics
|
||||
ScriptingDefineName: VECTOR_GRAPHICS_EXISTS
|
||||
- Name: 2D Sprite
|
||||
Type: UnityEditor.U2D.Sprites.SpriteDataProviderFactories, Unity.2D.Sprite.Editor
|
||||
ScriptingDefineName: U2D_SPRITE_EXISTS
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b083f642187875a40a6dcb9020bf0e81
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user