mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-11 01:48:07 +08:00
Make InputFieldRef helper, InteractiveString and IOUtility
This commit is contained in:
1 parent
4931117b1e
commit
d8f532d913
20 files changed
+405
-206
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user