lvjincheng 3 лет назад
Родитель
Сommit
15b04d1bab

+ 375 - 0
Assets/BowArrow/Resources/Prefabs/Views/SideTipView.prefab

@@ -0,0 +1,375 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &731398981958409830
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 5811282618674645403}
+  - component: {fileID: 3892568716558783383}
+  - component: {fileID: 4613134402855051526}
+  - component: {fileID: 6386542590749911630}
+  - component: {fileID: 5281390128327166824}
+  m_Layer: 5
+  m_Name: SideTipView
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &5811282618674645403
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 731398981958409830}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 0, y: 0, z: 0}
+  m_Children:
+  - {fileID: 8745548552644612890}
+  m_Father: {fileID: 0}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
+  m_Pivot: {x: 0, y: 0}
+--- !u!223 &3892568716558783383
+Canvas:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 731398981958409830}
+  m_Enabled: 1
+  serializedVersion: 3
+  m_RenderMode: 0
+  m_Camera: {fileID: 0}
+  m_PlaneDistance: 100
+  m_PixelPerfect: 0
+  m_ReceivesEvents: 1
+  m_OverrideSorting: 0
+  m_OverridePixelPerfect: 0
+  m_SortingBucketNormalizedSize: 0
+  m_AdditionalShaderChannelsFlag: 0
+  m_SortingLayerID: 0
+  m_SortingOrder: 200
+  m_TargetDisplay: 0
+--- !u!114 &4613134402855051526
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 731398981958409830}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_UiScaleMode: 1
+  m_ReferencePixelsPerUnit: 100
+  m_ScaleFactor: 1
+  m_ReferenceResolution: {x: 1280, y: 720}
+  m_ScreenMatchMode: 1
+  m_MatchWidthOrHeight: 0
+  m_PhysicalUnit: 3
+  m_FallbackScreenDPI: 96
+  m_DefaultSpriteDPI: 96
+  m_DynamicPixelsPerUnit: 1
+  m_PresetInfoIsWorld: 0
+--- !u!114 &6386542590749911630
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 731398981958409830}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_IgnoreReversedGraphics: 1
+  m_BlockingObjects: 0
+  m_BlockingMask:
+    serializedVersion: 2
+    m_Bits: 4294967295
+--- !u!114 &5281390128327166824
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 731398981958409830}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 115bb43ab0b8d6144aae3744dbb49548, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+--- !u!1 &2536229824174030564
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 8745548552644612890}
+  - component: {fileID: 3327669233003841910}
+  - component: {fileID: 7571701047568126791}
+  m_Layer: 5
+  m_Name: Container
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &8745548552644612890
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2536229824174030564}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children:
+  - {fileID: 8168598513995770684}
+  m_Father: {fileID: 5811282618674645403}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 25, y: 75}
+  m_SizeDelta: {x: 0, y: 0}
+  m_Pivot: {x: 0, y: 0}
+--- !u!114 &3327669233003841910
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2536229824174030564}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Padding:
+    m_Left: 0
+    m_Right: 0
+    m_Top: 0
+    m_Bottom: 0
+  m_ChildAlignment: 6
+  m_Spacing: 5
+  m_ChildForceExpandWidth: 0
+  m_ChildForceExpandHeight: 0
+  m_ChildControlWidth: 1
+  m_ChildControlHeight: 1
+  m_ChildScaleWidth: 0
+  m_ChildScaleHeight: 0
+  m_ReverseArrangement: 1
+--- !u!114 &7571701047568126791
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2536229824174030564}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_HorizontalFit: 2
+  m_VerticalFit: 2
+--- !u!1 &8168598513781563394
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 8168598513781563395}
+  - component: {fileID: 8168598513781563397}
+  - component: {fileID: 8168598513781563396}
+  m_Layer: 5
+  m_Name: Text
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &8168598513781563395
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513781563394}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 8168598513995770684}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &8168598513781563397
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513781563394}
+  m_CullTransparentMesh: 1
+--- !u!114 &8168598513781563396
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513781563394}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_RaycastTarget: 1
+  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_FontData:
+    m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
+    m_FontSize: 20
+    m_FontStyle: 0
+    m_BestFit: 0
+    m_MinSize: 1
+    m_MaxSize: 200
+    m_Alignment: 4
+    m_AlignByGeometry: 0
+    m_RichText: 1
+    m_HorizontalOverflow: 0
+    m_VerticalOverflow: 0
+    m_LineSpacing: 1
+  m_Text: SideTip
+--- !u!1 &8168598513995770683
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 8168598513995770684}
+  - component: {fileID: 8168598513995770816}
+  - component: {fileID: 8168598513995770687}
+  - component: {fileID: 8168598513995770685}
+  m_Layer: 5
+  m_Name: SideTip
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!224 &8168598513995770684
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513995770683}
+  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children:
+  - {fileID: 8168598513781563395}
+  m_Father: {fileID: 8745548552644612890}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, y: 0}
+  m_SizeDelta: {x: 0, y: 0}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &8168598513995770816
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513995770683}
+  m_CullTransparentMesh: 1
+--- !u!114 &8168598513995770687
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513995770683}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 0, g: 0, b: 0, a: 0.60784316}
+  m_RaycastTarget: 1
+  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_Sprite: {fileID: 0}
+  m_Type: 0
+  m_PreserveAspect: 0
+  m_FillCenter: 1
+  m_FillMethod: 4
+  m_FillAmount: 1
+  m_FillClockwise: 1
+  m_FillOrigin: 0
+  m_UseSpriteMesh: 0
+  m_PixelsPerUnitMultiplier: 1
+--- !u!114 &8168598513995770685
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513995770683}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Padding:
+    m_Left: 5
+    m_Right: 5
+    m_Top: 5
+    m_Bottom: 5
+  m_ChildAlignment: 4
+  m_Spacing: 0
+  m_ChildForceExpandWidth: 0
+  m_ChildForceExpandHeight: 0
+  m_ChildControlWidth: 1
+  m_ChildControlHeight: 1
+  m_ChildScaleWidth: 0
+  m_ChildScaleHeight: 0
+  m_ReverseArrangement: 0

