lvjincheng 3 gadi atpakaļ
vecāks
revīzija
e92068f6a2

+ 5 - 8
Assets/BowArrow/Modules/NewUserGuider/NewUserGuiderManager.cs

@@ -97,7 +97,7 @@ public class NewUserGuiderManager : MonoBehaviour
         config.key = "连接设备";
         config.frameTipPivot = "lb";
         config.onPrepare = (g) => {
-            RectTransform btn = GameObject.Find("HomeView/HomeViewRenderBow/Btn").GetComponent<RectTransform>();
+            RectTransform btn = GameObject.Find("HomeView/RenderBow/BtnConnectBLE").GetComponent<RectTransform>();
             g.hollowOutMask.SetTarget(btn);
             // g.hollowOutMask.isTargetRectCanThrough = false;
             
@@ -131,7 +131,7 @@ public class NewUserGuiderManager : MonoBehaviour
         config.key = "弓箭详情";
         config.frameTipPivot = "lt";
         config.onPrepare = (g) => {
-            RectTransform btn = GameObject.Find("HomeView/HomeViewRenderBow/BtnShowDetail").GetComponent<RectTransform>();
+            RectTransform btn = GameObject.Find("HomeView/RenderBow/BtnShowDetail").GetComponent<RectTransform>();
             g.hollowOutMask.SetTarget(btn);
             g.hollowOutMask.isTargetRectCanThrough = false;
             g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
@@ -141,12 +141,9 @@ public class NewUserGuiderManager : MonoBehaviour
         config.onStart = (g) => {
             g.GetMaskClickedEvent().RemoveAllListeners();
             g.GetNewUserGuiderButton().onClick += () => {
-                HomeViewRenderBow homeViewRenderBow = FindObjectOfType<HomeViewRenderBow>();
-                if (homeViewRenderBow) {
-                    homeViewRenderBow.OnClick_ShowDeviceView();
-                    g.clickedWillPlayAudioBtn = false;
-                    g.OnClick_ToNext();      
-                }
+                HomeView.ins.OnClick_ShowDeviceView();
+                g.clickedWillPlayAudioBtn = false;
+                g.OnClick_ToNext(); 
             };
         };
 

+ 18 - 21
Assets/BowArrow/Prefabs/Views/HomeView.prefab

@@ -1024,9 +1024,8 @@ GameObject:
   - component: {fileID: 8493734455800086512}
   - component: {fileID: 9005640840167746109}
   - component: {fileID: 6869505596738821332}
-  - component: {fileID: 1174873602034629604}
   m_Layer: 5
-  m_Name: HomeViewRenderBow
+  m_Name: RenderBow
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
@@ -1088,20 +1087,6 @@ MonoBehaviour:
     y: 0
     width: 1
     height: 1
---- !u!114 &1174873602034629604
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1249308475108434720}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 47523cfe53036fd45b245694d80d85ac, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  prefabRenderBowCamera: {fileID: 8783645853738562994, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
-  btnConnectBow: {fileID: 2317149572522622741}
 --- !u!1 &1360928897231276735
 GameObject:
   m_ObjectHideFlags: 0
@@ -1710,7 +1695,7 @@ GameObject:
   - component: {fileID: 4905715268193029435}
   - component: {fileID: 2464300839892354699}
   m_Layer: 5
-  m_Name: Btn
+  m_Name: BtnConnectBLE
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
@@ -1818,7 +1803,19 @@ MonoBehaviour:
   m_TargetGraphic: {fileID: 6979449892935850950}
   m_OnClick:
     m_PersistentCalls:
-      m_Calls: []
+      m_Calls:
+      - m_Target: {fileID: 7022781866214807771}
+        m_TargetAssemblyTypeName: HomeView, Assembly-CSharp
+        m_MethodName: OnClick_ConnectBLE
+        m_Mode: 1
+        m_Arguments:
+          m_ObjectArgument: {fileID: 0}
+          m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
+          m_IntArgument: 0
+          m_FloatArgument: 0
+          m_StringArgument: 
+          m_BoolArgument: 0
+        m_CallState: 2
 --- !u!114 &4905715268193029435
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -2267,7 +2264,7 @@ RectTransform:
   m_GameObject: {fileID: 3572727387850533746}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 0, y: 0, z: 0}
-  m_LocalScale: {x: 1.0622933, y: 1.0622933, z: 1.0622933}
+  m_LocalScale: {x: 1.126209, y: 1.126209, z: 1.126209}
   m_Children: []
   m_Father: {fileID: 7022781866214807768}
   m_RootOrder: 0
@@ -5996,8 +5993,8 @@ MonoBehaviour:
   m_OnClick:
     m_PersistentCalls:
       m_Calls:
-      - m_Target: {fileID: 1174873602034629604}
-        m_TargetAssemblyTypeName: HomeViewRenderBow, Assembly-CSharp
+      - m_Target: {fileID: 7022781866214807771}
+        m_TargetAssemblyTypeName: HomeView, Assembly-CSharp
         m_MethodName: OnClick_ShowDeviceView
         m_Mode: 1
         m_Arguments:

+ 0 - 44
Assets/BowArrow/Prefabs/Views/HomeView/HomeViewRenderBow.cs

@@ -1,44 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-using UnityEngine.EventSystems;
-
-public class HomeViewRenderBow : MonoBehaviour
-{
-    [SerializeField] GameObject prefabRenderBowCamera;
-    [SerializeField] GameObject btnConnectBow;
-    GameObject renderBowCamera;
-    Transform sphere;
-
-    void Start()
-    {
-        renderBowCamera = Instantiate(prefabRenderBowCamera);
-        sphere = renderBowCamera.transform.Find("Sphere");
-        btnConnectBow.GetComponent<Button>().onClick.AddListener(delegate() {
-            BluetoothAim.ins.DoConnect();
-        });
-    }
-
-    void Update()
-    {
-        sphere.Rotate(Vector3.up, Time.deltaTime * 60);
-        UpdateBtnForConnect();
-    }
-
-    BluetoothStatusEnum bowStatus;
-    void UpdateBtnForConnect() {
-        if (BluetoothAim.ins && bowStatus != BluetoothAim.ins.status) {
-            bowStatus = BluetoothAim.ins.status;
-            (int textID, Color color) = BluetoothStatus.GetStatusInfo(BluetoothAim.ins.status);
-            btnConnectBow.GetComponentInChildren<TextAutoLanguage>().SetText(textID);
-            btnConnectBow.GetComponentInChildren<Text>().color = color;
-            btnConnectBow.transform.Find("Check").gameObject.SetActive(bowStatus == BluetoothStatusEnum.ConnectSuccess);
-        }
-    }
-
-    public void OnClick_ShowDeviceView() {
-        AudioMgr.ins.PlayBtn();
-        GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/DeviceView 1"));
-    }
-}

+ 18 - 0
Assets/BowArrow/Prefabs/Views/HomeView/RenderBowCamera.cs

@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class RenderBowCamera : MonoBehaviour
+{
+    Transform sphere;
+
+    void Start()
+    {
+        sphere = transform.Find("Sphere");
+    }
+
+    void Update()
+    {
+        sphere.Rotate(Vector3.up, Time.deltaTime * 60);
+    }
+}

+ 1 - 1
Assets/BowArrow/Prefabs/Views/HomeView/HomeViewRenderBow.cs.meta → Assets/BowArrow/Prefabs/Views/HomeView/RenderBowCamera.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 47523cfe53036fd45b245694d80d85ac
+guid: c6ae6b64edbc7734b98c59a9ded37b95
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 13 - 0
Assets/BowArrow/Prefabs/Views/HomeView/RenderBowCamera.prefab

@@ -98,6 +98,7 @@ GameObject:
   m_Component:
   - component: {fileID: 355428189500007062}
   - component: {fileID: 8450466684948163410}
+  - component: {fileID: 4739788448203922185}
   m_Layer: 0
   m_Name: RenderBowCamera
   m_TagString: Untagged
@@ -168,6 +169,18 @@ Camera:
   m_OcclusionCulling: 1
   m_StereoConvergence: 10
   m_StereoSeparation: 0.022
+--- !u!114 &4739788448203922185
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8783645853738562994}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: c6ae6b64edbc7734b98c59a9ded37b95, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1001 &6918822814178881757
 PrefabInstance:
   m_ObjectHideFlags: 0

