Browse Source

解决Unity2021键盘报错

jiajun.hu.x 2 years ago
parent
commit
47cf81d8df

+ 2 - 0
Assets/SDK/Modules/Module_Interaction/SCInputField/Keyboard/Scripts/SCKeyboardBase.cs

@@ -119,6 +119,7 @@ namespace SC.XR.Unity
 
         private void SetKeyboardTransform(Transform parent, Vector3 positon, Quaternion rotation, Vector3 scale)
         {
+            Debug.Log("SetKeyboardTransfor===>");
             if (KeyboardGameObject == null)
             {
                 Debug.LogError("KeyboardGameObject is NULL");
@@ -134,6 +135,7 @@ namespace SC.XR.Unity
 
         public void SetKeyboardTransform(Vector3 positon, Quaternion rotation, Vector3 localScale)
         {
+            Debug.Log("SetKeyboardTransfor===>");
             this.KeyboardGameObject.transform.position = positon;
             this.KeyboardGameObject.transform.rotation = rotation;
             this.KeyboardGameObject.transform.localScale = localScale;

+ 7 - 3
Assets/SDK/Modules/Module_Interaction/SCInputField/Scripts/SCInputField.cs

@@ -7,6 +7,7 @@ using UnityEngine.EventSystems;
 using UnityEngine.Serialization;
 using UnityEngine.UI;
 using UnityEngine;
+using static UnityEngine.UI.InputField;
 #if UNITY_EDITOR
 using UnityEditor;
 #endif
@@ -145,8 +146,9 @@ namespace SC.XR.Unity
         [FormerlySerializedAs("onSubmit")]
         [FormerlySerializedAs("m_OnSubmit")]
         [FormerlySerializedAs("m_EndEdit")]
+        [FormerlySerializedAs("m_OnEndEdit")]
         [SerializeField]
-        protected SubmitEvent m_OnEndEdit = new SubmitEvent();
+        private SubmitEvent m_OnSubmit = new SubmitEvent();
 
         /// <summary>
         /// Event delegates triggered when the input field changes its data.
@@ -156,6 +158,8 @@ namespace SC.XR.Unity
         [SerializeField]
         protected OnChangeEvent m_OnValueChanged = new OnChangeEvent();
 
+        [SerializeField]
+        private EndEditEvent m_OnDidEndEdit = new EndEditEvent();
         /// <summary>
         /// Custom validation callback.
         /// </summary>
@@ -421,8 +425,8 @@ namespace SC.XR.Unity
 
         public Color selectionColor { get { return m_SelectionColor; } set { if (SCSetPropertyUtility.SetColor(ref m_SelectionColor, value)) MarkGeometryAsDirty(); } }
 
-        public SubmitEvent onEndEdit { get { return m_OnEndEdit; } set { SCSetPropertyUtility.SetClass(ref m_OnEndEdit, value); } }
-
+        public EndEditEvent onEndEdit { get { return m_OnDidEndEdit; } set { SCSetPropertyUtility.SetClass(ref m_OnDidEndEdit, value); } }
+        public SubmitEvent onSubmit { get { return m_OnSubmit; } set { SCSetPropertyUtility.SetClass(ref m_OnSubmit, value); } }
         [Obsolete("onValueChange has been renamed to onValueChanged")]
         public OnChangeEvent onValueChange { get { return onValueChanged; } set { onValueChanged = value; } }
 

File diff suppressed because it is too large
+ 105 - 184
Assets/SDK/Modules/Module_Keyboard/Resources/Prefabs/Keyboard/2DKeyboard.prefab


+ 7 - 3
Assets/SDK/Modules/Module_Keyboard/Scripts/Follower/KeyboardFollower.cs

@@ -24,11 +24,15 @@ namespace SC.XR.Unity.Module_Keyboard
         protected override void OnEnable()
         {
             base.OnEnable();
+            Vector3 v3 = Camera.main.transform.position + Camera.main.transform.forward * 0.5f;
+          //  transform.position = new Vector3(v3.x, Camera.main.transform.position.y, v3.z); // Vector3.Lerp(transform.position, CalculateWindowPosition(Camera.main.transform), WindowFollowSpeed * Time.deltaTime);
+            //transform.position = Vector3.SmoothDamp(transform.position, CalculateWindowPosition(Camera.main.transform), ref velocity, WindowFollowSpeed);
+            transform.LookAt(Camera.main.transform);
         }
 
         private void Start()
         {
-            InitTrans();
+          //  InitTrans();
         }
 
         protected override void LateUpdate()
@@ -82,9 +86,9 @@ namespace SC.XR.Unity.Module_Keyboard
         //Nonlinear Following by default
         protected override void Follow()
         {
-            transform.position = Vector3.Lerp(transform.position, CalculateWindowPosition(Camera.main.transform), WindowFollowSpeed * Time.deltaTime);
+            //transform.position = CalculateWindowPosition(Camera.main.transform); // Vector3.Lerp(transform.position, CalculateWindowPosition(Camera.main.transform), WindowFollowSpeed * Time.deltaTime);
             //transform.position = Vector3.SmoothDamp(transform.position, CalculateWindowPosition(Camera.main.transform), ref velocity, WindowFollowSpeed);
-            transform.rotation = Quaternion.Slerp(transform.rotation, CalculateWindowRotation(Camera.main.transform), WindowFollowSpeed * Time.deltaTime);
+           // transform.rotation = CalculateWindowRotation(Camera.main.transform);// Quaternion.Slerp(transform.rotation, CalculateWindowRotation(Camera.main.transform), WindowFollowSpeed * Time.deltaTime);
         }
 
         //For Linear Following, turn down the WindowFollowSpeed to around 0.5 at distance = 1 for best experience

+ 1 - 0
Assets/SDK/Modules/Module_Keyboard/Scripts/InputField/UGUI_SCInputField.cs

@@ -1670,6 +1670,7 @@ namespace SC.XR.Unity
 
 		private SCKeyboard SetKeyboardTransform()
 		{
+			Debug.Log("SetKeyboardTransformSetKeyboardTransformSetKeyboardTransform");
 			SCKeyboard scKeyboard;
 			Vector3 position = Vector3.zero;
 			Quaternion rotation = Quaternion.identity;

+ 5 - 1
Assets/SDK/Modules/Module_Keyboard/Scripts/SCKeyboard.cs

@@ -447,7 +447,11 @@ namespace SC.XR.Unity.Module_Keyboard
             SCKeyboardMono keyboardMono = keyboardMonoDic[sckeyboardEnum];
 
             keyboardMono.transform.SetParent(null);
-            keyboardMono.transform.localPosition = positon;
+            Vector3 v3 = Camera.main.transform.position + Camera.main.transform.forward * 0.5f;
+          //  keyboardMono.transform.LookAt(Camera.main.transform);
+            keyboardMono.transform.position = new Vector3(v3.x, Camera.main.transform.position.y-0.03f, v3.z);
+
+            //keyboardMono.transform.localPosition = positon;
             keyboardMono.transform.localRotation = rotation;
             keyboardMono.transform.localScale = localScale;
         }

+ 1 - 1
Assets/StreamingAssets/build_info

@@ -1 +1 @@
-Build from HJJ at 2023/2/25 11:27:54
+Build from HJJ at 2023/2/27 9:09:17

File diff suppressed because it is too large
+ 132 - 0
Assets/Studio/Resources/_1LoginSencePrefab/LoginDlg.prefab


Some files were not shown because too many files changed in this diff