public void OnGUI()
        {
            this.container            = EditorGUILayout.ObjectField("container", this.container, typeof(Transform), true) as Transform;
            NodeDataName.DataFileName = EditorGUILayout.TextField("Data File Name", NodeDataName.DataFileName);


            GUI.enabled = this.container != null && !NodeDataManager.IsLoaded && !this.hasCreated;
            if (GUILayout.Button("Create"))
            {
                Debug.Log("Creating new room layout from cubes, old data will be deleted");
                var data = NodeDataLoader.LoadAll(NodeDataName.DataFileName);
                NodeDataManager.Load(NodeDataName.DataFileName, data);
                NodeDataManager.DeleteAll();

                var cubes = this.container.GetComponentsInChildren <Transform>();
                foreach (var cube in cubes)
                {
                    if (cube == this.container)
                    {
                        continue;
                    }
                    if (cube.parent != this.container)
                    {
                        Debug.LogWarning("Container has 2nd level a child that will be ignored"); continue;
                    }

                    var node = new NodeJson(NodeDataManager.NextName(NodeType.CUBE), cube.position, cube.localScale, "", NodeType.CUBE);

                    NodeDataManager.AddNode(node);
                }

                NodeFactory.CreateNodes(NodeDataManager.NodeJsons);

                this.container.gameObject.SetActive(false);
                this.hasCreated = true;
            }
            GUI.enabled = true;
            if (NodeDataManager.IsLoaded)
            {
                GUILayout.Label("Please Unload first");
            }


            GUIHelper.HorizontalLine();
            GUI.skin.label.wordWrap = true;
            GUILayout.Label("** This Action will overrite current data **");
            GUILayout.Label("If you dont want to lose any data please change the data file that is being used");

            GUI.enabled = this.hasCreated;
            if (GUILayout.Button("Save"))
            {
                NodeDataLoader.SaveAll(NodeDataManager.SaveFilePath(), NodeDataManager.SaveDataHolder());
            }
            GUI.enabled = true;
        }
Пример #2
0
        public void Load()
        {
            Debug.Log("Loading Nodes");
            this.sceneChanged = false;

            NodeDataManager.Unload();

            var data = NodeDataLoader.LoadAll(NodeDataName.DataFileName);

            NodeDataManager.Load(NodeDataName.DataFileName, data);
            NodeFactory.CreateRootParent();
            NodeFactory.CreateNodes(NodeDataManager.NodeJsons);
        }