BS 0.2.0 UI控件同步 / EP Unity.1 Diagram版本下的附属增强提案

This commit is contained in:
2025-07-23 15:22:18 +08:00
parent d0e5420f95
commit 86842492ea
30 changed files with 1471 additions and 96 deletions

View File

@@ -58,17 +58,17 @@ namespace Convention.WindowsUI
}
}
public interface IText : IAnyClass
public interface IText
{
string text { get; set; }
}
public interface ITitle : IAnyClass
public interface ITitle
{
string title { get; set; }
}
public interface IInteractable : IAnyClass
public interface IInteractable
{
bool interactable { get; set; }
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7501c6bc00ab245409b71690e7011ff0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,108 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Convention.WindowsUI;
using UnityEngine;
namespace Convention.SO
{
[CreateAssetMenu(fileName = "new WindowsConfig", menuName = "Convention/WindowsConfig", order = 200)]
public class Windows : ScriptableObject
{
public static string GlobalWindowsConfig = "WindowConfig";
public static Windows GlobalInstance => Resources.Load<Windows>(GlobalWindowsConfig);
public static void InitExtensionEnv()
{
default_exist_names = GetDefaultNames();
#if CONVENTION_DISABLE_WINDOWSO_GLOBAL_INIT
GlobalWindowsConfig = "WindowConfig";
#endif
}
public static string[] GetDefaultNames()
{
List<string> names = new();
foreach (var item in Assembly.GetAssembly(typeof(Windows)).GetTypes())
{
if (item.IsSubclassOf(typeof(WindowsComponent)) ||
(item.IsInterface == false && item.GetInterface(nameof(IWindowUIModule)) != null)
)
{
names.Add(item.Name);
}
}
names.Add(nameof(WindowManager));
names.Remove(nameof(WindowUIModule));
return names.ToArray();
}
private static string[] default_exist_names = GetDefaultNames();
private void OnEnable()
{
Reset();
}
public override void Reset()
{
base.Reset();
foreach (string name in default_exist_names)
{
var resourcesArray = Resources.LoadAll(name);
foreach (var item in resourcesArray)
{
if (item is not GameObject)
continue;
if((item as GameObject).GetComponents<MonoBehaviour>().Length == 0)
continue;
this.uobjects[name] = item;
break;
}
}
}
[return: When("Datas's keys contains [In]name"), ReturnMayNull]
public WindowsComponent[] GetWindowsComponents([In] string name)
{
if (this.uobjects.TryGetValue(name, out var uobj))
{
var go = (uobj as GameObject);
return go.GetComponents<WindowsComponent>();
}
else return null;
}
[return: When("Datas's keys contains [In]name"), IsInstantiated(false), ReturnMayNull]
public WindowsComponent GetWindowsComponent([In] string name)
{
var wc = GetWindowsComponents(name);
if (wc.Length == 0)
return null;
return wc[0];
}
[return: When("Datas's keys contains [In]name and instance is T"), IsInstantiated(false)]
public T GetWindowsComponent<T>([In] string name) where T : WindowsComponent
{
return GetWindowsComponents(name).FirstOrDefault(P => (P as T) != null) as T;
}
[return: When("Datas's keys contains [In]name"), ReturnMayNull]
public IWindowUIModule[] GetWindowsUIs([In] string name)
{
if (this.uobjects.TryGetValue(name, out var value))
return (value as GameObject).GetComponents<IWindowUIModule>();
return null;
}
[return: When("Datas's keys contains [In]name"), IsInstantiated(false), ReturnMayNull]
public IWindowUIModule GetWindowsUI([In] string name)
{
var wm = GetWindowsUIs(name);
if (wm.Length == 0)
return null;
return wm[0];
}
[return: When("Datas's keys contains [In]name and instance is T"), IsInstantiated(false)]
public T GetWindowsUI<T>([In] string name) where T : class, IWindowUIModule
{
return GetWindowsUIs(name).FirstOrDefault(P => (P as T) != null) as T;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9dd186d241a818c4ab7de0a4f670b959
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -15,11 +15,6 @@ namespace Convention.WindowsUI.Variant
[Resources, OnlyNotNullMode, SerializeField, Tooltip("Path Text")] private Text m_PathTitle;
[Content, OnlyPlayMode] public string CurrentTargetName;
[Content, OnlyPlayMode, SerializeField] public List<string> pathContainer = new();
private RegisterWrapper<AssetsWindow> m_RegisterWrapper;
private void OnDestroy()
{
m_RegisterWrapper.Release();
}
public PropertiesWindow MainPropertiesWindow => m_PropertiesWindow;
@@ -33,12 +28,11 @@ namespace Convention.WindowsUI.Variant
{
m_BackButton.onClick.AddListener(() => Pop(true));
UpdatePathText();
m_RegisterWrapper = new(() => { });
Architecture.RegisterWithDuplicateAllow(typeof(AssetsWindow), this, () => { });
}
protected virtual void Reset()
{
m_PropertiesWindow.m_PerformanceMode = PerformanceIndicator.PerformanceMode.L1;
m_PropertiesWindow = GetComponent<PropertiesWindow>();
}

View File

@@ -9,7 +9,7 @@ namespace Convention.WindowsUI.Variant
public static void InitLoadedRoots(ref List<string> LoadedInRoot)
{
LoadedInRoot = new List<string>();
if (PlatformIndicator.is_platform_windows)
if (PlatformIndicator.IsPlatformWindows)
{
LoadedInRoot.Add(Application.persistentDataPath);
LoadedInRoot.Add(Application.streamingAssetsPath);

View File

@@ -7,7 +7,7 @@ using UnityEngine.UI;
namespace Convention.WindowsUI.Variant
{
public class FileSystemAssetsItem : MonoAnyBehaviour, AssetsItem.IAssetsItemInvoke
public class FileSystemAssetsItem : MonoBehaviour, AssetsItem.IAssetsItemInvoke
{
public static Dictionary<string, ToolFile> LoadedFiles = new();
public static long LoadedFileAutoLoadMaxFileSize = 1024 * 50;
@@ -18,15 +18,6 @@ namespace Convention.WindowsUI.Variant
[Content, OnlyNotNullMode, SerializeField, InspectorDraw(InspectorDrawType.Toggle), Ignore]
private bool m_IsLoading = false;
private void OnDestroy()
{
if (m_File.data is AssetBundle)
{
return;
}
m_File.data = null;
}
public void RebuildFileInfo([In] string path)
{
if (LoadedFiles.ContainsKey(path))
@@ -67,15 +58,15 @@ namespace Convention.WindowsUI.Variant
private void OnAssetsItemFocusWithFileMode([In] AssetsItem item, [In] string name)
{
item.title = name;
FileSystemAssets.instance.CurrentSelectFilename.title = m_File.FullPath;
if (m_File.IsExist == false)
FileSystemAssets.instance.CurrentSelectFilename.title = m_File.GetFullPath();
if (m_File.Exists() == false)
return;
else if (m_File.IsDir())
UpdateSprite(item, "folder");
else if (m_File.Extension.Length != 0 && m_Icons.uobjects.ContainsKey(m_File.Extension))
UpdateSprite(item, m_File.Extension);
else if (m_File.Extension.Length != 0 && m_Icons.uobjects.ContainsKey(m_File.Extension[1..]))
UpdateSprite(item, m_File.Extension[1..]);
else if (m_File.GetExtension().Length != 0 && m_Icons.uobjects.ContainsKey(m_File.GetExtension()))
UpdateSprite(item, m_File.GetExtension());
else if (m_File.GetExtension().Length != 0 && m_Icons.uobjects.ContainsKey(m_File.GetExtension()[1..]))
UpdateSprite(item, m_File.GetExtension()[1..]);
else if (m_File.IsImage)
UpdateSprite(item, "image");
else if (m_File.IsText)
@@ -101,8 +92,9 @@ namespace Convention.WindowsUI.Variant
private class SkyItem : AssetBundleItem
{
[Resources, SerializeField] private Material SkyBox;
public class SkyItemInstanceWrapper : Singleton<SkyItemInstanceWrapper>
public class SkyItemInstanceWrapper
{
public static SkyItemInstanceWrapper instance { get; protected set; }
public static void InitInstance()
{
if (instance == null)

View File

@@ -9,7 +9,6 @@ namespace Convention.WindowsUI.Variant
{
[Resources, OnlyNotNullMode] public WindowManager m_WindowManager;
[Resources, SerializeField, OnlyNotNullMode] private PropertiesWindow m_PropertiesWindow;
private RegisterWrapper<ConversationWindow> m_RegisterWrapper;
[Resources, Header("HeadLine"), OnlyNotNullMode] public Image HeadIcon;
[Resources, OnlyNotNullMode] public ModernUIInputField HeadText = new();
@@ -36,15 +35,11 @@ namespace Convention.WindowsUI.Variant
private void Start()
{
m_RegisterWrapper = new(() =>
Architecture.RegisterWithDuplicateAllow(typeof(ConversationWindow), this, () =>
{
});
}
private void OnDestroy()
{
m_RegisterWrapper.Release();
}
public void SetHeadText(string text)
{

View File

@@ -7,11 +7,11 @@ namespace Convention
{
public interface ILoadedInHierarchy { }
public interface IOnlyLoadedInHierarchy { }
public class HierarchyLoadedIn : MonoAnyBehaviour
public class HierarchyLoadedIn : MonoBehaviour
{
private void Update()
{
if (!RegisterBaseWrapperExtension.Registers.ContainsKey(typeof(WindowsUI.Variant.HierarchyWindow)))
if (!Architecture.Contains<WindowsUI.Variant.HierarchyWindow>())
return;
var onlys = GetComponents<IOnlyLoadedInHierarchy>();
try

View File

@@ -9,14 +9,13 @@ namespace Convention.WindowsUI.Variant
{
[Resources] public WindowManager windowManager;
[Resources, SerializeField] private PropertiesWindow m_PropertiesWindow;
private RegisterWrapper<HierarchyWindow> m_RegisterWrapper;
private Dictionary<int, object> AllReferenceLinker = new();
private Dictionary<object, int> AllReferenceLinker_R = new();
private Dictionary<object, HierarchyItem> AllReferenceItemLinker = new();
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>tab
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ӧ<EFBFBD><D3A6>tab
/// </summary>
/// <param name="reference"></param>
/// <param name="item"></param>
@@ -97,7 +96,7 @@ namespace Convention.WindowsUI.Variant
private void Start()
{
m_RegisterWrapper = new(() => { });
Architecture.RegisterWithDuplicateAllow(typeof(HierarchyWindow), this, () => { });
}
private void Reset()
@@ -106,10 +105,6 @@ namespace Convention.WindowsUI.Variant
m_PropertiesWindow = GetComponent<PropertiesWindow>();
AllReferenceLinker = new();
}
private void OnDestroy()
{
m_RegisterWrapper.Release();
}
public void RenameTabWhenItFocus()
{

View File

@@ -37,7 +37,7 @@ namespace Convention.WindowsUI.Variant
if (path == null || path.Length == 0)
return;
var file = new ToolFile(path);
if (file.IsExist == false)
if (file.Exists() == false)
return;
Texture2D texture = file.LoadAsImage();
SetImage(texture);

View File

@@ -8,7 +8,7 @@ using static Convention.WindowsUI.Variant.PropertiesWindow;
namespace Convention.WindowsUI.Variant
{
/// <summary>
/// enum&1==1<><31>Ϊ<EFBFBD><CEAA>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// enum&1==1<><31>Ϊ<EFBFBD><CEAA>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
public enum InspectorDrawType
{
@@ -400,9 +400,8 @@ namespace Convention.WindowsUI.Variant
/// <summary>
/// ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>, <20><><EFBFBD><EFBFBD>GameObject<63><74>SetTarget<65><74>Inspector<6F><72>ʱֻչʾ<D5B9><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չʾComponentsҲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><To GameObject><3E><>ת<EFBFBD><D7AA>GameObject<63><74>Components<74>б<EFBFBD>,
/// <20><><see cref="InspectorWindow.BuildWindow"/>
///
/// <see cref="InspectorWindow.BuildWindow"/>
/// </summary>
public interface IOnlyFocusThisOnInspector : IAnyClass { }
public interface IOnlyFocusThisOnInspector { }
}

View File

@@ -9,7 +9,7 @@ namespace Convention.WindowsUI.Variant
{
[Resources] public ModernUIInputField TextArea;
[Resources] public Button RawButton;
public IAnyClass lastReference;
public object lastReference;
[Content] public bool isEditing = false;
private void OnCallback(string str)

View File

@@ -7,10 +7,9 @@ using UnityEngine;
namespace Convention.WindowsUI.Variant
{
public class InspectorWindow : WindowsComponent, ISingleton<InspectorWindow>
public class InspectorWindow : WindowsComponent
{
public static InspectorWindow instance { get; private set; }
private RegisterWrapper<InspectorWindow> m_RegisterWrapper;
private object target;
[Setting] public bool IsWorkWithHierarchyWindow = true;
@@ -32,11 +31,6 @@ namespace Convention.WindowsUI.Variant
m_PropertiesWindow = GetComponent<PropertiesWindow>();
}
private void OnDestroy()
{
m_RegisterWrapper.Release();
}
private void Start()
{
if (m_WindowManager == null)
@@ -44,7 +38,7 @@ namespace Convention.WindowsUI.Variant
if (m_PropertiesWindow == null)
m_PropertiesWindow = GetComponent<PropertiesWindow>();
m_RegisterWrapper = new(() => { });
Architecture.RegisterWithDuplicateAllow(typeof(InspectorWindow), this, () => { });
instance = this;
if (IsWorkWithHierarchyWindow == true)
@@ -91,12 +85,12 @@ namespace Convention.WindowsUI.Variant
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ӧ<EFBFBD><D3A6>tab
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ӧ<EFBFBD><D3A6>tab
/// </summary>
/// <param name="target"></param>
/// <param name="item"></param>
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EBB4AB><EFBFBD><EFBFBD>target<EFBFBD><EFBFBD>ͬ</returns>
[return: When("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>target<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtarget<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ")]
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EBB4AB><EFBFBD>target<65><74>ͬ</returns>
[return: When("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>target<65><EFBFBD><EBB1BB><EFBFBD><EFBFBD>Ϊtarget<65><74>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>ͬ")]
public bool SetTarget([In] object target, [In, Opt] HierarchyItem item)
{
if (item != null && IsWorkWithHierarchyWindow)
@@ -159,7 +153,6 @@ namespace Convention.WindowsUI.Variant
m_currentEntries.Clear();
}
private static readonly Type[] IgnoreCutOffType = new Type[] {
typeof(MonoAnyBehaviour),
typeof(GameObject),
typeof(MonoBehaviour),
typeof(UnityEngine.Object),

View File

@@ -7,11 +7,13 @@ using UnityEngine.UI;
namespace Convention.WindowsUI.Variant
{
public class PropertiesWindow : MonoAnyBehaviour
public class PropertiesWindow : MonoBehaviour
{
[ArgPackage]
public class ItemEntry : LeftValueReference<WindowUIModule>
public class ItemEntry
{
private WindowUIModule m_module;
#region Tools
private static bool IsSetupParentRectTransformAdjustSizeToContainsChilds = false;
@@ -118,8 +120,8 @@ namespace Convention.WindowsUI.Variant
public static IActionInvoke MakeItemAsActionInvoke(
[In, Out] ItemEntry entry,
[In] string invokerName, [In] PropertiesWindow parent,
[In][Opt, When("If you sure not need a target")] IAnyClass target,
params UnityAction<IAnyClass>[] actions)
[In][Opt, When("If you sure not need a target")] object target,
params UnityAction<object>[] actions)
{
entry.ref_value = InstantiateItemObject(invokerName, parent.m_WindowManager, parent.m_WindowsConfig);
var invoker = entry.ref_value as IActionInvoke;
@@ -132,8 +134,8 @@ namespace Convention.WindowsUI.Variant
public static IButton MakeItemAsActionInvoke(
[In, Out] ItemEntry entry,
[In] string invokerName, [In] ItemEntry parent, [In] SO.Windows config,
[In][Opt, When("If you sure not need a target")] IAnyClass target,
params UnityAction<IAnyClass>[] actions)
[In][Opt, When("If you sure not need a target")] object target,
params UnityAction<object>[] actions)
{
entry.ref_value = InstantiateItemObject(invokerName, parent.ref_value.GetComponent<RectTransform>(), config);
var invoker = entry.ref_value as IButton;
@@ -147,8 +149,8 @@ namespace Convention.WindowsUI.Variant
public static IButton MakeItemAsButton(
[In, Out] ItemEntry entry,
[In] string buttonName, [In] PropertiesWindow parent,
[In][Opt, When("If you sure not need a target")] IAnyClass target,
params UnityAction<IAnyClass>[] actions)
[In][Opt, When("If you sure not need a target")] object target,
params UnityAction<object>[] actions)
{
entry.ref_value = InstantiateItemObject(buttonName, parent.m_WindowManager, parent.m_WindowsConfig);
var button = entry.ref_value as IButton;
@@ -161,8 +163,8 @@ namespace Convention.WindowsUI.Variant
public static IButton MakeItemAsButton(
[In, Out] ItemEntry entry,
[In] string buttonName, [In] ItemEntry parent, [In] SO.Windows config,
[In][Opt, When("If you sure not need a target")] IAnyClass target,
params UnityAction<IAnyClass>[] actions)
[In][Opt, When("If you sure not need a target")] object target,
params UnityAction<object>[] actions)
{
entry.ref_value = InstantiateItemObject(buttonName, parent.ref_value.GetComponent<RectTransform>(), config);
var button = entry.ref_value as IButton;
@@ -219,18 +221,18 @@ namespace Convention.WindowsUI.Variant
#endregion
public override WindowUIModule ref_value
public WindowUIModule ref_value
{
get => base.ref_value;
get => m_module;
set
{
if (base.ref_value != value)
if (m_module != value)
{
if (base.ref_value != null)
if (m_module != null)
{
base.ref_value.gameObject.SetActive(false);
m_module.gameObject.SetActive(false);
}
base.ref_value = value;
m_module = value;
if (parentWindow != null)
{
parentWindow.m_WindowManager.SelectContextPlane(parentWindow.m_TargetWindowContent);
@@ -266,7 +268,7 @@ namespace Convention.WindowsUI.Variant
public List<ItemEntry> GetChilds() => new(childs);
public ItemEntry GetParent() => parentEntry;
public ItemEntry(PropertiesWindow parent) : base(null)
public ItemEntry(PropertiesWindow parent)
{
childs = new();
this.parentWindow = parent;
@@ -274,7 +276,7 @@ namespace Convention.WindowsUI.Variant
parent.m_Entrys.Add(this);
layer = 0;
}
public ItemEntry(ItemEntry parent) : base(null)
public ItemEntry(ItemEntry parent)
{
childs = new();
this.parentEntry = parent;
@@ -401,7 +403,6 @@ namespace Convention.WindowsUI.Variant
private RectTransform m_ContentPlaneWhenNoWindow;
[Content, SerializeField, OnlyPlayMode] private List<ItemEntry> m_Entrys = new();
[Resources, SerializeField, HopeNotNull] public WindowUIModule ItemPrefab;
[Setting, Tooltip("RUNTIME MODE")] public PerformanceIndicator.PerformanceMode m_PerformanceMode = PerformanceIndicator.PerformanceMode.Quality;
public RectTransform TargetWindowContent => m_WindowManager == null ? m_ContentPlaneWhenNoWindow : m_WindowManager[m_TargetWindowContent];

View File

@@ -54,7 +54,7 @@ namespace Convention.WindowsUI.Variant
}
[ArgPackage]
public class CallbackData : AnyClass
public class CallbackData
{
public string name;
public Action<Vector3> callback;
@@ -65,7 +65,7 @@ namespace Convention.WindowsUI.Variant
}
}
/// <summary>
/// <EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>root
///
/// </summary>
[return: ReturnNotNull, IsInstantiated(true)]
public CustomMenu OpenCustomMenu([In] RectTransform root, params CallbackData[] actions)

Binary file not shown.

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21cd7907b9c0ce64bb4ef9dac9a93969
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: