Ver código fonte

Saknades kategori id, nu rättat

Axel Nordh 6 anos atrás
pai
commit
2538343752

+ 4 - 4
Assets/MainMenu.unity

@@ -2658,7 +2658,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.000045776367, y: 0.000006676831}
+  m_AnchoredPosition: {x: -0.000045776367, y: 8.324223}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 1}
 --- !u!114 &321314050
@@ -5679,7 +5679,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.000015258789, y: 0.000006676831}
+  m_AnchoredPosition: {x: -0.000015258789, y: 8.324223}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 1}
 --- !u!114 &777178507
@@ -7378,7 +7378,7 @@ MonoBehaviour:
   m_HandleRect: {fileID: 761483706}
   m_Direction: 2
   m_Value: 0
-  m_Size: 1
+  m_Size: 0.9450287
   m_NumberOfSteps: 0
   m_OnValueChanged:
     m_PersistentCalls:
@@ -10953,7 +10953,7 @@ MonoBehaviour:
   m_HandleRect: {fileID: 359479519}
   m_Direction: 2
   m_Value: 0
-  m_Size: 1
+  m_Size: 0.9450287
   m_NumberOfSteps: 0
   m_OnValueChanged:
     m_PersistentCalls:

+ 8 - 15
Assets/Scripts/Database/OnlineDatabase.cs

@@ -442,6 +442,7 @@ public class OnlineDatabase : MonoBehaviour {
         WWWForm form = new WWWForm();
         form.AddField("f", "GetQuestionsLost");
         form.AddField("userName", playerName);
+        form.AddField("gameId", gameId);
 
         string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
         if (response.Equals("")) {
@@ -546,7 +547,7 @@ public class OnlineDatabase : MonoBehaviour {
         int gameId = GameObject.Find("GameManager").GetComponent<GameManagerScript>().GameId;
         Color32 questionCategoryColor = new Color32(0, 0, 20, 20);
 
-        StartCoroutine(GetQuestionData(false));
+        GetQuestionData(false);
         NewQuestion q = NewQuestion.Instance();
         q.questionString = questionString;
         q.answerString = answerString;
@@ -611,30 +612,22 @@ public class OnlineDatabase : MonoBehaviour {
         return questions;
     }
 
-    private IEnumerator GetQuestionData(bool showAnswer) {
-        UnityWebRequest www = UnityWebRequest.Get("nordh.xyz/narKampen/dbFiles/Question.php");
-
-        yield return www.SendWebRequest();
+    private void GetQuestionData(bool showAnswer) {
+        WWWForm form = new WWWForm();
 
-        if (www.isNetworkError || www.isHttpError) {
-            Debug.Log(www.error);
-        } else {
-            while (!www.isDone) {
-                yield return null;
-            }
+        string response = CallOnlineDatabaseWithResponse("Question.php", form);
+        
             // Show result
-            string jsonData = www.downloadHandler.text;
 
-            jsonData = "{\"questionsList\" : [ " + jsonData + " ]}";
+            response = "{\"questionsList\" : [ " + response + " ]}";
 
             Questions qe = new Questions();
-            JsonUtility.FromJsonOverwrite(jsonData, qe);
+            JsonUtility.FromJsonOverwrite(response, qe);
 
             questionString = qe.questionsList[0].question;
             answerString = qe.questionsList[0].answer;
             idString = qe.questionsList[0].id;
             categoryString = qe.questionsList[0].category;
-        }
     }
 
     public List<UserName> GetUsersToInvite(string searchString) {

+ 2 - 1
dbFiles/Question.php

@@ -22,7 +22,8 @@
 		while ($row = mysqli_fetch_assoc($result)) {
 			$json = array('id' => $row['id'],
 				'question' => $row['question'],
-				'answer' => $row['answer']);
+				'answer' => $row['answer'],
+				'category' => $row['category']);
 		}
 		$jsonString = json_encode($json);
 		echo $jsonString;