BS 0.2.0 Visual

This commit is contained in:
2025-07-21 15:58:52 +08:00
parent f6750189d0
commit d0e5420f95
142 changed files with 11176 additions and 11 deletions

View File

@@ -0,0 +1,70 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Convention.WindowsUI.Variant
{
public class InspectorReference : InspectorDrawer
{
[Resources] public ModernUIInputField TextArea;
[Resources] public Button RawButton;
public IAnyClass lastReference;
[Content] public bool isEditing = false;
private void OnCallback(string str)
{
if (str == null || str.Length == 0)
{
targetItem.SetValue(null);
if (targetItem.target is IInspectorUpdater updater)
{
updater.OnInspectorUpdate();
}
}
else if (int.TryParse(str, out var code) && HierarchyWindow.instance.ContainsReference(code))
{
targetItem.SetValue(HierarchyWindow.instance.GetReference(code));
if (targetItem.target is IInspectorUpdater updater)
{
updater.OnInspectorUpdate();
}
}
}
private void Start()
{
RawButton.onClick.AddListener(() => InspectorWindow.instance.SetTarget(targetItem.GetValue(), null));
TextArea.AddListener(OnCallback);
TextArea.InputFieldSource.Source.onEndEdit.AddListener(x => isEditing = false);
TextArea.InputFieldSource.Source.onSelect.AddListener(x => isEditing = true);
}
private void OnEnable()
{
TextArea.interactable = targetItem.AbleChangeType;
TextArea.text = targetItem.GetValue().GetHashCode().ToString();
}
private void FixedUpdate()
{
if (targetItem.UpdateType && !isEditing)
{
object value = targetItem.GetValue();
if (value != null)
{
TextArea.text = value.GetHashCode().ToString();
}
else
{
TextArea.text = "";
}
}
}
private void Reset()
{
TextArea = GetComponent<ModernUIInputField>();
}
}
}