Browse Source

修改设置按钮位置,修改SceneChoose脚本

蓝色星空 2 years ago
parent
commit
e543c0c343
2 changed files with 294 additions and 294 deletions
  1. 6 6
      Assets/Scenes/NavigatorPro.unity
  2. 288 288
      Assets/Scripts/UI/SceneChoose.cs

+ 6 - 6
Assets/Scenes/NavigatorPro.unity

@@ -1621,7 +1621,7 @@ PrefabInstance:
     - target: {fileID: 2530963273550262053, guid: 7e724082e3f166747b1152780155e212,
         type: 3}
       propertyPath: m_Text
-      value: "\u8BBE\u7F6E\u9762\u677F"
+      value: "\u951A\u70B9\u9762\u677F"
       objectReference: {fileID: 0}
     - target: {fileID: 3175354672573086742, guid: 7e724082e3f166747b1152780155e212,
         type: 3}
@@ -1656,7 +1656,7 @@ PrefabInstance:
     - target: {fileID: 5079657590173202044, guid: 7e724082e3f166747b1152780155e212,
         type: 3}
       propertyPath: m_LocalPosition.y
-      value: -0.0615
+      value: 0
       objectReference: {fileID: 0}
     - target: {fileID: 5079657590173202044, guid: 7e724082e3f166747b1152780155e212,
         type: 3}
