Browse Source

修改问题为太阳系的题,调整UI大小

wangxin 4 years ago
parent
commit
8db1dbbc43

+ 170 - 35
Assets/Resources/Question/QuestionContral.prefab

@@ -45,6 +45,9 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: d26abf36bfd795247b64c2d237685887, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  IsSendMsgToServer: 1
+  m_WaitP2GalaxTime: 3
+  m_P2Galax: {fileID: 0}
 --- !u!114 &3978478165846016031
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -413,40 +416,45 @@ PrefabInstance:
       propertyPath: m_AnchoredPosition.y
       value: 78.3
       objectReference: {fileID: 0}
-    - target: {fileID: 8388074142738807956, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352507197556, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_AnchoredPosition.y
-      value: -125
+      propertyPath: m_LocalPosition.z
+      value: -0
       objectReference: {fileID: 0}
-    - target: {fileID: 8388074142738807956, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352507197556, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_SizeDelta.y
-      value: 150
+      propertyPath: m_AnchoredPosition.x
+      value: 55
       objectReference: {fileID: 0}
-    - target: {fileID: 3136143645585307287, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352507197556, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_FontData.m_FontSize
-      value: 20
+      propertyPath: m_AnchoredPosition.y
+      value: -215
       objectReference: {fileID: 0}
-    - target: {fileID: 3136143645585307287, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352507197556, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_FontData.m_MinSize
-      value: 2
+      propertyPath: m_SizeDelta.x
+      value: 230
       objectReference: {fileID: 0}
-    - target: {fileID: 2591843352507197557, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352507197556, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_FontData.m_FontSize
-      value: 15
+      propertyPath: m_SizeDelta.y
+      value: 100
       objectReference: {fileID: 0}
-    - target: {fileID: 2591843352507197557, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 8388074142738807956, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_FontData.m_MinSize
-      value: 1
+      propertyPath: m_AnchoredPosition.y
+      value: -175
       objectReference: {fileID: 0}
-    - target: {fileID: 2591843352995083134, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 8388074142738807956, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_RaycastTarget
-      value: 1
+      propertyPath: m_SizeDelta.x
+      value: 230
+      objectReference: {fileID: 0}
+    - target: {fileID: 8388074142738807956, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_SizeDelta.y
+      value: 150
       objectReference: {fileID: 0}
     - target: {fileID: 1508077566, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
       propertyPath: m_LocalPosition.z
@@ -462,11 +470,107 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 1508077566, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
       propertyPath: m_AnchoredPosition.x
-      value: 100
+      value: 115
       objectReference: {fileID: 0}
     - target: {fileID: 1508077566, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
       propertyPath: m_AnchoredPosition.y
-      value: -20
+      value: -30
+      objectReference: {fileID: 0}
+    - target: {fileID: 1508077566, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+      propertyPath: m_SizeDelta.x
+      value: 210
+      objectReference: {fileID: 0}
+    - target: {fileID: 1508077566, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+      propertyPath: m_SizeDelta.y
+      value: 50
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352507197557, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_FontData.m_MinSize
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352507197557, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_Text
+      value: "\u592A\u9633\u7CFB\u4E2D\u6700\u5C0F\u7684\u884C\u661F\u662F\uFF1F"
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352865211165, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_AnchorMin.y
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352865211165, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_AnchorMax.y
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352865211165, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: 115
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352865211165, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: -30
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352995083134, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_RaycastTarget
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 3136143645585307287, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_FontData.m_FontSize
+      value: 20
+      objectReference: {fileID: 0}
+    - target: {fileID: 3136143645585307287, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_FontData.m_MinSize
+      value: 2
+      objectReference: {fileID: 0}
+    - target: {fileID: 8281968744501167505, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_ChildAlignment
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 8281968744501167505, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_Spacing
+      value: 25
+      objectReference: {fileID: 0}
+    - target: {fileID: 8281968744501167505, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_ChildForceExpandWidth
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8281968744501167505, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_ChildForceExpandHeight
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 7568059303096459990, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: 15
+      objectReference: {fileID: 0}
+    - target: {fileID: 7568059303096459990, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_SizeDelta.x
+      value: 50
+      objectReference: {fileID: 0}
+    - target: {fileID: 7568059303096459990, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_SizeDelta.y
+      value: 50
+      objectReference: {fileID: 0}
+    - target: {fileID: 1261672939, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: 27.5
+      objectReference: {fileID: 0}
+    - target: {fileID: 1261672939, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+      propertyPath: m_SizeDelta.x
+      value: -55
       objectReference: {fileID: 0}
     - target: {fileID: 1508077565, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
       propertyPath: m_IsActive
@@ -476,31 +580,62 @@ PrefabInstance:
       propertyPath: m_LocalPosition.z
       value: -0.20871311
       objectReference: {fileID: 0}
+    - target: {fileID: 1467369133, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: 25
+      objectReference: {fileID: 0}
+    - target: {fileID: 1467369133, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+      propertyPath: m_AnchoredPosition.y
+      value: -25
+      objectReference: {fileID: 0}
     - target: {fileID: 1467369133, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
       propertyPath: m_SizeDelta.x
-      value: 20
+      value: 50
       objectReference: {fileID: 0}
     - target: {fileID: 1467369133, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
       propertyPath: m_SizeDelta.y
+      value: 50
+      objectReference: {fileID: 0}
+    - target: {fileID: 4101604926636709812, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_AnchoredPosition.x
+      value: 15
+      objectReference: {fileID: 0}
+    - target: {fileID: 4101604926636709812, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_SizeDelta.x
+      value: 50
+      objectReference: {fileID: 0}
+    - target: {fileID: 4101604926636709812, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_SizeDelta.y
+      value: 50
+      objectReference: {fileID: 0}
+    - target: {fileID: 1261672940, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+      propertyPath: m_FontData.m_FontSize
       value: 20
       objectReference: {fileID: 0}
-    - target: {fileID: 8281968744501167505, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352647172005, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_ChildAlignment
-      value: 1
+      propertyPath: m_FontData.m_FontSize
+      value: 20
       objectReference: {fileID: 0}
-    - target: {fileID: 8281968744501167505, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352647172005, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_ChildForceExpandWidth
-      value: 0
+      propertyPath: m_FontData.m_MinSize
+      value: 2
       objectReference: {fileID: 0}
-    - target: {fileID: 8281968744501167505, guid: 8f5c168366790844a9e7da38baa28c35,
+    - target: {fileID: 2591843352879768083, guid: 8f5c168366790844a9e7da38baa28c35,
         type: 3}
-      propertyPath: m_ChildForceExpandHeight
-      value: 0
+      propertyPath: m_FontData.m_FontSize
+      value: 20
+      objectReference: {fileID: 0}
+    - target: {fileID: 2591843352879768083, guid: 8f5c168366790844a9e7da38baa28c35,
+        type: 3}
+      propertyPath: m_FontData.m_MinSize
+      value: 2
       objectReference: {fileID: 0}
-    m_RemovedComponents:
-    - {fileID: 5252181168098895209, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
+    m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 8f5c168366790844a9e7da38baa28c35, type: 3}
 --- !u!4 &8345310932731944608 stripped
 Transform:

+ 9 - 9
Assets/Scripts/Data/QuestionData.cs

@@ -14,9 +14,9 @@ public class QuestionData
         question1.position = new Vector3(3.301f, 0f, -5.286f);
         question1.rotation = new Vector3(0, -116.1f, 0f);
         question1.scale = new Vector3(1, 1, 1);
-        question1.question = "下列不属于化石燃料的是";
-        question1.Answer.Add("氢气");
-        question1.Answer.Add("");
+        question1.question = "太阳系中最小的行星是?";
+        question1.Answer.Add("水星");
+        question1.Answer.Add("木星");
         question1.RightAnswer = 0;
         question1.score = 10;
         QuestionList.Add(question1);
@@ -25,9 +25,9 @@ public class QuestionData
         question2.position = new Vector3(3.057f, -0f, -4.788f);
         question2.rotation = new Vector3(0, -116.1f, 0f);
         question2.scale = new Vector3(1, 1, 1);
-        question2.question = "下列物质中属于纯净物的是";
-        question2.Answer.Add("精制碘盐");
-        question2.Answer.Add("蒸馏水");
+        question2.question = "金星上的一天等于地球的多少天?";
+        question2.Answer.Add("245");
+        question2.Answer.Add("243");
         question2.RightAnswer = 1;
         question2.score = 10;
         QuestionList.Add(question2);
@@ -36,9 +36,9 @@ public class QuestionData
         question3.position = new Vector3(2.816f, -0f, -4.296f);
         question3.rotation = new Vector3(0, -116.1f, 0f);
         question3.scale = new Vector3(1, 1, 1);
-        question3.question = "除去KCl溶液中混有的少量K2CO3,选用的试剂是";
-        question3.Answer.Add("稀盐酸");
-        question3.Answer.Add("K2SO4溶液");
+        question3.question = "太阳系密度最大的天体是?";
+        question3.Answer.Add("地球");
+        question3.Answer.Add("火星");
         question3.RightAnswer = 0;
         question3.score = 10;
         QuestionList.Add(question3);

+ 43 - 12
Assets/XDKUnityCloudExamples/Common/Scripts/Question/QuestionControl.cs

@@ -3,9 +3,10 @@ using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using System;
+using SC.XR.Unity.Module_InputSystem;
 
 /*
- * 当前无数据
+ * 答题模块的控制面板
  */
 public class QuestionControl : MonoBehaviour
 {
@@ -19,10 +20,23 @@ public class QuestionControl : MonoBehaviour
     //所有题目
     private List<Question> m_Questions;
     private UdpClient m_Udp;
-    public bool m_IsSendMsg;
+    /// <summary>
+    /// 是否向服务器发送数据
+    /// </summary>
+    [SerializeField]
+    private bool IsSendMsgToServer;
+    ///// <summary>
+    ///// 等待太阳系现时间
+    ///// </summary>
+    //[SerializeField]
+    //private float m_WaitP2GalaxTime;
     //太阳系
     public GameObject m_P2Galax;
 
+    private void OnEnable()
+    {
+        ChangeInputDeviceType(InputDeviceType.Head);
+    }
     private void Awake()
     {
         DataManager.Instance.Init();
@@ -32,17 +46,14 @@ public class QuestionControl : MonoBehaviour
     {
         m_CurrentScore = 0;
         m_RightQuestion = 0;
-        // m_IsSendMsg = false;
-        //m_Prefab = Resources.Load("question/question");
         m_SucessPanel = transform.Find("Sucess").gameObject;
         m_SucessText = m_SucessPanel.transform.Find("Text").GetComponent<Text>();
         m_Prefab = transform.Find("Question").gameObject;
         m_Prefab.SetActive(false);
         m_AlreadyQuestion = new List<Question>();
-        if(!m_IsSendMsg)
-         m_Udp = GameObject.Find("Socket").GetComponent<UdpClient>();
+        if (IsSendMsgToServer)
+            m_Udp = GameObject.Find("Socket").GetComponent<UdpClient>();
         m_Questions = new List<Question>();
-        //m_P2Galax = GameObject.Find("P2Galaxy");
         CraetQuestions();
     }
 
@@ -99,14 +110,13 @@ public class QuestionControl : MonoBehaviour
             m_SucessText.text = str;
 
             //发送信息到服务器
-            if (!m_IsSendMsg)
+            if (IsSendMsgToServer)
             {
                 SendQuestionInfor questionInfor = new SendQuestionInfor();
                 questionInfor.sn = DeviceSN.GetInstance().SendSerialBy16();
                 questionInfor.correct = m_RightQuestion;
                 questionInfor.incorrect = DataManager.Instance.QuesDataMgr.QuestionList.Count - m_RightQuestion;
                 m_Udp.SendIpTOQuestion(questionInfor);
-                m_IsSendMsg = true;
             }
 
             //等待2秒后,答题面板消失,太阳系出现
@@ -115,28 +125,49 @@ public class QuestionControl : MonoBehaviour
     }
     IEnumerator WaiteTime()
     {
-        yield return new WaitForSeconds(3f);
+        yield return new WaitForSeconds(2f);
         for (int i = 0; i < m_Questions.Count; i++)
         {
             m_Questions[i].gameObject.SetActive(false);
         }
         m_P2Galax.SetActive(true);
         m_SucessPanel.SetActive(false);
+        StopCoroutine(WaiteTime());
+    }
+
+    /// <summary>
+    /// 改变交互方式
+    /// </summary>
+    /// <param name="type"></param>
+    private void ChangeInputDeviceType(InputDeviceType type)
+    {
+        var list = API_Module_InputSystem.GetInstance().inputDeviceSupportList;
+        for (int i = 0; i < list.Length; i++)
+        {
+            if (type == list[i].inputDeviceType)
+            {
+                API_Module_InputSystem.GetInstance().SetActiveInputDevice(list[i].inputDeviceType, true);
+            }
+            else
+            {
+                API_Module_InputSystem.GetInstance().SetActiveInputDevice(list[i].inputDeviceType, false);
+            }
+        }
+
     }
 
     private void OnDisable()
     {
-        StopCoroutine(WaiteTime());
         m_RightQuestion = 0;
         m_CurrentScore = 0;
         m_AlreadyQuestion.Clear();
-        //m_IsSendMsg = false;
         for (int i = 0; i < m_Questions.Count; i++)
         {
             m_Questions[i].gameObject.SetActive(true);
         }
         m_P2Galax.SetActive(false);
         m_SucessPanel.SetActive(false);
+        ChangeInputDeviceType(InputDeviceType.GGT26Dof);
     }
 
 }