public override void OnInspectorGUI() { DrawDefaultInspector(); var node = (NodeBehaviour)this.target; GUIHelper.HorizontalLine(); var dataChanged = node.NodeState.StateChanged(); GUI.enabled = !node.noJson; if (GUILayout.Button("Save Node" + (dataChanged ? " *" : ""))) { var json = node.ToJson();//need to add as well?? NodeDataManager.AddNode(json); NodeDataLoader.SaveAll(NodeDataManager.SaveFilePath(), NodeDataManager.SaveDataHolder()); node.NodeState.UpdateState(); } GUI.enabled = true; changeParentMenu(node); if (GUILayout.Button("Normalise direct children")) { NodeHelper.NormaliseScale(node); } GUIHelper.HorizontalLine(); GUI.enabled = false; EditorGUILayout.Vector3Field("Position", node.GetPosition()); EditorGUILayout.Vector3Field("Scale", node.GetScale()); GUI.enabled = true; }
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; }
public void Save() { Debug.Log("Save Nodes"); this.savingNodeData = true; this.sceneChanged = false; foreach (var node in NodeDataManager.NodeBehaviours) { if (node.nodeType == NodeType.HOLE) { continue; /* dont save hole? */ } node.UpdateJson(); // updates json node.NodeState.UpdateState(); } NodeDataLoader.SaveAll(NodeDataManager.SaveFilePath(), NodeDataManager.SaveDataHolder()); }