+ 106 - 9
Assets/BowArrow/Scenes/Home.unity

@@ -287,7 +287,7 @@ PrefabInstance:
     m_Modifications:
     - target: {fileID: 7321084171293611996, guid: f8335429fb1a20743a0d2f92478e0b8e, type: 3}
       propertyPath: m_RootOrder
-      value: 10
+      value: 11
       objectReference: {fileID: 0}
     - target: {fileID: 7321084171293611996, guid: f8335429fb1a20743a0d2f92478e0b8e, type: 3}
       propertyPath: m_LocalPosition.x
@@ -335,6 +335,103 @@ PrefabInstance:
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: f8335429fb1a20743a0d2f92478e0b8e, type: 3}
+--- !u!1001 &1018166869
+PrefabInstance:
+  m_ObjectHideFlags: 0
+  serializedVersion: 2
+  m_Modification:
+    m_TransformParent: {fileID: 0}
+    m_Modifications:
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_Pivot.x
+      value: 0.5
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_Pivot.y
+      value: 0.5
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_RootOrder
+      value: 7
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_AnchorMax.x
+      value: 0.5
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_AnchorMax.y
+      value: 0.5
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_AnchorMin.x
+      value: 0.5
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_AnchorMin.y
+      value: 0.5
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_SizeDelta.x
+      value: 100
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_SizeDelta.y
+      value: 100
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalPosition.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalPosition.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalPosition.z
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalRotation.w
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalRotation.x
+      value: -0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalRotation.y
+      value: -0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalRotation.z
+      value: -0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: -1000
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 355428189500007062, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.z
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8783645853738562994, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
+      propertyPath: m_Name
+      value: RenderBowCamera
+      objectReference: {fileID: 0}
+    m_RemovedComponents: []
+  m_SourcePrefab: {fileID: 100100000, guid: 5b9185d051f03ab4cad6e95796ec1649, type: 3}
 --- !u!1 &1120650594
 GameObject:
   m_ObjectHideFlags: 0
