diff options
author | chai <chaifix@163.com> | 2021-07-15 16:09:27 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-07-15 16:09:27 +0800 |
commit | ac839e2315f362cc1085ff647cedbca90df2e16f (patch) | |
tree | b5e7363aaed63c8235d2dc875481ad7c5e39f090 | |
parent | 6cb66f51a668b1d75a7b9f05a9773e6f0165373e (diff) |
+misc
-rw-r--r-- | Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs | 2 | ||||
-rw-r--r-- | Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/InputField.cs | 24 |
2 files changed, 15 insertions, 11 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs index 200b4e5..6690060 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs @@ -185,7 +185,7 @@ namespace UnityEngine.UI // 到了这里布局和网格、材质都设置完毕,后面canvas会渲染 - // profiler不用管 + // profiler UISystemProfilerApi.EndSample(UISystemProfilerApi.SampleType.Layout); } diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/InputField.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/InputField.cs index ef6afa4..ed39020 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/InputField.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/UIControls/InputField.cs @@ -563,6 +563,7 @@ namespace UnityEngine.UI if (m_CachedInputRenderer != null) m_CachedInputRenderer.SetMaterial(m_TextComponent.GetModifiedMaterial(Graphic.defaultGraphicMaterial), Texture2D.whiteTexture); + //c 向Text组件注册事件监听,主要当Graphic进行顶点与材质的重建标记时会执行相应的监听事件 if (m_TextComponent != null) { m_TextComponent.RegisterDirtyVerticesCallback(MarkGeometryAsDirty); @@ -787,10 +788,11 @@ namespace UnityEngine.UI return; } + //获取输入信息 string val = m_Keyboard.text; - if (m_Text != val) { + //只读情况则无法改变输入内容 if (m_ReadOnly) { m_Keyboard.text = m_Text; @@ -805,12 +807,12 @@ namespace UnityEngine.UI if (c == '\r' || (int)c == 3) c = '\n'; - + //验证输入内容 if (onValidateInput != null) c = onValidateInput(m_Text, m_Text.Length, c); else if (characterValidation != CharacterValidation.None) - c = Validate(m_Text, m_Text.Length, c); - + c = Validate(m_Text, m_Text.Length, c);
+ //限制行时当存在换行情况则停止更新
if (lineType == LineType.MultiLineSubmit && c == '\n') { m_Keyboard.text = m_Text; @@ -821,8 +823,8 @@ namespace UnityEngine.UI if (c != 0) m_Text += c; - } - + }
+ //字数限制的情况进行切割
if (characterLimit > 0 && m_Text.Length > characterLimit) m_Text = m_Text.Substring(0, characterLimit); @@ -839,16 +841,16 @@ namespace UnityEngine.UI // and update label will take the old value from keyboard if we don't change it here if (m_Text != val) m_Keyboard.text = m_Text; - + //执行事件并更新文本显示 SendOnValueChangedAndUpdateLabel(); } } else if (m_Keyboard.canGetSelection) { UpdateCaretFromKeyboard(); - } - - + }
+
+ //当键盘输入完毕时,执行Deselect,会关闭键盘并执行编辑完成的事件
if (m_Keyboard.done) { if (m_Keyboard.wasCanceled) @@ -1629,6 +1631,7 @@ namespace UnityEngine.UI Insert(input); } + // 更新显示(不涉及值),比如输入类型为密码类型时,显示为* /// <summary> /// Update the visual text Text. /// </summary> @@ -2219,6 +2222,7 @@ namespace UnityEngine.UI { if (m_Keyboard != null && !m_Keyboard.active) { + //激活键盘接口,并将当前输入框设置进键盘接口中 m_Keyboard.active = true; m_Keyboard.text = m_Text; } |