Skip to content

Commit

Permalink
⭐[update] AIO DLL
Browse files Browse the repository at this point in the history
  • Loading branch information
xinansky committed Oct 26, 2023
1 parent e5304e1 commit 1620462
Show file tree
Hide file tree
Showing 9 changed files with 2,692 additions and 2,515 deletions.
64 changes: 14 additions & 50 deletions Editor/General/Script/Utils/Setting/EHelper.Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEditor.Build;
using UnityEngine;

namespace AIO.UEditor
Expand All @@ -21,61 +21,27 @@ public static class Setting
{
private static ICollection<string> GetScriptingDefineSymbolsForGroup(BuildTargetGroup buildTargetGroup)
{
//获得当前平台已有的的宏定义
var GetScriptingDefineSymbols = typeof(PlayerSettings).GetMethod("GetScriptingDefineSymbolsInternal",
BindingFlags.Static | BindingFlags.NonPublic);
string str = null;
if (GetScriptingDefineSymbols != null)
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (!assembly.GetName().Name.StartsWith("UnityEditor.Build")) continue;
var namedBuildTargetType = assembly.GetType("UnityEditor.Build.NamedBuildTarget");
var FromBuildTargetGroupMethod = namedBuildTargetType?.GetMethod("FromBuildTargetGroup",
BindingFlags.Static | BindingFlags.Public);
if (FromBuildTargetGroupMethod is null) continue;
var symbols = FromBuildTargetGroupMethod.Invoke(null, new object[] { buildTargetGroup });
str = GetScriptingDefineSymbols.Invoke(null, new object[] { symbols }) as string;
break;
}
}
else str = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
var str =
#if UNITY_2023_1_OR_NEWER
PlayerSettings.GetScriptingDefineSymbols(
NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup));
#else
PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
#endif

return string.IsNullOrEmpty(str) ? Array.Empty<string>() : str.Split(';');
}

private static void SetScriptingDefineSymbolsForGroup(BuildTargetGroup buildTargetGroup,
IEnumerable<string> verify)
{
//获得当前平台已有的的宏定义
MethodInfo SetScriptingDefineSymbols = null;
foreach (var methodInfo in typeof(PlayerSettings).GetMethods(BindingFlags.Static | BindingFlags.Public))
{
if (methodInfo.Name != "SetScriptingDefineSymbols") continue;
var parameters = methodInfo.GetParameters();
if (parameters.Length != 2) continue;
if (parameters[0].ParameterType != typeof(string)) continue;
if (parameters[1].ParameterType != typeof(string)) continue;
SetScriptingDefineSymbols = methodInfo;
}

var str = string.Join(";", verify);
if (SetScriptingDefineSymbols != null)
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (!assembly.GetName().Name.StartsWith("UnityEditor.Build")) continue;
var namedBuildTargetType = assembly.GetType("UnityEditor.Build.NamedBuildTarget");
var FromBuildTargetGroupMethod = namedBuildTargetType?.GetMethod("FromBuildTargetGroup",
BindingFlags.Static | BindingFlags.Public);
if (FromBuildTargetGroupMethod is null) continue;
var Symbols = FromBuildTargetGroupMethod.Invoke(null, new object[] { buildTargetGroup });
SetScriptingDefineSymbols.Invoke(null, new object[] { Symbols, str });

break;
}
}
else PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, str);
#if UNITY_2023_1_OR_NEWER
PlayerSettings.SetScriptingDefineSymbols(
NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup), str);
#else
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, str);
#endif
}

/// <summary>
Expand All @@ -84,7 +50,6 @@ private static void SetScriptingDefineSymbolsForGroup(BuildTargetGroup buildTarg
public static void AddScriptingDefine(BuildTargetGroup buildTargetGroup, ICollection<string> value)
{
if (value is null || value.Count == 0) return;
Debug.Log($"Plugins Data Editor : AddScriptingDefine -> {buildTargetGroup}");
var verify = new List<string>(GetScriptingDefineSymbolsForGroup(buildTargetGroup));
foreach (var v in value)
{
Expand All @@ -101,7 +66,6 @@ public static void AddScriptingDefine(BuildTargetGroup buildTargetGroup, ICollec
public static void DelScriptingDefine(BuildTargetGroup buildTargetGroup, ICollection<string> value)
{
if (value is null || value.Count == 0) return;
Debug.Log($"Plugins Data Editor : DelScriptingDefine -> {buildTargetGroup}");
var str = GetScriptingDefineSymbolsForGroup(buildTargetGroup);
if (str.Count == 0) return;
IList<string> verify = new List<string>(str);
Expand Down
Binary file modified Plugins/Editor/AIO.PrCourse.Unity.dll
Binary file not shown.
Binary file modified Plugins/Editor/AIO.PrCourse.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten

public static int GetListId(SerializedProperty property)
{
if (property != null)
{
int hashCode = property.serializedObject.targetObject.GetHashCode();
int hashCode2 = property.propertyPath.GetHashCode();
return ((hashCode << 5) + hashCode) ^ hashCode2;
}
return 0;
if (property == null) return 0;
var hashCode = property.serializedObject.targetObject.GetHashCode();
var hashCode2 = property.propertyPath.GetHashCode();
return ((hashCode << 5) + hashCode) ^ hashCode2;
}

public static ReorderableList GetList(SerializedProperty property, string arrayPropertyName)
Expand Down
Loading

0 comments on commit 1620462

Please sign in to comment.