From 00f4df0a68f8fc0e6c135ce6db8b1d3ec3c653f4 Mon Sep 17 00:00:00 2001 From: fuqunaga Date: Fri, 29 Nov 2024 15:54:59 +0900 Subject: [PATCH 1/5] refactor: GenericDropdownMenuIgnoreAnchored implementation --- .../Runtime/VisualElement/PopupFieldCustom.cs | 5 +- .../GenericDropdownMenuIgnoreAnchored.cs | 67 ++++++++++++++++--- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/PopupFieldCustom.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/PopupFieldCustom.cs index 9655f213..d86ed27c 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/PopupFieldCustom.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/PopupFieldCustom.cs @@ -84,10 +84,7 @@ private string GetValueToDisplay(T str) public PopupFieldCustom() { - CreateMenuCallbackFieldInfo.SetValue(this, (Func)CreateMenu); - return; - - GenericDropdownMenu CreateMenu() => new GenericDropdownMenuIgnoreAnchored(); + CreateMenuCallbackFieldInfo.SetValue(this, (Func)GenericDropdownMenuIgnoreAnchoredBuilder.CreateGenericDropdownMenuIgnoreAnchored); } #endregion diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs index cc7a3bf2..a8e72c87 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs @@ -1,15 +1,66 @@ -using UnityEngine; +using System; +using System.Reflection; +using System.Reflection.Emit; +using UnityEngine; using UnityEngine.UIElements; namespace RosettaUI.UIToolkit { - // Dropdown()の第3引数を無視するGenericDropdownMenu - // BasePopupFieldがDropdownMenuでanchor == trueで呼び出しているが、 - // falseにしたいために作成 - // IGenericMenuがinternalなのが辛い - public class GenericDropdownMenuIgnoreAnchored : GenericDropdownMenu, IGenericMenu + /// + /// Dropdown()の第3引数を無視するGenericDropdownMenu + /// BasePopupFieldがDropdownMenuでanchor == trueで呼び出しているが、強制的falseにする + /// + /// IGenericMenuがinternalなので次のようなクラスを動的に生成する + /// + /// public class GenericDropdownMenuIgnoreAnchored : GenericDropdownMenu, IGenericMenu + /// { + /// void IGenericMenu.DropDown(Rect position, VisualElement targetElement, bool anchored) + /// => base.DropDown(position, targetElement, false); + /// } + /// + public static class GenericDropdownMenuIgnoreAnchoredBuilder { - void IGenericMenu.DropDown(Rect position, VisualElement targetElement, bool anchored) - => base.DropDown(position, targetElement, false); + private static readonly Type GenericDropdownMenuIgnoreAnchoredType; + + public static GenericDropdownMenu CreateGenericDropdownMenuIgnoreAnchored() + { + return (GenericDropdownMenu)Activator.CreateInstance(GenericDropdownMenuIgnoreAnchoredType); + } + + static GenericDropdownMenuIgnoreAnchoredBuilder() + { + const string dropdownMethodName = "DropDown"; + + var iGenericMenuType = typeof(GenericDropdownMenu).Assembly.GetType("UnityEngine.UIElements.IGenericMenu"); + var moduleBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("RosettaUI.UIToolkit.DynamicAssembly"), AssemblyBuilderAccess.Run).DefineDynamicModule("RosettaUI.UIToolkit.DynamicModule"); + var typeBuilder = moduleBuilder.DefineType("RosettaUI.UIToolkit.GenericDropdownMenuIgnoreAnchored", TypeAttributes.Public | TypeAttributes.Class, typeof(GenericDropdownMenu), new[]{iGenericMenuType}); + + // インターフェイスの実装 + typeBuilder.AddInterfaceImplementation(iGenericMenuType); + + var dropDownMethodArgumentTypes = new[] { typeof(Rect), typeof(VisualElement), typeof(bool) }; + var methodBuilder = typeBuilder.DefineMethod( + dropdownMethodName, + MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.HideBySig | MethodAttributes.NewSlot, + null, + dropDownMethodArgumentTypes + ); + + // IL生成 (メソッドの実装) + var ilGenerator = methodBuilder.GetILGenerator(); + + // 静的メソッドの呼び出しを行うILコードを生成 + ilGenerator.Emit(OpCodes.Ldarg_0); // this + ilGenerator.Emit(OpCodes.Ldarg_1); // Rect position + ilGenerator.Emit(OpCodes.Ldarg_2); // VisualElement targetElement + ilGenerator.Emit(OpCodes.Ldc_I4_0); // bool anchored (false) + ilGenerator.Emit(OpCodes.Call, typeof(GenericDropdownMenu).GetMethod(dropdownMethodName, dropDownMethodArgumentTypes)); + ilGenerator.Emit(OpCodes.Ret); + + // メソッドをインターフェイスのメソッドにマップする + typeBuilder.DefineMethodOverride(methodBuilder, iGenericMenuType.GetMethod(dropdownMethodName)); + + GenericDropdownMenuIgnoreAnchoredType = typeBuilder.CreateType(); + } } } \ No newline at end of file From b63ce8b90e64132be2cb74b32d37c28927cfe78c Mon Sep 17 00:00:00 2001 From: fuqunaga Date: Fri, 29 Nov 2024 16:00:56 +0900 Subject: [PATCH 2/5] fix: #31 remove UnityInternalAccess --- .../Runtime/RosettaUIRootUIToolkit.cs | 1 - .../Runtime/VisualElement/FoldoutCustom.cs | 4 +--- .../Utilities}/DropDownMenuGenerator.cs | 2 +- .../Utilities}/DropDownMenuGenerator.cs.meta | 0 .../GenericDropdownMenuIgnoreAnchored.cs | 0 .../GenericDropdownMenuIgnoreAnchored.cs.meta | 0 .../VisualElement/Utilities/PopupMenuUtility.cs | 1 - .../VisualElement/Utilities}/UIToolkitUtility.cs | 2 +- .../Utilities}/UIToolkitUtility.cs.meta | 0 .../UnityInternalAccess.meta | 8 -------- .../RosettaUI.UnityInternalAccess.asmdef | 16 ---------------- .../RosettaUI.UnityInternalAccess.asmdef.meta | 7 ------- 12 files changed, 3 insertions(+), 38 deletions(-) rename Packages/ga.fuquna.rosettaui.uitoolkit/{UnityInternalAccess => Runtime/VisualElement/Utilities}/DropDownMenuGenerator.cs (97%) rename Packages/ga.fuquna.rosettaui.uitoolkit/{UnityInternalAccess => Runtime/VisualElement/Utilities}/DropDownMenuGenerator.cs.meta (100%) rename Packages/ga.fuquna.rosettaui.uitoolkit/{UnityInternalAccess => Runtime/VisualElement/Utilities}/GenericDropdownMenuIgnoreAnchored.cs (100%) rename Packages/ga.fuquna.rosettaui.uitoolkit/{UnityInternalAccess => Runtime/VisualElement/Utilities}/GenericDropdownMenuIgnoreAnchored.cs.meta (100%) rename Packages/ga.fuquna.rosettaui.uitoolkit/{UnityInternalAccess => Runtime/VisualElement/Utilities}/UIToolkitUtility.cs (96%) rename Packages/ga.fuquna.rosettaui.uitoolkit/{UnityInternalAccess => Runtime/VisualElement/Utilities}/UIToolkitUtility.cs.meta (100%) delete mode 100644 Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess.meta delete mode 100644 Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef delete mode 100644 Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef.meta diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/RosettaUIRootUIToolkit.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/RosettaUIRootUIToolkit.cs index c72ce1b3..049b8569 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/RosettaUIRootUIToolkit.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/RosettaUIRootUIToolkit.cs @@ -1,5 +1,4 @@ using RosettaUI.UIToolkit.Builder; -using RosettaUI.UIToolkit.UnityInternalAccess; using UnityEngine; using UnityEngine.UIElements; diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/FoldoutCustom.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/FoldoutCustom.cs index 085e8945..262a6293 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/FoldoutCustom.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/FoldoutCustom.cs @@ -1,6 +1,4 @@ -using RosettaUI.UIToolkit.UnityInternalAccess; -using UnityEngine; -using UnityEngine.UIElements; +using UnityEngine.UIElements; namespace RosettaUI.UIToolkit { diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/DropDownMenuGenerator.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs similarity index 97% rename from Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/DropDownMenuGenerator.cs rename to Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs index 6cf72076..b4af6441 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/DropDownMenuGenerator.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs @@ -2,7 +2,7 @@ using UnityEngine; using UnityEngine.UIElements; -namespace RosettaUI.UIToolkit.UnityInternalAccess +namespace RosettaUI.UIToolkit { public static class DropDownMenuGenerator { diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/DropDownMenuGenerator.cs.meta b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs.meta similarity index 100% rename from Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/DropDownMenuGenerator.cs.meta rename to Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs.meta diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/GenericDropdownMenuIgnoreAnchored.cs similarity index 100% rename from Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs rename to Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/GenericDropdownMenuIgnoreAnchored.cs diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs.meta b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/GenericDropdownMenuIgnoreAnchored.cs.meta similarity index 100% rename from Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/GenericDropdownMenuIgnoreAnchored.cs.meta rename to Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/GenericDropdownMenuIgnoreAnchored.cs.meta diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/PopupMenuUtility.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/PopupMenuUtility.cs index 7fd51db8..885c1f1e 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/PopupMenuUtility.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/PopupMenuUtility.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using RosettaUI.UIToolkit.Builder; -using RosettaUI.UIToolkit.UnityInternalAccess; using UnityEngine; using UnityEngine.UIElements; diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/UIToolkitUtility.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs similarity index 96% rename from Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/UIToolkitUtility.cs rename to Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs index 1308a92c..0a16a106 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/UIToolkitUtility.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs @@ -2,7 +2,7 @@ using UnityEngine.Assertions; using UnityEngine.UIElements; -namespace RosettaUI.UIToolkit.UnityInternalAccess +namespace RosettaUI.UIToolkit { public static class UIToolkitUtility { diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/UIToolkitUtility.cs.meta b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs.meta similarity index 100% rename from Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/UIToolkitUtility.cs.meta rename to Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs.meta diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess.meta b/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess.meta deleted file mode 100644 index e67f00e3..00000000 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 619d4a0a8354a034c90c67abfd08434f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef b/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef deleted file mode 100644 index 0ff58cce..00000000 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "Unity.InternalAPIEngineBridge.001", - "rootNamespace": "", - "references": [ - "GUID:2b1b0416520827b409049c7e4d90bcc1" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef.meta b/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef.meta deleted file mode 100644 index 82e282b4..00000000 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/UnityInternalAccess/RosettaUI.UnityInternalAccess.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 10043d6ab0c030d489fbc2555e20e9b5 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From f4cf47c8eaa6adc17ae14f5f0735a0acb9645914 Mon Sep 17 00:00:00 2001 From: fuqunaga Date: Fri, 29 Nov 2024 16:28:19 +0900 Subject: [PATCH 3/5] fix UIToolkitUtility build error at Unity2022 --- .../Runtime/VisualElement/Utilities/UIToolkitUtility.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs index 0a16a106..e3540d32 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/UIToolkitUtility.cs @@ -9,6 +9,9 @@ public static class UIToolkitUtility private static MethodInfo _focusControllerGetLeafFocusedElementMethodInfo; #if UNITY_2023_1_OR_NEWER private static PropertyInfo _baseBoolFieldAcceptClicksIfDisabledPropertyInfo; +#else + private static FieldInfo _baseBoolFieldClickableFieldInfo; + private static PropertyInfo _clickableAcceptClicksIfDisabledPropertyInfo; #endif public static bool WillUseKeyInput(IPanel panel) @@ -30,7 +33,11 @@ public static void SetAcceptClicksIfDisabled(BaseBoolField baseBoolField, bool f _baseBoolFieldAcceptClicksIfDisabledPropertyInfo ??= typeof(BaseBoolField).GetProperty("acceptClicksIfDisabled", BindingFlags.NonPublic | BindingFlags.Instance); _baseBoolFieldAcceptClicksIfDisabledPropertyInfo?.SetValue(baseBoolField, flag); #else - baseBoolField.m_Clickable.acceptClicksIfDisabled = flag; + _baseBoolFieldClickableFieldInfo ??= typeof(BaseBoolField).GetField("m_Clickable", BindingFlags.NonPublic | BindingFlags.Instance); + _clickableAcceptClicksIfDisabledPropertyInfo ??= typeof(Clickable).GetProperty("acceptClicksIfDisabled", BindingFlags.NonPublic | BindingFlags.Instance); + + var baseBoolFieldClickable = _baseBoolFieldClickableFieldInfo?.GetValue(baseBoolField); + _clickableAcceptClicksIfDisabledPropertyInfo?.SetValue(baseBoolFieldClickable, flag); #endif } } From 00f5bb88e05baeceaf7a4d9b3a1aa9b21e7bd14d Mon Sep 17 00:00:00 2001 From: fuqunaga Date: Fri, 29 Nov 2024 17:23:19 +0900 Subject: [PATCH 4/5] fix DropDownMenuGenerator build error at Unity2022 --- .../Utilities/DropDownMenuGenerator.cs | 99 +++++++++++++++++-- 1 file changed, 89 insertions(+), 10 deletions(-) diff --git a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs index b4af6441..292bec93 100644 --- a/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs +++ b/Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/VisualElement/Utilities/DropDownMenuGenerator.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Reflection; using UnityEngine; using UnityEngine.UIElements; @@ -16,25 +18,37 @@ public static object Generate(IEnumerable menuItems, Rect position, Vi #else // refs: BasePopupField // https://github.com/Unity-Technologies/UnityCsReference/blob/c84064be69f20dcf21ebe4a7bbc176d48e2f289c/ModuleOverrides/com.unity.ui/Core/Controls/BasePopupField.cs#L206 - var isPlayer = targetElement?.elementPanel.contextType == ContextType.Player; - - IGenericMenu menu; + var isPlayer = targetElement?.panel.contextType == ContextType.Player; + + GenericDropdownMenuWrapper menu; if (isPlayer) { - // Unity2022.3でスクロールバーが表示されてしまう(バグ?)のであらかじめ広めの幅を確保しておく var genericMenu = new GenericDropdownMenu(); - genericMenu.contentContainer.style.width = 200; - - menu = genericMenu; + menu = new GenericDropdownMenuWrapper(genericMenu); } - // GenericDropdownMenu だとエディターでエラーになる場合があるのでDropdownUtility経由でOSのメニューを使用する // RosettaUIEditorWindowExample > MiscExample > UI.Popup() でエラーになる - // Unity2022.3 + // at Unity2022.3 else { + // DropdownUtility.CreateDropdown() は internal なのでリフレクションで取得 +#if false menu = DropdownUtility.CreateDropdown(); +#else + _createDropdownFunc ??= (Func)typeof(VisualElement).Assembly + .GetType("UnityEngine.UIElements.DropdownUtility")? + .GetMethod("CreateDropdown", BindingFlags.NonPublic | BindingFlags.Static)? + .CreateDelegate(typeof(Func)); + + if (_createDropdownFunc == null) + { + return null; + } + + menu = new GenericDropdownMenuWrapper(_createDropdownFunc()); +#endif } + #endif foreach (var item in menuItems) @@ -58,5 +72,70 @@ public static object Generate(IEnumerable menuItems, Rect position, Vi menu.DropDown(position, targetElement, anchored); return menu; } + +#if !UNITY_2023_1_OR_NEWER + private static Func _createDropdownFunc; + + /// + /// UnityEngine.UIElements.IGenericMenu が internal なので代替インターフェース + /// + private class GenericDropdownMenuWrapper + { + private class MethodInfoSet + { + private static readonly Type[] AddItemTypes = {typeof(string), typeof(bool), typeof(Action)}; + private static readonly Type[] AddDisabledItemTypes = {typeof(string), typeof(bool)}; + private static readonly Type[] AddSeparatorTypes = {typeof(string)}; + private static readonly Type[] DropDownTypes = {typeof(Rect), typeof(VisualElement), typeof(bool)}; + + public readonly MethodInfo addItem; + public readonly MethodInfo addDisabledItem; + public readonly MethodInfo addSeparator; + public readonly MethodInfo dropDown; + + public MethodInfoSet(Type type) + { + addItem = type.GetMethod("AddItem", AddItemTypes); + addDisabledItem = type.GetMethod("AddDisabledItem", AddDisabledItemTypes); + addSeparator = type.GetMethod("AddSeparator", AddSeparatorTypes); + dropDown = type.GetMethod("DropDown", DropDownTypes); + } + } + + + private static readonly Dictionary TypeToMethodInfoSet = new(); + + private static MethodInfoSet GetMethodInfoSet(Type type) + { + if (!TypeToMethodInfoSet.TryGetValue(type, out var methodInfoSet)) + { + methodInfoSet = new MethodInfoSet(type); + TypeToMethodInfoSet[type] = methodInfoSet; + } + + return methodInfoSet; + } + + + private readonly Action _addItemAction; + private readonly Action _addDisabledItemAction; + private readonly Action _addSeparatorAction; + private readonly Action _dropDownAction; + + public GenericDropdownMenuWrapper(object baseObject) + { + var methodInfoSet = GetMethodInfoSet(baseObject.GetType()); + _addItemAction = (Action)Delegate.CreateDelegate(typeof(Action), baseObject, methodInfoSet.addItem); + _addDisabledItemAction = (Action)Delegate.CreateDelegate(typeof(Action), baseObject, methodInfoSet.addDisabledItem); + _addSeparatorAction = (Action)Delegate.CreateDelegate(typeof(Action), baseObject, methodInfoSet.addSeparator); + _dropDownAction = (Action)Delegate.CreateDelegate(typeof(Action), baseObject, methodInfoSet.dropDown); + } + + public void AddItem(string name, bool isChecked, Action action) => _addItemAction(name, isChecked, action); + public void AddDisabledItem(string name, bool isChecked) => _addDisabledItemAction(name, isChecked); + public void AddSeparator(string path) => _addSeparatorAction(path); + public void DropDown(Rect position, VisualElement targetElement, bool anchored) => _dropDownAction(position, targetElement, anchored); + } +#endif } } \ No newline at end of file From c953170e4453c281da82af5a6755674006027183 Mon Sep 17 00:00:00 2001 From: fuqunaga Date: Fri, 29 Nov 2024 17:34:35 +0900 Subject: [PATCH 5/5] update settings --- .../.idea/projectSettingsUpdater.xml | 2 +- ProjectSettings/ProjectSettings.asset | 133 +++++++++++++----- 2 files changed, 98 insertions(+), 37 deletions(-) diff --git a/.idea/.idea.RosettaUI/.idea/projectSettingsUpdater.xml b/.idea/.idea.RosettaUI/.idea/projectSettingsUpdater.xml index 4bb9f4d2..86cc6c63 100644 --- a/.idea/.idea.RosettaUI/.idea/projectSettingsUpdater.xml +++ b/.idea/.idea.RosettaUI/.idea/projectSettingsUpdater.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index f772320b..bfae6eec 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 23 + serializedVersion: 28 productGUID: d67776f7afbae944d8e598af431888df AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -42,20 +42,23 @@ PlayerSettings: m_SplashScreenLogos: [] m_VirtualRealitySplashScreen: {fileID: 0} m_HolographicTrackingLossScreen: {fileID: 0} - defaultScreenWidth: 1024 - defaultScreenHeight: 768 + defaultScreenWidth: 1600 + defaultScreenHeight: 1200 defaultScreenWidthWeb: 960 defaultScreenHeightWeb: 600 m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 + unsupportedMSAAFallback: 0 + m_SpriteBatchMaxVertexCount: 65535 + m_SpriteBatchVertexThreshold: 300 m_MTRendering: 1 mipStripping: 0 numberOfMipsStripped: 0 + numberOfMipsStrippedPerMipmapLimitGroup: {} m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 iosUseCustomAppBackgroundBehavior: 0 - iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 allowedAutorotateToLandscapeRight: 1 @@ -68,16 +71,18 @@ PlayerSettings: androidRenderOutsideSafeArea: 1 androidUseSwappy: 1 androidBlitType: 0 - androidResizableWindow: 0 + androidResizeableActivity: 0 androidDefaultWindowWidth: 1920 androidDefaultWindowHeight: 1080 androidMinimumWindowWidth: 400 androidMinimumWindowHeight: 300 androidFullscreenMode: 1 + androidAutoRotationBehavior: 1 + androidPredictiveBackSupport: 0 + androidApplicationEntry: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 - captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 Force IOS Speakers When Recording: 0 @@ -85,13 +90,15 @@ PlayerSettings: hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 + dedicatedServerOptimizations: 1 bakeCollisionMeshes: 0 forceSingleInstance: 0 useFlipModelSwapchain: 1 - resizableWindow: 0 + resizableWindow: 1 useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games gpuSkinning: 1 + meshDeformation: 2 xboxPIXTextureCapture: 0 xboxEnableAvatar: 0 xboxEnableKinect: 0 @@ -99,7 +106,7 @@ PlayerSettings: xboxEnableFitness: 0 visibleInBackground: 1 allowFullscreenSwitch: 1 - fullscreenMode: 1 + fullscreenMode: 3 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 @@ -119,21 +126,20 @@ PlayerSettings: switchNVNShaderPoolsGranularity: 33554432 switchNVNDefaultPoolsGranularity: 16777216 switchNVNOtherPoolsGranularity: 16777216 + switchGpuScratchPoolGranularity: 2097152 + switchAllowGpuScratchShrinking: 0 switchNVNMaxPublicTextureIDCount: 0 switchNVNMaxPublicSamplerIDCount: 0 - stadiaPresentMode: 0 - stadiaTargetFramerate: 0 + switchMaxWorkerMultiple: 8 + switchNVNGraphicsFirmwareMemory: 32 vulkanNumSwapchainBuffers: 3 vulkanEnableSetSRGBWrite: 0 vulkanEnablePreTransform: 0 vulkanEnableLateAcquireNextImage: 0 vulkanEnableCommandBufferRecycling: 1 - m_SupportedAspectRatios: - 4:3: 1 - 5:4: 1 - 16:10: 1 - 16:9: 1 - Others: 1 + loadStoreDebugModeEnabled: 0 + visionOSBundleVersion: 1.0 + tvOSBundleVersion: 1.0 bundleVersion: 0.0.0 preloadedAssets: [] metroInputSource: 0 @@ -146,23 +152,26 @@ PlayerSettings: isWsaHolographicRemotingEnabled: 0 enableFrameTimingStats: 0 enableOpenGLProfilerGPURecorders: 1 + allowHDRDisplaySupport: 0 useHDRDisplay: 0 - D3DHDRBitDepth: 0 + hdrBitDepth: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 resolutionScalingMode: 0 resetResolutionOnWindowResize: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 + androidMinAspectRatio: 1 applicationIdentifier: Standalone: com.fuquna.ga.RosettaUI buildNumber: Standalone: 0 + VisionOS: 0 iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 0 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 22 + AndroidMinSdkVersion: 23 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: @@ -172,15 +181,20 @@ PlayerSettings: ForceInternetPermission: 0 ForceSDCardPermission: 0 CreateWallpaper: 0 - APKExpansionFiles: 0 + androidSplitApplicationBinary: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 1 + strictShaderVariantMatching: 0 VertexChannelCompressionMask: 4054 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 11.0 + iOSSimulatorArchitecture: 0 + iOSTargetOSVersionString: 13.0 tvOSSdkVersion: 0 + tvOSSimulatorArchitecture: 0 tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 11.0 + tvOSTargetOSVersionString: 13.0 + VisionOSSdkVersion: 0 + VisionOSTargetOSVersionString: 1.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 @@ -205,7 +219,6 @@ PlayerSettings: rgba: 0 iOSLaunchScreenFillPct: 100 iOSLaunchScreenSize: 100 - iOSLaunchScreenCustomXibPath: iOSLaunchScreeniPadType: 0 iOSLaunchScreeniPadImage: {fileID: 0} iOSLaunchScreeniPadBackgroundColor: @@ -213,7 +226,6 @@ PlayerSettings: rgba: 0 iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 - iOSLaunchScreeniPadCustomXibPath: iOSLaunchScreenCustomStoryboardPath: iOSLaunchScreeniPadCustomStoryboardPath: iOSDeviceRequirements: [] @@ -223,13 +235,16 @@ PlayerSettings: iOSMetalForceHardShadows: 0 metalEditorSupport: 1 metalAPIValidation: 1 + metalCompileShaderBinary: 0 iOSRenderExtraFrameOnPause: 0 iosCopyPluginsCodeInsteadOfSymlink: 0 appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + VisionOSManualSigningProvisioningProfileID: iOSManualSigningProvisioningProfileType: 0 tvOSManualSigningProvisioningProfileType: 0 + VisionOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 iOSRequireARKit: 0 iOSAutomaticallyDetectAndAddCapabilities: 1 @@ -244,13 +259,15 @@ PlayerSettings: useCustomLauncherGradleManifest: 0 useCustomBaseGradleTemplate: 0 useCustomGradlePropertiesTemplate: 0 + useCustomGradleSettingsTemplate: 0 useCustomProguardFile: 0 AndroidTargetArchitectures: 1 - AndroidTargetDevices: 0 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: AndroidKeyaliasName: + AndroidEnableArmv9SecurityFeatures: 0 + AndroidEnableArm64MTE: 0 AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 0 AndroidIsGame: 1 @@ -263,12 +280,12 @@ PlayerSettings: height: 180 banner: {fileID: 0} androidGamepadSupportLevel: 0 - chromeosInputEmulation: 1 - AndroidMinifyWithR8: 0 AndroidMinifyRelease: 0 AndroidMinifyDebug: 0 AndroidValidateAppBundleSize: 1 AndroidAppBundleSizeToValidate: 150 + AndroidReportGooglePlayAppDependencies: 1 + androidSymbolsSizeThreshold: 800 m_BuildTargetIcons: [] m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: @@ -351,11 +368,13 @@ PlayerSettings: tvOS: 1 m_BuildTargetGroupLightmapEncodingQuality: [] m_BuildTargetGroupLightmapSettings: [] + m_BuildTargetGroupLoadStoreDebugModeSettings: [] m_BuildTargetNormalMapEncoding: [] m_BuildTargetDefaultTextureCompressionFormat: [] playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 + editorGfxJobOverride: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 enableCrashReportAPI: 0 @@ -363,6 +382,7 @@ PlayerSettings: locationUsageDescription: microphoneUsageDescription: bluetoothUsageDescription: + macOSTargetOSVersion: 11.0 switchNMETAOverride: switchNetLibKey: switchSocketMemoryPoolSize: 6144 @@ -370,10 +390,11 @@ PlayerSettings: switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 - switchUseGOLDLinker: 0 + switchEnableFileSystemTrace: 0 switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: + switchCompilerFlags: switchTitleNames_0: switchTitleNames_1: switchTitleNames_2: @@ -447,7 +468,6 @@ PlayerSettings: switchReleaseVersion: 0 switchDisplayVersion: 1.0.0 switchStartupUserAccount: 0 - switchTouchScreenUsage: 0 switchSupportedLanguagesMask: 0 switchLogoType: 0 switchApplicationErrorCodeCategory: @@ -489,6 +509,7 @@ PlayerSettings: switchNativeFsCacheSize: 32 switchIsHoldTypeHorizontal: 0 switchSupportedNpadCount: 8 + switchEnableTouchScreen: 1 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -499,13 +520,14 @@ PlayerSettings: switchSocketBufferEfficiency: 4 switchSocketInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1 - switchPlayerConnectionEnabled: 1 + switchDisableHTCSPlayerConnection: 0 switchUseNewStyleFilepaths: 0 switchUseLegacyFmodPriorities: 1 switchUseMicroSleepForYield: 1 switchEnableRamDiskSupport: 0 switchMicroSleepForYieldTime: 25 switchRamDiskSpaceSize: 12 + switchUpgradedPlayerSettingsToNMETA: 0 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -589,6 +611,7 @@ PlayerSettings: webGLMemorySize: 16 webGLExceptionSupport: 1 webGLNameFilesAsHashes: 0 + webGLShowDiagnostics: 0 webGLDataCaching: 1 webGLDebugSymbols: 0 webGLEmscriptenArgs: @@ -601,26 +624,53 @@ PlayerSettings: webGLLinkerTarget: 1 webGLThreadsSupport: 0 webGLDecompressionFallback: 0 + webGLInitialMemorySize: 32 + webGLMaximumMemorySize: 2048 + webGLMemoryGrowthMode: 2 + webGLMemoryLinearGrowthStep: 16 + webGLMemoryGeometricGrowthStep: 0.2 + webGLMemoryGeometricGrowthCap: 96 + webGLEnableWebGPU: 0 webGLPowerPreference: 2 + webGLWebAssemblyTable: 0 + webGLWebAssemblyBigInt: 0 + webGLCloseOnQuit: 0 + webWasm2023: 0 scriptingDefineSymbols: {} additionalCompilerArguments: {} platformArchitecture: {} - scriptingBackend: {} + scriptingBackend: + Android: 0 il2cppCompilerConfiguration: {} - managedStrippingLevel: {} + il2cppCodeGeneration: {} + il2cppStacktraceInformation: {} + managedStrippingLevel: + Android: 1 + EmbeddedLinux: 1 + GameCoreScarlett: 1 + GameCoreXboxOne: 1 + Nintendo Switch: 1 + PS4: 1 + PS5: 1 + QNX: 1 + ReservedCFE: 1 + VisionOS: 1 + WebGL: 1 + Windows Store Apps: 1 + XboxOne: 1 + iPhone: 1 + tvOS: 1 incrementalIl2cppBuild: {} suppressCommonWarnings: 1 allowUnsafeCode: 0 useDeterministicCompilation: 1 - enableRoslynAnalyzers: 1 - selectedPlatform: 0 additionalIl2CppArgs: scriptingRuntimeVersion: 1 gcIncremental: 1 - assemblyVersionValidation: 1 gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: Standalone: 6 + editorAssembliesCompatibilityLevel: 1 m_RenderingPath: 1 m_MobileRenderingPath: 1 metroPackageName: Template_3D @@ -644,6 +694,7 @@ PlayerSettings: metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} metroSplashScreenUseBackgroundColor: 0 + syncCapabilities: 0 platformCapabilities: {} metroTargetDeviceFamilies: {} metroFTAName: @@ -691,7 +742,14 @@ PlayerSettings: luminVersion: m_VersionCode: 1 m_VersionName: + hmiPlayerDataPath: + hmiForceSRGBBlit: 1 + embeddedLinuxEnableGamepadInput: 0 + hmiCpuConfiguration: + hmiLogStartupTiming: 0 + qnxGraphicConfPath: apiCompatibilityLevel: 6 + captureStartupLogs: {} activeInputHandler: 2 windowsGamepadBackendHint: 0 cloudProjectId: @@ -701,6 +759,9 @@ PlayerSettings: organizationId: cloudEnabled: 0 legacyClampBlendShapeWeights: 0 - playerDataPath: - forceSRGBBlit: 1 + hmiLoadingImage: {fileID: 0} + platformRequiresReadableAssets: 0 virtualTexturingSupportEnabled: 0 + insecureHttpOption: 0 + androidVulkanDenyFilterList: [] + androidVulkanAllowFilterList: []