using UnityEngine; using SimpleJSON; namespace dlu { public class SceneController : MonoBehaviour { public string json = "test"; [HideInInspector] public SemanticBehaviour[] semanticBehaviours; public void Start() { if (semanticBehaviours == null) { FindSemanticLabels(); } string jsonContent = Resources.Load(json).text; // Debug.Log(JsonUtility.ToJson(GameObject.Find("Objects/cup").GetComponent())); // List scene = JsonConvert.DeserializeObject>(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); } } public void FindSemanticLabels() { this.semanticBehaviours = GameObject.FindObjectsOfType(); } } }