Explorar el Código

Categories gathered from database

Axel Nordh hace 3 años
padre
commit
e3d8f4868f

+ 15 - 7
Assets/Scripts/Database/Category.cs

@@ -1,12 +1,20 @@
-internal class Category
+using System;
+using System.Collections.Generic;
+
+[Serializable]
+public class Category
 {
-    string Name { get; set; }
-    int Id { get; set; }
+    public int a, r, g, b;
+    public string name;
+    public int id;
 
-    public Category() { }
-    public Category(int id, string name)
+    public override string ToString()
     {
-        Name = name;
-        Id = id;
+        return name + " id " + id;
     }
+}
+[Serializable]
+public class CategoryList
+{
+    public List<Category> list;
 }

+ 8 - 1
Assets/Scripts/Database/DatabaseController.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
 using UnityEngine.Networking;
 using UnityEngine.UI;
@@ -14,7 +15,7 @@ public class DatabaseController : MonoBehaviour
 
     public Text statusText;
 
-    List<Category> categories = new List<Category>();
+    CategoryList categories;
 
     private void Awake()
     {
@@ -30,6 +31,12 @@ public class DatabaseController : MonoBehaviour
         if (request.result == UnityWebRequest.Result.Success)
         {
             Debug.Log(request.downloadHandler.text);
+            categories = JsonUtility.FromJson<CategoryList>("{\"list\":" + request.downloadHandler.text + "}");
+            Debug.Log("Category count: " + categories.list.Count);
+            foreach (Category c in categories.list)
+            {
+                Debug.Log(c.ToString());
+            }
         }
         else if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.DataProcessingError)
         {

+ 1 - 0
Logs/shadercompiler-UnityShaderCompiler.exe0.log

@@ -1,3 +1,4 @@
 Base path: 'F:/Unity/2021.3.9f1/Editor/Data', plugins path 'F:/Unity/2021.3.9f1/Editor/Data/PlaybackEngines'
 Cmd: initializeCompiler
 
+Cmd: shutdown

+ 2 - 5
ServerFiles/Categories.php

@@ -23,9 +23,6 @@ $sth->setFetchMode(PDO::FETCH_ASSOC);
 
 $result = $sth->fetchAll();
 if (count($result) > 0) {
-    echo json_encode($result);
-    // foreach($result as $r) {
-    //     $data[] = []
-    //     echo $r['name'].",".$r['id'].PHP_EOL;
-    // }
+    $json =  json_encode($result, JSON_UNESCAPED_UNICODE);
+    echo "{\"items\":" . $json . "}";
 }

+ 14 - 14
UserSettings/Layouts/default-2021.dwlt

@@ -19,7 +19,7 @@ MonoBehaviour:
     width: 1920
     height: 997
   m_ShowMode: 4
-  m_Title: Inspector
+  m_Title: Game
   m_RootView: {fileID: 2}
   m_MinSize: {x: 875, y: 392}
   m_MaxSize: {x: 10000, y: 10000}
@@ -119,7 +119,7 @@ MonoBehaviour:
   m_MinSize: {x: 300, y: 200}
   m_MaxSize: {x: 24288, y: 16192}
   vertical: 0
-  controlID: 154
+  controlID: 103
 --- !u!114 &6
 MonoBehaviour:
   m_ObjectHideFlags: 52
@@ -144,7 +144,7 @@ MonoBehaviour:
   m_MinSize: {x: 200, y: 200}
   m_MaxSize: {x: 16192, y: 16192}
   vertical: 1
-  controlID: 94
+  controlID: 22
 --- !u!114 &7
 MonoBehaviour:
   m_ObjectHideFlags: 52
@@ -169,7 +169,7 @@ MonoBehaviour:
   m_MinSize: {x: 200, y: 100}
   m_MaxSize: {x: 16192, y: 8096}
   vertical: 0
-  controlID: 95
+  controlID: 23
 --- !u!114 &8
 MonoBehaviour:
   m_ObjectHideFlags: 52
@@ -248,7 +248,7 @@ MonoBehaviour:
   m_MinSize: {x: 200, y: 100}
   m_MaxSize: {x: 16192, y: 8096}
   vertical: 0
-  controlID: 45
+  controlID: 110
 --- !u!114 &11
 MonoBehaviour:
   m_ObjectHideFlags: 52
@@ -452,9 +452,9 @@ MonoBehaviour:
   m_SceneHierarchy:
     m_TreeViewState:
       scrollPos: {x: 0, y: 0}
-      m_SelectedIDs: 36940000
-      m_LastClickedID: 37942
-      m_ExpandedIDs: e8c2ffff26c3ffff22c4ffff
+      m_SelectedIDs: 
+      m_LastClickedID: 0
+      m_ExpandedIDs: 20fbffff
       m_RenameOverlay:
         m_UserAcceptedRename: 0
         m_Name: 
@@ -914,10 +914,10 @@ MonoBehaviour:
   m_LockTracker:
     m_IsLocked: 0
   m_FolderTreeState:
-    scrollPos: {x: 0, y: 40}
-    m_SelectedIDs: d8930000
-    m_LastClickedID: 37848
-    m_ExpandedIDs: 0000000070920000d0930000d69300004a940000
+    scrollPos: {x: 0, y: 28}
+    m_SelectedIDs: 14610000
+    m_LastClickedID: 24852
+    m_ExpandedIDs: 00000000f86000000c610000
     m_RenameOverlay:
       m_UserAcceptedRename: 0
       m_Name: 
@@ -945,7 +945,7 @@ MonoBehaviour:
     scrollPos: {x: 0, y: 0}
     m_SelectedIDs: 
     m_LastClickedID: 0
-    m_ExpandedIDs: 
+    m_ExpandedIDs: 00000000f8600000
     m_RenameOverlay:
       m_UserAcceptedRename: 0
       m_Name: 
@@ -972,7 +972,7 @@ MonoBehaviour:
   m_ListAreaState:
     m_SelectedInstanceIDs: 
     m_LastClickedInstanceID: 0
-    m_HadKeyboardFocusLastEvent: 1
+    m_HadKeyboardFocusLastEvent: 0
     m_ExpandedInstanceIDs: c6230000
     m_RenameOverlay:
       m_UserAcceptedRename: 0