@@ -3397,7 +3397,7 @@ PrefabInstance:
     - target: {fileID: 2656584712679981451, guid: 3e8996c442fe40541beb734ca45f2bf6,
         type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: -0.0053232186
+      value: -0.0012420515
       objectReference: {fileID: 0}
     - target: {fileID: 2656584712838976906, guid: 3e8996c442fe40541beb734ca45f2bf6,
         type: 3}
@@ -3527,7 +3527,7 @@ PrefabInstance:
     - target: {fileID: 2656584713474595953, guid: 3e8996c442fe40541beb734ca45f2bf6,
         type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: -0.006121242
+      value: -0.0057972968
       objectReference: {fileID: 0}
     - target: {fileID: 2656584713571100915, guid: 3e8996c442fe40541beb734ca45f2bf6,
         type: 3}
@@ -5577,7 +5577,7 @@ PrefabInstance:
     - target: {fileID: 486518953982833418, guid: 6693e68f506a6c944b1783fb7e52a498,
         type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: 0.00027694742
+      value: -0.0014560656
       objectReference: {fileID: 0}
     - target: {fileID: 486518953989235048, guid: 6693e68f506a6c944b1783fb7e52a498,
         type: 3}
@@ -9392,7 +9392,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0, y: -0.0054047313}
+  m_AnchoredPosition: {x: 0, y: -0.0040776283}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0, y: 1}
 --- !u!114 &1180406930876628118

+ 288 - 288
Assets/Scripts/UI/SceneChoose.cs

@@ -1,292 +1,292 @@
-using LitJson;
-using Newtonsoft.Json.Linq;
-using SC.XR.Unity;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using UnityEngine;
-using UnityEngine.UI;
-using Newtonsoft.Json;
-
-public class SceneChoose : BaseUI
-{
-    private Button m_LeftBtn;
-    private Button m_RightBtn;
-    private Button m_OkBtn;
-
-    private GameObject m_SceneItem;
-    private Transform m_ScenePanel;
-    /// <summary>
-    /// 场景选择面板中确认的场景
-    /// </summary>
-    private SceneValue m_CurrentData;
-    private List<SChooseItem> m_Items;
-
-    private CarouselImage m_CarImage;
-
-    private List<SceneValue> m_SceneData;
-
-    protected override void OnAwake()
-    {
-        base.OnAwake();
-        m_SceneData = new List<SceneValue>();
-        m_Items = new List<SChooseItem>();
-        m_CurrentData = null;
-        m_LeftBtn = CacheTransform.Find("Left").GetComponent<Button>();
-        m_RightBtn = CacheTransform.Find("Right").GetComponent<Button>();
-        m_OkBtn = CacheTransform.Find("OK").GetComponent<Button>();
-
-        m_SceneItem = CacheTransform.Find("SceneItem").gameObject;
-        m_ScenePanel = CacheTransform.Find("ScenePanel");
-
-        m_ScenePanel.GetComponent<RectTransform>().sizeDelta = new Vector2(400, 150);
-
-        m_LeftBtn.onClick.AddListener(ONClickLeftBtn);
-        m_RightBtn.onClick.AddListener(ONClickRightBtn);
-        m_OkBtn.onClick.AddListener(OnClickOKBtn);
-    }
-
-    #region UI监听事件
-
-    private void ONClickLeftBtn()
-    {
-        if (m_CarImage != null)
-        {
-            m_CarImage.MoveToIndex(m_CarImage.CurrentIndex + 1);
-        }
-    }
-
-    private void ONClickRightBtn()
-    {
-        if (m_CarImage != null)
-        {
-            m_CarImage.MoveToIndex(m_CarImage.CurrentIndex - 1);
-        }
-    }
-
-    private void OnClickOKBtn()
-    {
-        if (m_CurrentData != null)
-        {
-            //根据场景数据,下载资源
-            Debug.Log("选择的场景为:" + m_CurrentData.name);
-
-            SendSceneDetail detail = new SendSceneDetail();
-            detail.id = m_CurrentData.id;
-            string str = JsonConvert.SerializeObject(detail);
-            HttpTool.Instance.PostTest("/project/detail", str, (mes) =>
-            {
-                JObject jObject = JObject.Parse(mes);
-                if (jObject["code"].ToString() == "200")
-                {
-                    mes = jObject["data"].ToString();
-                    SceneValue scene = JsonConvert.DeserializeObject<SceneValue>(mes);
-                    GameManager.Instance.MapPicUrl = scene.backgroundImages[0].base64;
-                    GameManager.Instance.GetMinMap(scene);
-                    GetSNInit();
-                }
-                else
-                {
-                    UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
-                    Module_Notice.getInstance.SetNoticeInfo("场景地图获取失败", "请至网页端检查场景数据", NoticeType.Normal, 1.7f);
-                    Module_Notice.getInstance._Follower.WindowAnchor = TextAnchor.UpperCenter;
-                    Module_Notice.getInstance.StartNotice(3f);
-                    UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
-                }
-            });
-        }
-        else
-        {
-            Module_Notice.getInstance.SetNoticeInfo("未选择导览场景", "请先勾选要进入的场景", NoticeType.Normal, 1.7f);
-            Module_Notice.getInstance._Follower.WindowAnchor = TextAnchor.UpperCenter;
-            Module_Notice.getInstance.StartNotice(3f);
-        }
-    }
-
-    private void GetSNInit()
-    {
-        // 选择场景
-        SendInit send = new SendInit();
-
+using LitJson;
+using Newtonsoft.Json.Linq;
+using SC.XR.Unity;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine;
+using UnityEngine.UI;
+using Newtonsoft.Json;
+
+public class SceneChoose : BaseUI
+{
+    private Button m_LeftBtn;
+    private Button m_RightBtn;
+    private Button m_OkBtn;
+
+    private GameObject m_SceneItem;
+    private Transform m_ScenePanel;
+    /// <summary>
+    /// 场景选择面板中确认的场景
+    /// </summary>
+    private SceneValue m_CurrentData;
+    private List<SChooseItem> m_Items;
+
+    private CarouselImage m_CarImage;
+
+    private List<SceneValue> m_SceneData;
+
+    protected override void OnAwake()
+    {
+        base.OnAwake();
+        m_SceneData = new List<SceneValue>();
+        m_Items = new List<SChooseItem>();
+        m_CurrentData = null;
+        m_LeftBtn = CacheTransform.Find("Left").GetComponent<Button>();
+        m_RightBtn = CacheTransform.Find("Right").GetComponent<Button>();
+        m_OkBtn = CacheTransform.Find("OK").GetComponent<Button>();
+
+        m_SceneItem = CacheTransform.Find("SceneItem").gameObject;
+        m_ScenePanel = CacheTransform.Find("ScenePanel");
+
+        m_ScenePanel.GetComponent<RectTransform>().sizeDelta = new Vector2(400, 150);
+
+        m_LeftBtn.onClick.AddListener(ONClickLeftBtn);
+        m_RightBtn.onClick.AddListener(ONClickRightBtn);
+        m_OkBtn.onClick.AddListener(OnClickOKBtn);
+    }
+
+    #region UI监听事件
+
+    private void ONClickLeftBtn()
+    {
+        if (m_CarImage != null)
+        {
+            m_CarImage.MoveToIndex(m_CarImage.CurrentIndex + 1);
+        }
+    }
+
+    private void ONClickRightBtn()
+    {
+        if (m_CarImage != null)
+        {
+            m_CarImage.MoveToIndex(m_CarImage.CurrentIndex - 1);
+        }
+    }
+
+    private void OnClickOKBtn()
+    {
+        if (m_CurrentData != null)
+        {
+            //根据场景数据,下载资源
+            Debug.Log("选择的场景为:" + m_CurrentData.name);
+
+            SendSceneDetail detail = new SendSceneDetail();
+            detail.id = m_CurrentData.id;
+            string str = JsonConvert.SerializeObject(detail);
+            HttpTool.Instance.PostTest("/project/detail", str, (mes) =>
+            {
+                JObject jObject = JObject.Parse(mes);
+                if (jObject["code"].ToString() == "200")
+                {
+                    mes = jObject["data"].ToString();
+                    SceneValue scene = JsonConvert.DeserializeObject<SceneValue>(mes);
+                    GameManager.Instance.MapPicUrl = scene.backgroundImages[0].base64;
+                    GameManager.Instance.GetMinMap(scene);
+                    GetSNInit();
+                }
+                else
+                {
+                    UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
+                    Module_Notice.getInstance.SetNoticeInfo("场景地图获取失败", "请至网页端检查场景数据", NoticeType.Normal, 1.7f);
+                    Module_Notice.getInstance._Follower.WindowAnchor = TextAnchor.UpperCenter;
+                    Module_Notice.getInstance.StartNotice(3f);
+                    UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
+                }
+            });
+        }
+        else
+        {
+            Module_Notice.getInstance.SetNoticeInfo("未选择导览场景", "请先勾选要进入的场景", NoticeType.Normal, 1.7f);
+            Module_Notice.getInstance._Follower.WindowAnchor = TextAnchor.UpperCenter;
+            Module_Notice.getInstance.StartNotice(3f);
+        }
+    }
+
+    private void GetSNInit()
+    {
+        // 选择场景
+        SendInit send = new SendInit();
+
         send.sn = SendSN.GetSN();
         //send.sn = API_GSXR_Slam.SlamManager.plugin.SN;
 
-        send.projectId = m_CurrentData.id;
-        string jsonString = JsonConvert.SerializeObject(send);
-        UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.sceneChoose);
-        //通过SN获取场景数据
-        HttpTool.Instance.PostTest("/sn/init", jsonString, (message) =>
+        send.projectId = m_CurrentData.id;
+        string jsonString = JsonConvert.SerializeObject(send);
+        UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.sceneChoose);
+        //通过SN获取场景数据
+        HttpTool.Instance.PostTest("/sn/init", jsonString, (message) =>
+        {
+            Debug.Log("SN:" + send.sn);
+            Debug.Log("通过SN获取场景数据:" + message);
+            if (!string.IsNullOrWhiteSpace(message))
+            {
+                JObject jobject = JObject.Parse(message);
+
+                if (jobject.GetValue("code") != null)
+                {
+                    if (jobject["code"].ToString() == "400")
+                    {
+                        UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
+                        //Module_Notice.getInstance.SetNoticeInfo("场景数据获取失败", jobject["data"].ToString(), NoticeType.Normal, 1.7f);
+                        //Module_Notice.getInstance._Follower.WindowAnchor = TextAnchor.UpperCenter;
+                        //Module_Notice.getInstance.StartNotice(3f);
+                    }
+                }
+                else
+                {
+                    message = jobject["data"].ToString();
+                    GameManager.Instance.text.text = message;
+                  //  SceneValue scene = JsonMapper.ToObject<SceneValue>(message);
+
+                    SceneValue scene = JsonConvert.DeserializeObject<SceneValue>(message);
+                    DataManager.Instance.CurrentScene = scene;
+                    DataManager.Instance.ProjectID = m_CurrentData.id;
+                    UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.createScene);
+                    StartCoroutine(GetSpoitValueDetail(scene));
+                    GameManager.Instance.text.text = JsonConvert.SerializeObject(scene);
+                    Debug.Log("当前选择场景数据: " + JsonConvert.SerializeObject(scene));
+                }
+            }
+            else
+            {
+                UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
+            }
+           
+        });
+    }
+
+
+    private IEnumerator GetSpoitValueDetail(SceneValue scene)
+    {
+        var spoits = scene.listSpoit;
+        for (int i = 0; i < spoits.Count; i++)
+        {
+            //通过ID获取场景详情
+            SendSceneDetail detail = new SendSceneDetail();
+            detail.id = spoits[i].id;
+            string jsonString = JsonConvert.SerializeObject(detail);
+
+            yield return StartCoroutine(HttpTool.Instance.PostRequestSpoitDetail("/viewpoint/detail", jsonString, (message) =>
+            {
+                Debug.Log("当前选择场景数据: " + message);
+                JObject jObject = JObject.Parse(message);
+                if (jObject["code"].ToString() == "200")
+                {
+                    message = jObject["data"].ToString();
+                    SpoitValueDetail spoit = JsonConvert.DeserializeObject<SpoitValueDetail>(message);
+                    GameManager.Instance.SpoitsValueDetail.Add(spoit.id, spoit);
+                }
+            }));
+        }
+        Debug.Log(scene.vuforiaXML);
+        string xmlName = Path.GetFileName(scene.vuforiaXML);
+
+        if (xmlName != null)
+        {
+            xmlName = xmlName.Substring(0, xmlName.Length - 4);
+            AppConfigConst.IMAGE_TARGET_FILE_NAME = xmlName;
+        }
+
+
+      
+
+        if (scene.vuforiaXML != null)
+        {
+            DownloadData xml = new DownloadData();
+            string filename = Path.GetFileName(scene.vuforiaXML);
+            xml.name = filename;
+            xml.type = 8;
+            xml.downloadPath = scene.vuforiaXML;
+            xml.updateTime = (int)scene.updateTime;
+            xml.localSavePath = Application.persistentDataPath + "/StreamingAssets/Vuforia/" + filename;
+            DownloadManager.Instance.AddDownloadData(xml);
+
+            DownloadData dat = new DownloadData();
+            string filename2 = Path.GetFileName(scene.vuforiaDat);
+            dat.name = filename2;
+            dat.type = 8;
+            dat.downloadPath = scene.vuforiaDat;
+            dat.updateTime = (int)scene.updateTime;
+            dat.localSavePath = Application.persistentDataPath + "/StreamingAssets/Vuforia/" + filename2;
+
+            DownloadManager.Instance.AddDownloadData(dat);
+        }
+
+        yield return new WaitForSeconds(1f);
+        //创建场景
+        GameManager.Instance.CreateScene(scene);
+        Hide();
+    }
+
+
+    private void UpdateSceneItem()
+    {
+        if (m_SceneData == null)
+        {
+            return;
+        }
+        ClearItem();
+        for (int i = 0; i < m_SceneData.Count; i++)
+        {
+            var obj = Instantiate(m_SceneItem);
+            obj.transform.SetParent(m_ScenePanel);
+            var item = obj.AddComponent<SChooseItem>();
+            obj.gameObject.SetActive(true);
+            obj.transform.localScale = new Vector3(1, 1, 1);
+            obj.transform.localEulerAngles = Vector3.zero;
+
+            item.OnSelectScene += OnClickSceneItem;
+            item.SceneData = m_SceneData[i];
+            item.Init();
+            m_Items.Add(item);
+        }
+
+        if (m_CarImage == null)
+        {
+            m_CarImage = m_ScenePanel.gameObject.AddComponent<CarouselImage>();
+        }
+        m_CarImage.mCellSize = new Vector2(400, 150);
+        m_CarImage.mSpacing = new Vector2(0, 0);
+        m_CarImage.mAutoLoop = false;
+        m_CarImage.mDrag = true;
+        m_CarImage.mLoopSpaceTime = 5f;
+        m_CarImage.resizeChildren();
+    }
+
+    private void OnClickSceneItem(SceneValue item, bool b)
+    {
+        m_CurrentData = b ? item : null;
+    }
+
+    #endregion
+    protected override void OnInit()
+    {
+        base.OnInit();
+    }
+
+    protected override void OnShow(object param)
+    {
+        base.OnShow(param);
+        m_SceneData = (List<SceneValue>)param;
+        UpdateSceneItem();
+    }
+
+    protected override void OnHide()
+    {
+        base.OnHide();
+    }
+    /// <summary>
+    /// 清除所有场景信息
+    /// </summary>
+    private void ClearItem()
+    {
+        while (m_Items.Count > 0)
         {
-            Debug.Log("SN:" + send.sn);
-            Debug.Log("通过SN获取场景数据:" + message);
-            if (!string.IsNullOrWhiteSpace(message))
-            {
-                JObject jobject = JObject.Parse(message);
-
-                if (jobject.GetValue("code") != null)
-                {
-                    if (jobject["code"].ToString() == "400")
-                    {
-                        UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
-                        //Module_Notice.getInstance.SetNoticeInfo("场景数据获取失败", jobject["data"].ToString(), NoticeType.Normal, 1.7f);
-                        //Module_Notice.getInstance._Follower.WindowAnchor = TextAnchor.UpperCenter;
-                        //Module_Notice.getInstance.StartNotice(3f);
-                    }
-                }
-                else
-                {
-                    message = jobject["data"].ToString();
-                    GameManager.Instance.text.text = message;
-                  //  SceneValue scene = JsonMapper.ToObject<SceneValue>(message);
-
-                    SceneValue scene = JsonConvert.DeserializeObject<SceneValue>(message);
-                    DataManager.Instance.CurrentScene = scene;
-                    DataManager.Instance.ProjectID = m_CurrentData.id;
-                    UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.createScene);
-                    StartCoroutine(GetSpoitValueDetail(scene));
-                    GameManager.Instance.text.text = JsonConvert.SerializeObject(scene);
-                    Debug.Log("当前选择场景数据: " + JsonConvert.SerializeObject(scene));
-                }
-            }
-            else
-            {
-                UIManager.Instance.HideUI(UINameConfig.LoadingPanel);
-            }
-           
-        });
-    }
-
-
-    private IEnumerator GetSpoitValueDetail(SceneValue scene)
-    {
-        var spoits = scene.listSpoit;
-        for (int i = 0; i < spoits.Count; i++)
-        {
-            //通过ID获取场景详情
-            SendSceneDetail detail = new SendSceneDetail();
-            detail.id = spoits[i].id;
-            string jsonString = JsonConvert.SerializeObject(detail);
-
-            yield return StartCoroutine(HttpTool.Instance.PostRequestSpoitDetail("/viewpoint/detail", jsonString, (message) =>
-            {
-                Debug.Log("当前选择场景数据: " + message);
-                JObject jObject = JObject.Parse(message);
-                if (jObject["code"].ToString() == "200")
-                {
-                    message = jObject["data"].ToString();
-                    SpoitValueDetail spoit = JsonConvert.DeserializeObject<SpoitValueDetail>(message);
-                    GameManager.Instance.SpoitsValueDetail.Add(spoit.id, spoit);
-                }
-            }));
-        }
-        Debug.Log(scene.vuforiaXML);
-        string xmlName = Path.GetFileName(scene.vuforiaXML);
-
-        if (xmlName != null)
-        {
-            xmlName = xmlName.Substring(0, xmlName.Length - 4);
-            AppConfigConst.IMAGE_TARGET_FILE_NAME = xmlName;
-        }
-
-
-      
-
-        if (scene.vuforiaXML != null)
-        {
-            DownloadData xml = new DownloadData();
-            string filename = Path.GetFileName(scene.vuforiaXML);
-            xml.name = filename;
-            xml.type = 8;
-            xml.downloadPath = scene.vuforiaXML;
-            xml.updateTime = (int)scene.updateTime;
-            xml.localSavePath = Application.persistentDataPath + "/StreamingAssets/Vuforia/" + filename;
-            DownloadManager.Instance.AddDownloadData(xml);
-
-            DownloadData dat = new DownloadData();
-            string filename2 = Path.GetFileName(scene.vuforiaDat);
-            dat.name = filename2;
-            dat.type = 8;
-            dat.downloadPath = scene.vuforiaDat;
-            dat.updateTime = (int)scene.updateTime;
-            dat.localSavePath = Application.persistentDataPath + "/StreamingAssets/Vuforia/" + filename2;
-
-            DownloadManager.Instance.AddDownloadData(dat);
-        }
-
-        yield return new WaitForSeconds(1f);
-        //创建场景
-        GameManager.Instance.CreateScene(scene);
-        Hide();
-    }
-
-
-    private void UpdateSceneItem()
-    {
-        if (m_SceneData == null)
-        {
-            return;
-        }
-        ClearItem();
-        for (int i = 0; i < m_SceneData.Count; i++)
-        {
-            var obj = Instantiate(m_SceneItem);
-            obj.transform.SetParent(m_ScenePanel);
-            var item = obj.AddComponent<SChooseItem>();
-            obj.gameObject.SetActive(true);
-            obj.transform.localScale = new Vector3(1, 1, 1);
-            obj.transform.localEulerAngles = Vector3.zero;
-
-            item.OnSelectScene += OnClickSceneItem;
-            item.SceneData = m_SceneData[i];
-            item.Init();
-            m_Items.Add(item);
-        }
-
-        if (m_CarImage == null)
-        {
-            m_CarImage = m_ScenePanel.gameObject.AddComponent<CarouselImage>();
-        }
-        m_CarImage.mCellSize = new Vector2(400, 150);
-        m_CarImage.mSpacing = new Vector2(0, 0);
-        m_CarImage.mAutoLoop = false;
-        m_CarImage.mDrag = true;
-        m_CarImage.mLoopSpaceTime = 5f;
-        m_CarImage.resizeChildren();
-    }
-
-    private void OnClickSceneItem(SceneValue item, bool b)
-    {
-        m_CurrentData = b ? item : null;
-    }
-
-    #endregion
-    protected override void OnInit()
-    {
-        base.OnInit();
-    }
-
-    protected override void OnShow(object param)
-    {
-        base.OnShow(param);
-        m_SceneData = (List<SceneValue>)param;
-        UpdateSceneItem();
-    }
-
-    protected override void OnHide()
-    {
-        base.OnHide();
-    }
-    /// <summary>
-    /// 清除所有场景信息
-    /// </summary>
-    private void ClearItem()
-    {
-        while (m_Items.Count > 0)
-        {
-            var item = m_Items[0];
-            m_Items.RemoveAt(0);
-            Destroy(item.gameObject);
-        }
-    }
-}
+            var item = m_Items[0];
+            m_Items.RemoveAt(0);
+            Destroy(item.gameObject);
+        }
+    }
+}