@@ -476,7 +573,7 @@ RectTransform:
   m_Children:
   - {fileID: 1374792867}
   m_Father: {fileID: 0}
-  m_RootOrder: 7
+  m_RootOrder: 8
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
@@ -587,7 +684,7 @@ Transform:
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children: []
   m_Father: {fileID: 0}
-  m_RootOrder: 9
+  m_RootOrder: 10
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!114 &1420232143
 MonoBehaviour:
@@ -615,7 +712,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 8896251417503616548, guid: 13268d381a624684a9c989604be1571f, type: 3}
       propertyPath: m_RootOrder
-      value: 8
+      value: 9
       objectReference: {fileID: 0}
     - target: {fileID: 8896251417503616548, guid: 13268d381a624684a9c989604be1571f, type: 3}
       propertyPath: m_LocalPosition.x
@@ -1105,7 +1202,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 2724066502166853830, guid: 380a45198d4735c459d08a00b0d49290, type: 3}
       propertyPath: m_AnchoredPosition.x
-      value: 95.165054
+      value: 95.53465
       objectReference: {fileID: 0}
     - target: {fileID: 2724066502166853830, guid: 380a45198d4735c459d08a00b0d49290, type: 3}
       propertyPath: m_AnchoredPosition.y
@@ -1225,7 +1322,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 2724066503641769175, guid: 380a45198d4735c459d08a00b0d49290, type: 3}
       propertyPath: m_AnchoredPosition.x
-      value: 8.38835
+      value: 8.511553
       objectReference: {fileID: 0}
     - target: {fileID: 2724066503641769175, guid: 380a45198d4735c459d08a00b0d49290, type: 3}
       propertyPath: m_AnchoredPosition.y
@@ -1386,15 +1483,15 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 4899621318518057717, guid: 80bcbb10e0e3f2e42af22ac5a4ca7f7f, type: 3}
       propertyPath: m_LocalScale.x
-      value: 1.1397451
+      value: 1.2954729
       objectReference: {fileID: 0}
     - target: {fileID: 4899621318518057717, guid: 80bcbb10e0e3f2e42af22ac5a4ca7f7f, type: 3}
       propertyPath: m_LocalScale.y
-      value: 1.1397451
+      value: 1.2954729
       objectReference: {fileID: 0}
     - target: {fileID: 4899621318518057717, guid: 80bcbb10e0e3f2e42af22ac5a4ca7f7f, type: 3}
       propertyPath: m_LocalScale.z
-      value: 1.1397451
+      value: 1.2954729
       objectReference: {fileID: 0}
     - target: {fileID: 5583935121717812721, guid: 80bcbb10e0e3f2e42af22ac5a4ca7f7f, type: 3}
       propertyPath: m_AnchorMax.y

+ 21 - 0
Assets/BowArrow/Scripts/View/HomeView.cs

@@ -59,6 +59,27 @@ public class HomeView : MonoBehaviour
                 friendTip.SetActive(false);
             }
         }
+        UpdateBtnForConnect();
+    }
+
+    BluetoothStatusEnum bowStatus;
+    void UpdateBtnForConnect() {
+        if (BluetoothAim.ins && bowStatus != BluetoothAim.ins.status) {
+            bowStatus = BluetoothAim.ins.status;
+            (int textID, Color color) = BluetoothStatus.GetStatusInfo(BluetoothAim.ins.status);
+            btnConnectBow.GetComponentInChildren<TextAutoLanguage>().SetText(textID);
+            btnConnectBow.GetComponentInChildren<Text>().color = color;
+            btnConnectBow.transform.Find("Check").gameObject.SetActive(bowStatus == BluetoothStatusEnum.ConnectSuccess);
+        }
+    }
+
+    public void OnClick_ConnectBLE() {
+        BluetoothAim.ins.DoConnect();
+    }
+
+    public void OnClick_ShowDeviceView() {
+        AudioMgr.ins.PlayBtn();
+        GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/DeviceView 1"));
     }
 
     public void RenderNameOrGender() {

+ 9 - 1
Assets/Test9Axis/BleUDP.cs

@@ -36,6 +36,13 @@ public class BleUDP : MonoBehaviour
         }
         ins = this;
         DontDestroyOnLoad(this.gameObject);
+    }
+
+    bool _inited;
+    void Init() 
+    {
+        if (_inited) return;
+        _inited = true;
 
         client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
         client.Bind(new IPEndPoint(IPAddress.Parse(localIP), myPort));
@@ -59,7 +66,7 @@ public class BleUDP : MonoBehaviour
     void OnDestroy()
     {
         if (ins == this) ins = null;
-        client.Close();
+        if (client != null) client.Close();
     }
 
     void Update()
@@ -142,6 +149,7 @@ public class BleUDP : MonoBehaviour
 
     public void Connect()
     {
+        Init();
         noneMsgTime = 0;
         bluetoothStatusEnum = BluetoothStatusEnum.Connecting;
         SendMsg("M");