Exemplo n.º 1
0
 public void RemoveConnection(uNode child)
 {
     if (child.Parent != null)
     {
         child.Parent.RemoveChild(child);
         child.Parent  = null;
         currentCanvas = uNodeEditorSaveManager.SaveCanvasState(currentCanvas);
     }
 }
Exemplo n.º 2
0
        public void DuplicateNodeWithChildren(uNode n)
        {
            // TO DO
            uNode copy = n.GetCopy();

            copy.ParentName = "";
            copy.Position   = new Vector2(copy.Position.x + copy.Size.x + 50f, copy.Position.y);
            AddNewNode(copy);
        }
Exemplo n.º 3
0
 public void AddConnection(uNode parent, uNode child)
 {
     if (IsValidConnection(parent, child))
     {
         parent.AddChild(child);
         child.Parent  = parent;
         currentCanvas = uNodeEditorSaveManager.SaveCanvasState(currentCanvas);
     }
 }
Exemplo n.º 4
0
        public void DuplicateNode(uNode n)
        {
            // Get copy returns n copy without hierarchical info
            // (except for ParentName, used in Save/Load functions)
            uNode copy = n.GetCopy();

            copy.ParentName = "";
            copy.Position   = new Vector2(copy.Position.x + copy.Size.x + 50f, copy.Position.y);
            AddNewNode(copy);
        }
Exemplo n.º 5
0
        // GUI Function
#if UNITY_EDITOR
        public virtual uNode GetCopy()
        {
            uNode copy = CreateInstance <uNode>();

            UnityEditor.EditorUtility.CopySerialized(this, copy);
            copy.childrens  = new List <uNode>();
            copy.parentName = parent != null ? parent.nodeName : "";
            copy.InputKnob  = new uKnob(copy);
            copy.OutputKnob = new uKnob(copy);
            return(copy);
        }
Exemplo n.º 6
0
 // Private member functions
 private bool IsValidConnection(uNode parent, uNode child)
 {
     if (parent == child)
     {
         return(false);
     }
     if (parent.HasChild(child))
     {
         return(false);
     }
     if (child.Parent != null)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 7
0
        public void CreateNewNode()
        {
            if (currentCanvas == null)
            {
                return;
            }
            uNode   n = ScriptableObject.CreateInstance <uTerrainNode>();
            Vector2 p = uNodeEditor.editor.CanvasWindowRect.Contains(uNodeEditorState.mousePosition)
                            ? uNodeEditorState.mousePosition
                            : new Vector2(200f, 200f);

            // @ To do : scale p with EditorZoom
            n.Init("Node" + currentCanvas.Nodes.Count, p);
            currentCanvas.Nodes.Add(n);
            currentCanvas = uNodeEditorSaveManager.SaveCanvasState(currentCanvas);
        }
Exemplo n.º 8
0
        public static uCanvas CreateWorkingCopy(uCanvas canvas)
        {
            uCanvas ret = ScriptableObject.CreateInstance <uCanvas>();

            ret.Init(canvas.Name);

            // Copy each node
            foreach (uNode n in canvas.Nodes)
            {
                uNode copy = n.GetCopy();
                ret.Nodes.Add(copy);
            }

            // Restore hirearchy
            ret.SetParentFromCopy();

            return(ret);
        }
Exemplo n.º 9
0
 public void DeleteNode(uNode n)
 {
     currentCanvas.Nodes.Remove(n);
     if (n.Parent != null)
     {
         n.Parent.Childrens.Remove(n);
     }
     if (n.Childrens.Count > 0)
     {
         for (int i = 0; i < n.Childrens.Count; i++)
         {
             n.Childrens[i].Parent = null;
         }
         n.Childrens.Clear();
     }
     Object.DestroyImmediate(n);
     currentCanvas = uNodeEditorSaveManager.SaveCanvasState(currentCanvas);
 }
Exemplo n.º 10
0
 public void AddNewNode(uNode n)
 {
     currentCanvas.Nodes.Add(n);
     currentCanvas = uNodeEditorSaveManager.SaveCanvasState(currentCanvas);
 }
Exemplo n.º 11
0
 public uKnob(uNode p)
 {
     parent = p;
     rect   = new Rect(parent.Position, new Vector2(uNodeEditorSettings.knobWidth, uNodeEditorSettings.knobHeight));
 }
Exemplo n.º 12
0
 public bool HasChild(uNode child)
 {
     return(childrens.Contains(child));
 }
Exemplo n.º 13
0
 public void RemoveChild(uNode child)
 {
     childrens.Remove(child);
 }
Exemplo n.º 14
0
 public void AddChild(uNode child)
 {
     childrens.Add(child);
 }