Jelajahi Sumber

NY fråga och start fråga fixat

Axel Nordh 7 tahun lalu
induk
melakukan
f97bfc8cbe

+ 8 - 2
Assets/Prefab/NewQuestion.prefab

@@ -376,6 +376,12 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f299b2d58078e8d44b925d2d8c48a498, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  questionText: {fileID: 3395082337199520677}
+  answerText: {fileID: 3395082337050455787}
+  questionString: 
+  answerString: 
+  idString: 
+  categoryString: 
 --- !u!61 &3395082336421756022
 BoxCollider2D:
   m_ObjectHideFlags: 0
@@ -416,7 +422,7 @@ GameObject:
   - component: {fileID: 3395082337050455788}
   - component: {fileID: 3395082337050455787}
   m_Layer: 5
-  m_Name: AnswerText
+  m_Name: NewAnswerText
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
@@ -499,7 +505,7 @@ GameObject:
   - component: {fileID: 3395082337199520678}
   - component: {fileID: 3395082337199520677}
   m_Layer: 5
-  m_Name: QuestionText
+  m_Name: NewQuestionText
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0

+ 6 - 0
Assets/Prefab/QuestionCard.prefab

@@ -350,6 +350,12 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 81296cbde3d359d45a78e8b9a5bace79, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  questionText: {fileID: 8925946038907665068}
+  answerText: {fileID: 332650730565547124}
+  questionString: 
+  answerString: 
+  idString: 
+  categoryString: 
 --- !u!1 &2598333893938895333
 GameObject:
   m_ObjectHideFlags: 0

+ 6 - 0
Assets/Scripts/NewQuestion.cs

@@ -8,6 +8,12 @@ public class NewQuestion : QuestionCard
     void Start()
     {
         // Get question from server
+        SetQuestionData();
+    }
+
+    public void SetQuestionData()
+    {
+        GetQuestion(false);
     }
 
     // Update is called once per frame

+ 40 - 0
Assets/Scripts/NewQuestionScript.cs

@@ -0,0 +1,40 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class NewQuestionScript : MonoBehaviour {
+
+    public GameObject prefab;
+    public Transform contentPanel;
+    // Start is called before the first frame update
+    void Start()
+    {
+        GetNewQuestionData();
+    }
+
+    private void GetNewQuestionData()
+    {
+        // if new game, create one question card to start with
+        GameObject question = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
+        NewQuestion questionCard = question.GetComponent<NewQuestion>();
+        PrepareQuestion(questionCard);
+        questionCard.GetQuestion(false);
+
+        Debug.Log("NEWQuestion start " + questionCard.questionText.text);
+
+        questionCard.transform.SetParent(contentPanel);
+    }
+
+    public void PrepareQuestion(QuestionCard qc)
+    {
+        qc.questionText = GameObject.Find("NewQuestionText").GetComponent<Text>();
+        qc.answerText = GameObject.Find("NewAnswerText").GetComponent<Text>();
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        
+    }
+}

+ 11 - 0
Assets/Scripts/NewQuestionScript.cs.meta

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

+ 26 - 6
Assets/Scripts/QuestionCard.cs