+ 7 - 0
Assets/BowArrow/Resources/Prefabs/Views/SideTipView.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ccbd3ac80187e0a4c8c69cf004e4892f
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 6 - 0
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -102,6 +102,7 @@ public class BluetoothAim : MonoBehaviour
 
     void OnDisconnect()
     {
+        curMac = null;
         hasData = false;
         canConnect = true;
         SetStatus(BluetoothStatusEnum.ConnectFail);
@@ -548,12 +549,17 @@ public class BluetoothAim : MonoBehaviour
         Debug.Log(string.Format("[{0}]{1}", typeof(BluetoothAim).Name, text));
     }
 
+    [NonSerialized] public string curMac;
     void UploadMacAddress(byte[] bytes) {
         string mac = System.Text.Encoding.ASCII.GetString(bytes);
         if (mac != null) mac = mac.Trim();
         if (CheckIsMacValid(mac)) {
+            curMac = mac;
+            SideTipView.ShowTip("Mac获取成功:" + mac, Color.white);
             LoginMgr.myUserInfo.mac = mac;
             UserComp.Instance.saveMac();
+        } else {
+            SideTipView.ShowTip("Mac获取失败:" + mac, Color.yellow);
         }
     }
 

+ 8 - 0
Assets/BowArrow/Scripts/Bluetooth/New/Axis9Handler.cs

