Exemple #1
0
    private void LoadBT()
    {
        string absPath = EditorUtility.OpenFilePanel("Select a Behaviour Tree...", Application.dataPath, "asset");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            bt = (BehaviourTreeEditor)AssetDatabase.LoadAssetAtPath(relPath, typeof(BehaviourTreeEditor));

            if (bt != null && bt.nodes == null)
            {
                bt.nodes = new List <BaseNodeEditor> ();
                EditorPrefs.SetString("AssetPath", relPath);
            }
            root = null;
        }
        Debug.Log("BT Loaded!");
    }
 public override void PrintGUIElement(BehaviourTreeEditor src)
 {
     //EditorGUILayout.BeginHorizontal();
     //GUILayout.Button(this.GetName());
     if (GUILayout.Button((this.GetParent() == null ? "" : "Parent: " + this.GetParent().GetName() + "                ")
                          + this.GetName() + (src.currentNode == this ? "***" : "")
                          + (m_isSequence == true ? "       Sequence" : "           Selector")))//if (GUILayout.Button(indentationString + this.GetName() + (src.currentNode == this ? "***" : "")))
     {
         src.currentNode = this;
     }
     //EditorGUILayout.EndHorizontal();
     foreach (Node current in m_children)
     {
         //EditorGUILayout.BeginHorizontal();
         current.PrintGUIElement(src);
     }
     //EditorGUILayout.EndHorizontal();
 }
Exemple #3
0
    private bool Initialize()
    {
        Editor = BehaviourTreeEditor.GetInstance();
        if (!Editor)
        {
            EditorGUILayout.HelpBox("Unable to get BehaviourTreeEditor instance!", MessageType.Error);
            return(false);
        }

        Parameters = Editor.GetCurrentAsset().Parameters;

        if (!Editor.CanEditNode(Node))
        {
            EditorGUILayout.HelpBox("Unable to edit this node!", MessageType.Error);
            return(false);
        }

        return(true);
    }
Exemple #4
0
    void OnEnable()
    {
        if (EditorPrefs.HasKey("AssetPath") && File.Exists(EditorPrefs.GetString("AssetPath")))
        {
            string assetPath = EditorPrefs.GetString("AssetPath");
            bt = (BehaviourTreeEditor)AssetDatabase.LoadAssetAtPath(assetPath, typeof(BehaviourTreeEditor));
            if (bt != null && bt.nodes == null)
            {
                bt.nodes = new List <BaseNodeEditor> ();
            }

            if (bt != null && bt.nodes.Count > 0)
            {
                root = bt.nodes [0];
            }
        }


        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();
    }
    private bool Initialize(ref Rect position, SerializedProperty property, GUIContent label)
    {
        position.height = base.GetPropertyHeight(property, label);

        Editor = BehaviourTreeEditor.GetInstance();
        if (!Editor)
        {
            EditorGUI.HelpBox(position, "Unable to get BehaviourTreeEditor instance!", MessageType.Error);
            return(false);
        }

        Parameters = Editor.GetCurrentAsset().Parameters.Where(p => p.HoldType.Type == fieldInfo.FieldType).ToList();

        AsNode = (BehaviourTreeNode)property.serializedObject.targetObject;

        Typename = GenericParameter.GetDisplayedName(fieldInfo.FieldType);
        if (Typename == null)
        {
            EditorGUI.HelpBox(position, string.Format("Type {0} is not a known type!", fieldInfo.FieldType), MessageType.Error);
            return(false);
        }

        if (!Editor.CanEditNode(AsNode))
        {
            EditorGUI.HelpBox(position, "Unable to edit this node!", MessageType.Error);
            return(false);
        }

        if (!(attribute is Blackboard.Required))
        {
            EditorGUI.HelpBox(position, "Unable to get Required attribute!", MessageType.Error);
            return(false);
        }

        SetContentForParameters();

        return(true);
    }
Exemple #6
0
 public override void PrintGUIElement(BehaviourTreeEditor src)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
 public abstract void PrintGUIElement(BehaviourTreeEditor src);