コード例 #1
0
 public BlendContainerWindow(Rect position, AT_Node node)
     : base(position, "Blend Graph", node)
 {
     m_Out = new ConnectionButton(this, ConnectionButton.ConnectionButtonType.kAnimDataOut,"Out", ConnectionButton.Alignment.kLeft);
     ConnectionPoints = new ConnectionButton[1];
     ConnectionPoints[0] = m_Out;
 }
コード例 #2
0
    public ControlVariablesWindow(Rect position, AT_Node node)
        : base(position, "Control Variables", node)
    {
        m_varsNode = node as AT_ControlVariables;
        if (m_varsNode != null)
        {
            m_varsNode.Refresh ();

            m_buttons = new ConnectionButton[m_varsNode.Variables.Count];
            ConnectionPoints = m_buttons;
            int counter = 0;
            foreach (ControlVariable cv in m_varsNode.Variables)
            {
                if (cv != null)
                {
                    m_buttons[counter] = new ConnectionButton (this, ConnectionButton.ConnectionButtonType.kControlDataOut, cv.m_variableName, ConnectionButton.Alignment.kLeft);
                    counter++;
                }
            }
        }

        Rect pos = Position;
        float newHeight = 30 + 25 * m_varsNode.Variables.Count;
        pos.y = pos.y + pos.height - newHeight;
        pos.height = newHeight;
        pos.width = position.width;
        Position = pos;
    }
コード例 #3
0
 public ResultNodeWindow( Rect position, AT_Node node )
     : base(position, "Output", node)
 {
     m_In = new ConnectionButton( this, ConnectionButton.ConnectionButtonType.kAnimDataIn, "In", ConnectionButton.Alignment.kRight );
     ConnectionPoints = new ConnectionButton[2];
     ConnectionPoints[1] = m_In;
 }
コード例 #4
0
    public PoseNodeWindow(Rect position, string animation, AT_Node node)
        : base(position, "Pose", node)
    {
        m_AnimationName = animation;
        m_Out = new ConnectionButton(this, ConnectionButton.ConnectionButtonType.kAnimDataOut,"Out", ConnectionButton.Alignment.kLeft);
           // m_controlVariable = new ConnectionButton(this, ConnectionButton.ConnectionButtonType.kControlDataIn, "Time Control", ConnectionButton.Alignment.kRight);

        ConnectionPoints = new ConnectionButton[1];
        ConnectionPoints[0] = m_Out;

        Position = position;
    }
コード例 #5
0
    public NodeWindow( Rect position, string title, AT_Node node)
    {
        Title = title;
        TreeNode = node;

        //Debug.Log(Position);

        /*Rect pos = Position;
        pos.width = position.width;
        pos.height = position.height;
        Position = pos;*/
        Position = position;
    }
コード例 #6
0
    public AdditiveBlendNodeWindow(Rect position, AT_Node node)
        : base(position, "Additive Blend", node)
    {
        m_Out = new ConnectionButton( this, ConnectionButton.ConnectionButtonType.kAnimDataOut, "Out", ConnectionButton.Alignment.kLeft );

        AT_AdditiveBlend blendNode = (AT_AdditiveBlend)node;
        int childCount = blendNode.Children.Count;

        position.height = 30 + (30 * childCount);
        Position = position;

        ConnectionPoints = new ConnectionButton[childCount + 1];
        ConnectionPoints[0] = m_Out;

        for (int i = 0; i < childCount; i++)
        {
            ConnectionPoints[i + 1] = new ConnectionButton(this, ConnectionButton.ConnectionButtonType.kAnimDataIn, "In " + (i + 1), ConnectionButton.Alignment.kRight);
        }
    }
コード例 #7
0
    public AnimationNodeWindow(Rect position, string animation, AT_Node node)
        : base(position, "Animation", node)
    {
        m_AnimationName = animation;
        m_Out = new ConnectionButton(this, ConnectionButton.ConnectionButtonType.kAnimDataOut,"Out", ConnectionButton.Alignment.kLeft);
        m_controlVariable = new ConnectionButton(this, ConnectionButton.ConnectionButtonType.kControlDataIn, "Time Control", ConnectionButton.Alignment.kRight);
        m_speedControlVariable = new ConnectionButton(this, ConnectionButton.ConnectionButtonType.kControlDataIn, "Speed Control", ConnectionButton.Alignment.kRight);

        ConnectionPoints = new ConnectionButton[1];
        ConnectionPoints[0] = m_Out;

        if ((node as AT_Animation).m_animTimeControlled)
        {
            position.height = 100;
        }

        if ((node as AT_Animation).animSpeedControlled)
        {
            position.height = 100;
        }

        Position = position;
    }