@@ -104,11 +104,14 @@ public class Axis9Handler : AxisBaseHandler
     {
         try
         {
+            SideTipView.ShowTip("开始序列化九轴数据", Color.white);
             string record = attitudeJson.Stringify(_9Axis.Attitude);
             if (!string.IsNullOrEmpty(record))
             {
+                SideTipView.ShowTip($"九轴数据序列化完成(长度{record.Length})", Color.white);
                 Debug.Log("9轴数据序列化成功");
                 UserComp.Instance.saveCalibrateRecord(record);
+                SideTipView.ShowTip("正在上传九轴数据", Color.white);
             }
         }
         catch (Exception e)
@@ -122,13 +125,18 @@ public class Axis9Handler : AxisBaseHandler
     {
         try
         {
+            SideTipView.ShowTip($"成功加载服务端的九轴数据(长度{record.Length})", Color.white);
             _9Axis.Attitude = attitudeJson.Parse<o0.IMU._9AxisPreProcessor>(record);
             Debug.Log("9轴反序列化完成");
+            SideTipView.ShowTip("九轴数据恢复成功", Color.white);
+            SideTipView.ShowTip($"GyrMeanLen:{_9Axis.Attitude.GyrCalibrater.Mean.Length}", Color.white);
+            SideTipView.ShowTip($"MagVariance:{_9Axis.Attitude.MagCalibrater.Variance}", Color.white);
             PrintAxisInfo();
             if (!IsAxisRight())
             {
                 _9Axis.Attitude = new o0.IMU._9AxisPreProcessor(GyrByteIndex, AccByteIndex, MagByteIndex);
                 Debug.Log("跟保存的轴向不相同,重置校准记录!");
+                SideTipView.ShowTip("跟保存的轴向不相同,重置校准记录!", Color.yellow);
                 PrintAxisInfo();
             }
             Debug.Log("9轴数据恢复结果: " + _9Axis.Attitude.MagCalibrater.Complete);

+ 5 - 2
Assets/BowArrow/Scripts/Network/SocketComp/UserComp.cs

@@ -30,8 +30,11 @@ public class UserComp : JCUnityLib.Singleton<UserComp>
     } 
 
     public void saveCalibrateRecord(string record) {
-        string mac = LoginMgr.myUserInfo.mac;
-        if (string.IsNullOrEmpty(mac)) return;
+        string mac = BluetoothAim.ins.curMac;
+        if (string.IsNullOrEmpty(mac)) {
+            SideTipView.ShowTip("没有Mac无法上传九轴数据", UnityEngine.Color.yellow);
+            throw new Exception("没有Mac无法上传九轴数据");
+        }
         int type = AimHandler.ins.DeviceType;
         if (type > 0) {
             UserPlayer.ins.call("userComp.saveCalibrateRecord", type, record, mac);

+ 5 - 0
Assets/BowArrow/Scripts/Network/UserPlayer.cs

@@ -154,6 +154,11 @@ public class UserPlayer : JCEntity
         ins?.Close();
     }
 
+    public void onAnyMessage(string msg)
+    {
+        SideTipView.ShowTip(msg, msg.EndsWith("失败") ? Color.yellow : Color.white);
+    }
+
     public void onRequestAddFriend() {
         PopupMgr.ins.ShowTipTop(TextAutoLanguage2.GetTextByKey("tip_friend-receive-request"));
         tempData.hasFriendRequest = true;

+ 48 - 0
Assets/BowArrow/Scripts/View/SideTipView.cs

@@ -0,0 +1,48 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using JCUnityLib;
+
+public class SideTipView : ViewBase
+{
+    Transform container;
+    GameObject sideTipPrefab;
+    static SideTipView ins;
+
+    void Awake()
+    {
+        ins = this;
+        container = transform.Find("Container");
+        sideTipPrefab = container.Find("SideTip").gameObject;
+        sideTipPrefab.SetActive(false);
+    }
+
+    void OnDestroy()
+    {
+        if (ins == this) ins = null;
+    }
+
+    void _ShowTip(string text, Color color)
+    {
+        var o = Instantiate(sideTipPrefab);
+        var t = o.GetComponentInChildren<Text>();
+        t.text = text;
+        t.color = color;
+        o.transform.SetParent(container);
+        o.SetActive(true);
+        StartCoroutine(AutoDestroy(o));
+    }
+
+    IEnumerator AutoDestroy(GameObject o)
+    {
+        yield return new WaitForSeconds(5.0f);
+        Destroy(o);
+    }
+
+    public static void ShowTip(string text, Color color)
+    {
+        if (!ins) Instantiate(Resources.Load("Prefabs/Views/SideTipView"));
+        ins?._ShowTip(text, color);
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/View/SideTipView.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 115bb43ab0b8d6144aae3744dbb49548
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: