예제 #1
0
        /// <summary>
        /// Draws the node inspector.
        /// <param name="target">The node that is being inspected.</param>
        /// </summary>
        public void DrawNode(ActionNode target)
        {
            // Create style?
            if (s_Styles == null)
            {
                s_Styles = new NodeEditor.Styles();
            }

            if (target == null)
            {
                m_SerializedNode    = null;
                m_Target            = null;
                m_TargetContent     = GUIContent.none;
                m_TargetIconContent = GUIContent.none;
                m_TargetType        = string.Empty;
            }
            // The target node has changed?
            else if (m_SerializedNode == null || m_SerializedNode.target != target)
            {
                m_SerializedNode = new SerializedNode(target);
                m_Target         = target;

                Type targetType = m_Target.GetType();
                m_TargetType = " (" + targetType.Name + ")";
                var nodeInfo = AttributeUtility.GetAttribute <NodeInfoAttribute>(targetType, false) ?? new NodeInfoAttribute();
                m_TargetContent     = new GUIContent(target.name + m_TargetType, null, nodeInfo.description);
                m_TargetIconContent = new GUIContent(IconUtility.GetIcon(targetType));

                // Update Values
                m_SerializedNode.Update();
            }

            // The serialized node is not null?
            if (m_SerializedNode != null)
            {
                // Draw node title
                this.DrawTitle();

                if (m_Target != null && BehaviourWindow.IsVisible(m_Target.instanceID))
                {
                    // Draw node properties
                    this.OnInspectorGUI();

                    // Update target content?
                    if (Event.current.type == EventType.Used && m_Target != null)
                    {
                        m_TargetContent.text = m_Target.name + m_TargetType;
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Draws the node inspector.
        /// <param name="target">The node that is being inspected.</param>
        /// </summary>
        public void DrawNode (ActionNode target) {
            // Create style?
            if (s_Styles == null)
                s_Styles = new NodeEditor.Styles();

            if (target == null) {
                m_SerializedNode = null;
                m_Target = null;
                m_TargetContent = GUIContent.none;
                m_TargetIconContent = GUIContent.none;
                m_TargetType = string.Empty;
            }
            // The target node has changed?
            else if (m_SerializedNode == null || m_SerializedNode.target != target) {
                m_SerializedNode = new SerializedNode(target);
                m_Target = target;

                Type targetType = m_Target.GetType();
                m_TargetType = " (" + targetType.Name + ")";
                var nodeInfo = AttributeUtility.GetAttribute<NodeInfoAttribute>(targetType, false) ?? new NodeInfoAttribute();
                m_TargetContent = new GUIContent(target.name + m_TargetType, null, nodeInfo.description);
                m_TargetIconContent = new GUIContent(IconUtility.GetIcon(targetType));

                // Update Values
                m_SerializedNode.Update();
            }

            // The serialized node is not null?
            if (m_SerializedNode != null) {
                // Draw node title
                this.DrawTitle();

                if (m_Target != null && BehaviourWindow.IsVisible(m_Target.instanceID)) {
                    // Draw node properties
                    this.OnInspectorGUI();

                    // Update target content?
                    if (Event.current.type == EventType.Used && m_Target != null) {
                        m_TargetContent.text = m_Target.name + m_TargetType;
                    }
                }
            }
        }