public SerializedBehaviorTreeNode([NotNull] SerializedBehavior_Base dependedSerializedBehavior,
                                          [NotNull] SerializedBehaviorTreeGraph treeGraph)
        {
            m_dependedSerializedBehavior = dependedSerializedBehavior;
            m_treeGraph = treeGraph;

            Type type = m_dependedSerializedBehavior.serializedBehaviorType;

            title         = TypeHelper.GetUIName(type);
            m_isComposite = type.IsSubclassOf(typeof(Composite));

            Port input = InstantiatePort(Orientation.Horizontal, Direction.Input, Port.Capacity.Single,
                                         typeof(BehaviorConnection));

            input.portName = "Parent";
            inputContainer.Add(input);

            if (m_isComposite)
            {
                var addButton = new Button(AddOutputPortAndNotify)
                {
                    text = "+"
                };
                titleButtonContainer.Add(addButton);
            }

            UIElementsHelper.CreatePropertyElements(new SerializedObject(m_dependedSerializedBehavior),
                                                    extensionContainer);
        }
        private SerializedBehaviorTreeNode FindNode([NotNull] SerializedBehavior_Base serializedBehavior)
        {
            for (int i = 0, count = m_nodes.Count; i < count; ++i)
            {
                SerializedBehaviorTreeNode node = m_nodes[i];

                if (node.dependedSerializedBehavior == serializedBehavior)
                {
                    return(node);
                }
            }

            return(null);
        }
Пример #3
0
        private void ValidateNulls()
        {
            for (int i = 0; i < m_SerializedBehaviorData.Length; ++i)
            {
                SerializedBehaviorData  serializedBehaviorData = m_SerializedBehaviorData[i];
                SerializedBehavior_Base serializedBehavior     = serializedBehaviorData.serializedBehavior;

                if (serializedBehavior == null)
                {
                    RemoveBehavior(i);
                    --i;
                }
            }
        }
Пример #4
0
        private void ValidateDependedAssets()
        {
            for (int i = 0; i < m_SerializedBehaviorData.Length; ++i)
            {
                SerializedBehavior_Base serializedBehavior = m_SerializedBehaviorData[i].serializedBehavior;
                string path      = UnityEditor.AssetDatabase.GetAssetPath(serializedBehavior);
                Object mainAsset = UnityEditor.AssetDatabase.LoadMainAssetAtPath(path);

                if (mainAsset == null || mainAsset == this)
                {
                    continue;
                }

                RemoveBehavior(i);
                --i;
            }
        }
Пример #5
0
        private void ValidateCopies()
        {
            for (int i = 0; i < m_SerializedBehaviorData.Length; ++i)
            {
                SerializedBehaviorData  serializedBehaviorData = m_SerializedBehaviorData[i];
                SerializedBehavior_Base serializedBehavior     = serializedBehaviorData.serializedBehavior;

                bool copy = false;

                for (int behaviorIndex = 0; behaviorIndex < i & !copy; ++behaviorIndex)
                {
                    copy = serializedBehavior == m_SerializedBehaviorData[behaviorIndex].serializedBehavior;
                }

                if (copy)
                {
                    RemoveBehavior(i);
                    --i;
                }
            }
        }