mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 15:57:52 +08:00
Make InputFieldRef helper, InteractiveString and IOUtility
This commit is contained in:
@ -76,11 +76,11 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
|
||||
if (suggestions.Any() && CurrentHandler != null)
|
||||
{
|
||||
if (!CurrentHandler.InputField.gameObject.activeInHierarchy)
|
||||
if (!CurrentHandler.InputField.UIRoot.activeInHierarchy)
|
||||
ReleaseOwnership(CurrentHandler);
|
||||
else
|
||||
{
|
||||
lastCaretPos = CurrentHandler.InputField.caretPosition;
|
||||
lastCaretPos = CurrentHandler.InputField.InputField.caretPosition;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
@ -142,13 +142,13 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
|
||||
private void UpdatePosition()
|
||||
{
|
||||
if (CurrentHandler == null || !CurrentHandler.InputField.isFocused)
|
||||
if (CurrentHandler == null || !CurrentHandler.InputField.InputField.isFocused)
|
||||
return;
|
||||
|
||||
Vector3 pos;
|
||||
var input = CurrentHandler.InputField;
|
||||
|
||||
var textGen = input.textComponent.cachedTextGenerator;
|
||||
var textGen = input.InputField.textComponent.cachedTextGenerator;
|
||||
int caretPos = 0;
|
||||
if (CurrentHandler.AnchorToCaretPosition)
|
||||
{
|
||||
@ -159,7 +159,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
}
|
||||
|
||||
pos = textGen.characters[caretPos].cursorPos;
|
||||
pos = input.transform.TransformPoint(pos);
|
||||
pos = input.UIRoot.transform.TransformPoint(pos);
|
||||
|
||||
uiRoot.transform.position = new Vector3(pos.x + 10, pos.y - 20, 0);
|
||||
|
||||
|
@ -9,7 +9,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
{
|
||||
public interface ISuggestionProvider
|
||||
{
|
||||
InputField InputField { get; }
|
||||
InputFieldRef InputField { get; }
|
||||
bool AnchorToCaretPosition { get; }
|
||||
|
||||
void OnSuggestionClicked(Suggestion suggestion);
|
||||
|
@ -21,20 +21,20 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
public Type BaseType { get; set; }
|
||||
public Type[] GenericConstraints { get; set; }
|
||||
|
||||
public InputField InputField { get; }
|
||||
public InputFieldRef InputField { get; }
|
||||
public bool AnchorToCaretPosition => false;
|
||||
|
||||
private readonly List<Suggestion> suggestions = new List<Suggestion>();
|
||||
private float timeOfLastCheck;
|
||||
//private float timeOfLastCheck;
|
||||
|
||||
private HashSet<Type> allowedTypes;
|
||||
|
||||
public TypeCompleter(Type baseType, InputField inputField)
|
||||
public TypeCompleter(Type baseType, InputFieldRef inputField)
|
||||
{
|
||||
BaseType = baseType;
|
||||
InputField = inputField;
|
||||
|
||||
inputField.onValueChanged.AddListener(OnInputFieldChanged);
|
||||
inputField.OnValueChanged += OnInputFieldChanged;
|
||||
|
||||
if (BaseType != null)
|
||||
CacheTypes();
|
||||
@ -47,9 +47,9 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
|
||||
public void OnSuggestionClicked(Suggestion suggestion)
|
||||
{
|
||||
timeOfLastCheck = Time.realtimeSinceStartup;
|
||||
//timeOfLastCheck = Time.realtimeSinceStartup;
|
||||
|
||||
InputField.text = suggestion.UnderlyingValue;
|
||||
InputField.Text = suggestion.UnderlyingValue;
|
||||
SuggestionClicked?.Invoke(suggestion);
|
||||
|
||||
suggestions.Clear();
|
||||
@ -58,10 +58,10 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
|
||||
private void OnInputFieldChanged(string value)
|
||||
{
|
||||
if (!timeOfLastCheck.OccuredEarlierThanDefault())
|
||||
return;
|
||||
|
||||
timeOfLastCheck = Time.realtimeSinceStartup;
|
||||
//if (!timeOfLastCheck.OccuredEarlierThanDefault())
|
||||
// return;
|
||||
//
|
||||
//timeOfLastCheck = Time.realtimeSinceStartup;
|
||||
|
||||
value = value ?? "";
|
||||
|
||||
|
Reference in New Issue
Block a user