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;
        }
Exemplo n.º 2
0
        private void loadedGUI()
        {
            if (GUILayout.Button("unload"))
            {
                this.UnLoad();
                return;
            }
            if (GUILayout.Button("Save" + (NodeDataManager.NeedSave || this.sceneChanged ? " *" : "")))
            {
                this.Save();
            }
            if (GUILayout.Button("load (Overwrite Scene)"))
            {
                this.Load();
            }

            GUIHelper.HorizontalLine();
            if (GUILayout.Button("Normalise direct children"))
            {
                var node = this.activeNodeBehavior();
                NodeHelper.NormaliseScale(node);
            }
            if (GUILayout.Button("New Node"))
            {
                NodeCreatorWindow.ShowWindow();
            }
            if (GUILayout.Button("Cut Hole"))
            {
                HoleCutterWindow.ShowWindow();
            }
            GUIHelper.HorizontalLine();
            if (GUILayout.Button("Close And Clean Scene"))
            {
                this.finishNodeEditing();
            }
        }
Exemplo n.º 3
0
        public void UpdateFromJson(NodeJson updatedJson)
        {
            if (updatedJson == null)
            {
                return;
            }

            this.name = updatedJson.name;
            this.transform.localPosition = updatedJson.position;
            if (this.GetScale() != updatedJson.scale)
            {
                var newScale = NodeHelper.InverseScale(updatedJson.scale, this.GetScale());
                this.transform.localScale = newScale;
                NodeHelper.NormaliseScale(this);
            }

            var parentName = this.HasParent ? this.parent.name : "";

            if (updatedJson.parentName != parentName)
            {
                var newParent = updatedJson.parentName == "" ? RootParent : NodeDataManager.FindNode(updatedJson.parentName);
                this.ChangeParent(newParent);
            }
        }