SceneController.cs 1.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
using UnityEngine;
using SimpleJSON;

namespace dlu
{

public class SceneController : MonoBehaviour
{
    public string json = "test";

11
12
13
    [HideInInspector]
    public SemanticBehaviour[] semanticBehaviours;

14
15
    public void Start()
    {
16
17
18
19
20
        if (semanticBehaviours == null)
        {
            FindSemanticLabels();
        }

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        string jsonContent = Resources.Load<TextAsset>(json).text;
        // Debug.Log(JsonUtility.ToJson(GameObject.Find("Objects/cup").GetComponent<Entity>()));
        // List<Entity> scene = JsonConvert.DeserializeObject<List<Entity>>(jsonContent);
        JSONArray scene = JSON.Parse(jsonContent) as JSONArray;
        foreach (JSONObject obj in scene)
        {
            SetGameObjectState(obj);
        }
    }

    private void SetGameObjectState(JSONObject sceneObject)
    {
        string name = sceneObject["name"];
        // Debug.Log($"name {name}");
        GameObject go = GameObject.Find($"Objects/{name}");
        if (go != null) {
            // Debug.Log(go);
        }
    }
40
41
42
43
44

    public void FindSemanticLabels()
    {
        this.semanticBehaviours = GameObject.FindObjectsOfType<SemanticBehaviour>();
    }
45
46
47
}

}