@@ -9,6 +9,11 @@ public class QuestionCard : MonoBehaviour
 {
     public Text questionText;
     public Text answerText;
+
+    public string questionString = "";
+    public string answerString = "";
+    public string idString = "";
+    public string categoryString = "";
     
     [Serializable]
     public class Question {
@@ -25,14 +30,16 @@ public class QuestionCard : MonoBehaviour
 
     // Start is called before the first frame update
     void Start()
+    {
+    }
+
+    public void PrepareQuestion()
     {
         questionText = GameObject.Find("QuestionText").GetComponent<Text>();
         answerText = GameObject.Find("AnswerText").GetComponent<Text>();
-
-        StartCoroutine(GetQuestion(true));
     }
 
-    IEnumerator GetQuestion(bool showAnswer)
+    private IEnumerator GetQuestionData(bool showAnswer)
     {
         UnityWebRequest www = UnityWebRequest.Get("nordh.xyz/narKampen/dbAccess.php");
 
@@ -50,11 +57,24 @@ public class QuestionCard : MonoBehaviour
 
             Questions qe = new Questions();
             JsonUtility.FromJsonOverwrite(jsonData, qe);
+            if (qe.questionsList.Count > 0 && questionText != null )
+            {
+                if (showAnswer && answerText != null)
+                {
+                    answerText.text = qe.questionsList[0].answer;
+                }
+                questionText.text = qe.questionsList[0].question;
+             }
+            questionString = qe.questionsList[0].question;
+            answerString = qe.questionsList[0].answer;
+            idString = qe.questionsList[0].id;
+            categoryString = qe.questionsList[0].category;
 
-            answerText.text = qe.questionsList[0].answer;
-            questionText.text = qe.questionsList[0].question;
         }
+    }
 
-        yield return null;
+    public void GetQuestion(bool showAnswer)
+    {
+        StartCoroutine(GetQuestionData(showAnswer));
     }
 }

+ 16 - 0
Assets/Scripts/ScrollViewScript.cs

@@ -4,10 +4,26 @@ using UnityEngine;
 
 public class ScrollViewScript : MonoBehaviour
 {
+    public GameObject prefab;
+    public Transform contentPanel;
+
     // Start is called before the first frame update
     void Start()
+    {
+        SetGiventQuestion();
+    }
+
+    public void SetGiventQuestion()
     {
         // if new game, create one question card to start with
+        GameObject question = Instantiate(prefab, new Vector2(0,0), Quaternion.identity) as GameObject;
+        QuestionCard questionCard = question.GetComponent<QuestionCard>();
+        questionCard.PrepareQuestion();
+        questionCard.GetQuestion(true);
+
+        Debug.Log("ScrollView Question start " + questionCard.questionText.text + " questionString " + questionCard.questionString);
+
+        questionCard.transform.SetParent(contentPanel);
     }
 
     // Update is called once per frame

+ 5 - 129
Assets/narKampen.unity

@@ -493,7 +493,7 @@ MonoBehaviour:
   m_TargetGraphic: {fileID: 1133529224}
   m_HandleRect: {fileID: 1133529223}
   m_Direction: 0
-  m_Value: 0
+  m_Value: 1
   m_Size: 1
   m_NumberOfSteps: 0
   m_OnValueChanged:
@@ -1131,14 +1131,13 @@ RectTransform:
   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: 2679799103802188408}
+  m_Children: []
   m_Father: {fileID: 1251991201}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0.000026486614, y: -0.000010714011}
+  m_AnchoredPosition: {x: -0.00003454854, y: -0.00004575831}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0, y: 1}
 --- !u!114 &1715970008
@@ -1402,6 +1401,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 684c1f69bdbd6fb4ab209953393d9a9c, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  prefab: {fileID: 828492766240825314, guid: 66a4bacf087ffb848b07dd6b7ee79bba, type: 3}
+  contentPanel: {fileID: 1715970007}
 --- !u!1 &2030668785
 GameObject:
   m_ObjectHideFlags: 0