コード例 #8
0
 public AnimationStateWindow(Rect position, string animation, AT_Node node)
     : base(position, "Animation", node)
 {
     m_AnimationName = animation;
 }
コード例 #9
0
    void ApplyNewSubjectToChildAnimationNodes(AT_Node node)
    {
        AT_AnimationBase anim = node as AT_AnimationBase;
        AT_AnimationState state = node as AT_AnimationState;
        if (state != null)
        {
            anim = state.m_animation;
        }
        if (anim != null)
        {
            anim.m_subject = m_subject;
            anim.Init ();
        }

        AT_ContainerNode cont = node as AT_ContainerNode;
        if (cont != null)
        {
            foreach (AT_Node cNode in cont.Children)
            {
                ApplyNewSubjectToChildAnimationNodes (cNode);
            }
        }
    }
コード例 #10
0
 public void RegisterNode( AT_Node node )
 {
     _treeNodes.Add(node);
 }
コード例 #11
0
 public void DeregisterNode( AT_Node node )
 {
     _treeNodes.Remove(node);
 }
コード例 #12
0
    // Add a child to the container
    public virtual void AddChild( AT_Node node, bool unassigned )
    {
        if (node == null)
        {
            Debug.LogWarning("AT_ContainerNode: Tried to add null node as child");
            return;
        }

         // Set this as the new child's parent
        node.SetParent(this);

        if (unassigned)
        {
            if (!UnassignedChildren_Writable.Contains(node))
            {
                UnassignedChildren_Writable.Add(node);
            }
            else
            {
                Debug.LogWarning("AT_ContainerNode: Failed to add unassigned child because node is already a unassigned child");
            }
        }
        else
        {
            if (!Children_Writable.Contains(node))
            {
                Children_Writable.Add(node);
            }
            else
            {
                Debug.LogWarning("AT_ContainerNode: Failed to add child because node is already a child");
            }
        }
    }
コード例 #13
0
    public void CheckForDirtyNodes( AT_Node node )
    {
        if ( node == null )
        {
            return;
        }

        if ( node.IsDirty )
        {
            //Debug.Log("dirty: " + node.name);
            EditorUtility.SetDirty(node);
            node.IsDirty = false;
        }

        AT_ContainerNode cont = node as AT_ContainerNode;
        if ( cont != null )
        {
            foreach( AT_Node cNode in cont.Children )
            {
                CheckForDirtyNodes( cNode );
            }

            for (int i = 0; i < cont.UnassignedChildren.Count; i++)
            {
                CheckForDirtyNodes( cont.UnassignedChildren[i] );
            }
        }
    }
コード例 #14
0
 // Get the window that represents the passed node
 public NodeWindow GetCorrespondingWindow(AT_Node node)
 {
     foreach (NodeWindow win in m_Windows)
     {
         if (win.GetTreeNode() == node)
         {
             return win;
         }
     }
     return null;
 }
コード例 #15
0
 // Remove a child state. Needs to be different to a normal container node
 public override void RemoveChild(AT_Node node)
 {
     Children_Writable.Remove(node);
     UnassignedChildren_Writable.Remove(node);
 }
コード例 #16
0
    public void Update()
    {
        if ( m_selectedAnimationTree != null && m_selectedAnimationTree.IsDirty )
        {
            CheckForDirtyNodes(m_selectedAnimationTree.Root);
            m_selectedAnimationTree.IsDirty = false;
        }

        if ( Selection.activeGameObject != null )
        {
            // Get the current selection from Unity
            GameObject go = Selection.activeGameObject;

            // Get the tree the current selection belongs to
            AnimationTree currentTree = GetAnimationTree( go );

            // If a child of an animation tree is currently selected...
            if (currentTree != null)
            {
                GameObject firstChild = go;

                // Make sure the firstChild points to an AT_Node not the AnimationTree base object
                if (currentTree.gameObject == go )
                {
                    firstChild = currentTree.Root.gameObject;
                }
                m_currentNode = firstChild.GetComponent<AT_Node>();

                AT_ContainerNode contParent;
                // If the root is not selected, find the closest container node to the selected node
                if (firstChild != currentTree.Root.gameObject)
                {
                    if (m_currentNode != null && m_currentNode.Parent != null)
                    {
                        contParent = FindNextContainerNode(m_currentNode.Parent.gameObject);
                    }
                    else
                    {
                        contParent = FindNextContainerNode(firstChild.transform.parent.gameObject);
                    }
                }
                else
                {
                    // If the root is selected, it is the active container
                    contParent = firstChild.GetComponent<AT_ContainerNode>();
                }

                // Change the control variables node's parent to the currently selected container.
                // This allows us to view and select the control variables node while inside any
                // container node without altering what the active container node is
                if (m_selectedAnimationTree != null && m_activeContainer != null)
                {
                    m_selectedAnimationTree.m_controlVarsNode.Parent = m_activeContainer;
                }

                // If we've selected a new container node, rebuild the tree graph
                if ( contParent != m_activeContainer )
                {
                    m_activeContainer = contParent;
                    RebuildTreeGraph();
                }

                // If the control variables window doesn't exist, create it
                if (m_controlVarsWindow == null)
                {
                    RefreshVariablesWindow();
                }
            }

            m_selectedAnimationTree = currentTree;
        }
        else
        {
            m_selectedAnimationTree = null;
        }
    }
コード例 #17
0
 public StateWindow(Rect position, string title, AT_Node node )
     : base(position, title, node)
 {
 }
コード例 #18
0
 public StateWindow(Rect position, AT_Node node)
     : base(position, "State", node)
 {
 }
コード例 #19
0
    // Detach a node from its current parent and make it an unassigned child of the active container
    public void DetachNode( AT_Node node )
    {
        if (node == null)
        {
            return;
        }

        m_activeContainer.AddChild(node, true);
        node.SetParentBlendWeight(0);

        m_activeContainer.SetDirty();
        node.SetDirty();
    }
コード例 #20
0
 public BlendGraphWindow(Rect position, AT_Node node)
     : base(position, "Blend Graph", node)
 {
 }
コード例 #21
0
 // Insert a child node at a specific point in the child list
 public void InsertChild(AT_Node node, int index)
 {
     Children_Writable[index] = node;
     node.SetParent(this);
 }
コード例 #22
0
    // Remove the node from this container
    public virtual void RemoveChild(AT_Node node)
    {
        for (int i = 0; i < Children_Writable.Count; i++)
        {
            if (Children_Writable[i] == node)
            {
                Children_Writable[i] = null;
            }
        }

        UnassignedChildren_Writable.Remove(node);
    }
コード例 #23
0
    // Create a new window to represent the passed node
    void AddWindowForNode(AT_Node node)
    {
        if (node == null)
        {
            //Debug.LogError ("AnimationTreeEditor: Trying to add window for null node");
            return;
        }

        NodeWindow win = null;

        switch (node.NodeType)
        {
        case AT_NodeType.kOutput:
            AT_OutputNode resNode = (AT_OutputNode)node;
            win = new ResultNodeWindow (new Rect (resNode.EditorProperties.Position.x, resNode.EditorProperties.Position.y, 150, 50), node);
            break;

            case AT_NodeType.kAnimation:
            AT_Animation animNode = (AT_Animation)node;
            win = new AnimationNodeWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 200, 60), animNode.m_animationName, node);
            break;

            case AT_NodeType.kPose:
            AT_Pose poseNode = (AT_Pose)node;
            win = new PoseNodeWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 200, 60), poseNode.m_animationName, node);
            break;

            case AT_NodeType.kAnimationState:
            AT_AnimationState animState = (AT_AnimationState)node;
            win = new AnimationStateWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 150, 60), animState.m_animation.m_animationName, node);
            break;

            case AT_NodeType.kBlendGraph:
            win = new BlendGraphWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 150, 60), node);
            break;

            case AT_NodeType.kBlend:
            win = new BlendNodeWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 150, 100), node);
            break;

            case AT_NodeType.kStateMachine:
            win = new StateMachineWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 150, 60), node);
            break;

            case AT_NodeType.kBlendContainer:
            win = new BlendContainerWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 200, 60), node);
            break;

            case AT_NodeType.kAdditiveBlend:
            win = new AdditiveBlendNodeWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 150, 100), node);
            break;

            case AT_NodeType.kBlendStateMachine:
            win = new BlendSMWindow (new Rect (node.EditorProperties.Position.x, node.EditorProperties.Position.y, 200, 60), node);
            break;

        case AT_NodeType.kRoot:
            Debug.LogError ("AnimationTreeEditor: Trying to add a window for the root node");
            /*AT_StateMachine sm = node as AT_StateMachine;
            if (sm != null)
            {
                Debug.Log (sm.m_stateName);
            }*/

            Debug.Log(node.GetType());

            break;
        }

        if (win != null)
        {
            m_Windows.Add (win);
        }

        // If this is a contianer, create new windows for all of its children
        AT_ContainerNode cont = node as AT_ContainerNode;
        if ( cont != null && !cont.Expandable)
        {
            foreach ( AT_Node cNode in cont.Children )
            {
                //for ( int i = 0; i < cont.Children.Count; i++ )
                //{
                    AddWindowForNode( cNode );//cont.Children[i] );
                //}
            }

            for (int i = 0; i < cont.UnassignedChildren.Count; i++)
            {
                AddWindowForNode(cont.UnassignedChildren[i]);
            }
        }
    }