Make InputFieldRef helper, InteractiveString and IOUtility

This commit is contained in:
Sinai committed 2021-05-07 17:06:56 +10:00
1 parent 4931117b1e
commit d8f532d913
20 files changed
+405 -206

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.Models;
namespace UnityExplorer.UI
{
public class InputFieldRef : UIBehaviourModel
{
public InputFieldRef(InputField InputField)
{
this.InputField = InputField;
Rect = InputField.GetComponent<RectTransform>();
PlaceholderText = InputField.placeholder.TryCast<Text>();
InputField.onValueChanged.AddListener(OnInputChanged);
}
public event Action<string> OnValueChanged;
public InputField InputField;
public Text PlaceholderText;
private readonly RectTransform Rect;
public string Text
{
get => InputField.text;
set => InputField.text = value;
}
private bool updatedWanted;
private void OnInputChanged(string value)
{
updatedWanted = true;
}
public override void Update()
{
if (updatedWanted)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(Rect);
OnValueChanged?.Invoke(InputField.text);
updatedWanted = false;
}
}
public override GameObject UIRoot => InputField.gameObject;
public override void ConstructUI(GameObject parent)
{
throw new NotImplementedException();
}
}
}