@@ -1541,12 +1542,6 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 4
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!224 &2679799103802188408 stripped
-RectTransform:
-  m_CorrespondingSourceObject: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-    type: 3}
-  m_PrefabInstance: {fileID: 8132125998305707054}
-  m_PrefabAsset: {fileID: 0}
 --- !u!1001 &3395082336074472064
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -1791,122 +1786,3 @@ PrefabInstance:
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 952f6c50eed555c448854a8a8fdb799e, type: 3}
---- !u!1001 &8132125998305707054
-PrefabInstance:
-  m_ObjectHideFlags: 0
-  serializedVersion: 2
-  m_Modification:
-    m_TransformParent: {fileID: 1715970007}
-    m_Modifications:
-    - target: {fileID: 828492766240825314, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_Name
-      value: QuestionCard
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalPosition.x
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalPosition.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalPosition.z
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalRotation.x
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalRotation.y
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalRotation.z
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalRotation.w
-      value: 1
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_RootOrder
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalEulerAnglesHint.x
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalEulerAnglesHint.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_LocalEulerAnglesHint.z
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_AnchoredPosition.x
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_AnchoredPosition.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_SizeDelta.x
-      value: 100
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_SizeDelta.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_AnchorMin.x
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_AnchorMin.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_AnchorMax.x
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_AnchorMax.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_Pivot.x
-      value: 0.5
-      objectReference: {fileID: 0}
-    - target: {fileID: 2679799103802188408, guid: 66a4bacf087ffb848b07dd6b7ee79bba,
-        type: 3}
-      propertyPath: m_Pivot.y
-      value: 0.5
-      objectReference: {fileID: 0}
-    m_RemovedComponents: []
-  m_SourcePrefab: {fileID: 100100000, guid: 66a4bacf087ffb848b07dd6b7ee79bba, type: 3}

+ 55 - 17
ProjectSettings/QualitySettings.asset

@@ -17,6 +17,7 @@ QualitySettings:
     shadowNearPlaneOffset: 3
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 0
     blendWeights: 1
     textureQuality: 1
     anisotropicTextures: 0
@@ -28,9 +29,17 @@ QualitySettings:
     vSyncCount: 0
     lodBias: 0.3
     maximumLODLevel: 0
+    streamingMipmapsActive: 0
+    streamingMipmapsAddAllCameras: 1
+    streamingMipmapsMemoryBudget: 512
+    streamingMipmapsRenderersPerFrame: 512
+    streamingMipmapsMaxLevelReduction: 2
+    streamingMipmapsMaxFileIORequests: 1024
     particleRaycastBudget: 4
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    asyncUploadPersistentBuffer: 1
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Fast
@@ -43,6 +52,7 @@ QualitySettings:
     shadowNearPlaneOffset: 3
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 0
     blendWeights: 2
     textureQuality: 0
     anisotropicTextures: 0
@@ -54,9 +64,17 @@ QualitySettings:
     vSyncCount: 0
     lodBias: 0.4
     maximumLODLevel: 0
+    streamingMipmapsActive: 0
+    streamingMipmapsAddAllCameras: 1
+    streamingMipmapsMemoryBudget: 512
+    streamingMipmapsRenderersPerFrame: 512
+    streamingMipmapsMaxLevelReduction: 2
+    streamingMipmapsMaxFileIORequests: 1024
     particleRaycastBudget: 16
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    asyncUploadPersistentBuffer: 1
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Simple
@@ -69,6 +87,7 @@ QualitySettings:
     shadowNearPlaneOffset: 3
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 0
     blendWeights: 2
     textureQuality: 0
     anisotropicTextures: 1
@@ -80,9 +99,17 @@ QualitySettings:
     vSyncCount: 1
     lodBias: 0.7
     maximumLODLevel: 0
+    streamingMipmapsActive: 0
+    streamingMipmapsAddAllCameras: 1
+    streamingMipmapsMemoryBudget: 512
+    streamingMipmapsRenderersPerFrame: 512
+    streamingMipmapsMaxLevelReduction: 2
+    streamingMipmapsMaxFileIORequests: 1024
     particleRaycastBudget: 64
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    asyncUploadPersistentBuffer: 1
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Good
@@ -95,6 +122,7 @@ QualitySettings:
     shadowNearPlaneOffset: 3
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 1
     blendWeights: 2
     textureQuality: 0
     anisotropicTextures: 1
@@ -106,9 +134,17 @@ QualitySettings:
     vSyncCount: 1
     lodBias: 1
     maximumLODLevel: 0
+    streamingMipmapsActive: 0
+    streamingMipmapsAddAllCameras: 1
+    streamingMipmapsMemoryBudget: 512
+    streamingMipmapsRenderersPerFrame: 512
+    streamingMipmapsMaxLevelReduction: 2
+    streamingMipmapsMaxFileIORequests: 1024
     particleRaycastBudget: 256
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    asyncUploadPersistentBuffer: 1
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Beautiful
@@ -121,6 +157,7 @@ QualitySettings:
     shadowNearPlaneOffset: 3
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 1
     blendWeights: 4
     textureQuality: 0
     anisotropicTextures: 2
@@ -132,9 +169,17 @@ QualitySettings:
     vSyncCount: 1
     lodBias: 1.5
     maximumLODLevel: 0
+    streamingMipmapsActive: 0
+    streamingMipmapsAddAllCameras: 1
+    streamingMipmapsMemoryBudget: 512
+    streamingMipmapsRenderersPerFrame: 512
+    streamingMipmapsMaxLevelReduction: 2
+    streamingMipmapsMaxFileIORequests: 1024
     particleRaycastBudget: 1024
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    asyncUploadPersistentBuffer: 1
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Fantastic
@@ -147,6 +192,7 @@ QualitySettings:
     shadowNearPlaneOffset: 3
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 1
     blendWeights: 4
     textureQuality: 0
     anisotropicTextures: 2
@@ -158,24 +204,16 @@ QualitySettings:
     vSyncCount: 1
     lodBias: 2
     maximumLODLevel: 0
+    streamingMipmapsActive: 0
+    streamingMipmapsAddAllCameras: 1
+    streamingMipmapsMemoryBudget: 512
+    streamingMipmapsRenderersPerFrame: 512
+    streamingMipmapsMaxLevelReduction: 2
+    streamingMipmapsMaxFileIORequests: 1024
     particleRaycastBudget: 4096
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    asyncUploadPersistentBuffer: 1
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
-  m_PerPlatformDefaultQuality:
-    Android: 2
-    Nintendo 3DS: 5
-    PS4: 5
-    PSM: 5
-    PSP2: 2
-    Samsung TV: 2
-    Standalone: 5
-    Switch: 5
-    Tizen: 2
-    Web: 5
-    WebGL: 3
-    WiiU: 5
-    Windows Store Apps: 5
-    XboxOne: 5
-    iPhone: 2
-    tvOS: 2
+  m_PerPlatformDefaultQuality: {}

+ 10 - 8
ProjectSettings/UnityConnectSettings.asset

@@ -3,30 +3,32 @@
 --- !u!310 &1
 UnityConnectSettings:
   m_ObjectHideFlags: 0
-  m_Enabled: 0
+  serializedVersion: 1
+  m_Enabled: 1
   m_TestMode: 0
-  m_TestEventUrl: 
-  m_TestConfigUrl: 
+  m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
+  m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
+  m_ConfigUrl: https://config.uca.cloud.unity3d.com
   m_TestInitMode: 0
   CrashReportingSettings:
-    m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes
+    m_EventUrl: https://perf-events.cloud.unity3d.com
     m_Enabled: 0
+    m_LogBufferSize: 10
     m_CaptureEditorExceptions: 1
   UnityPurchasingSettings:
     m_Enabled: 0
     m_TestMode: 0
   UnityAnalyticsSettings:
     m_Enabled: 1
-    m_InitializeOnStartup: 1
     m_TestMode: 0
-    m_TestEventUrl: 
-    m_TestConfigUrl: 
+    m_InitializeOnStartup: 1
   UnityAdsSettings:
     m_Enabled: 0
     m_InitializeOnStartup: 1
     m_TestMode: 0
-    m_EnabledPlatforms: 4294967295
     m_IosGameId: 
     m_AndroidGameId: 
+    m_GameIds: {}
+    m_GameId: 
   PerformanceReportingSettings:
     m_Enabled: 0