Ejemplo n.º 1
0
    private void DrawSelectDrawer()
    {
        int selected  = _drawers.IndexOf(_selectedDrawer);
        int nSelected = EditorGUILayout.Popup(selected, _drawers.ToArray(), GUILayout.Width(165));

        if (nSelected != selected)
        {
            _selectedDrawer = _drawers[nSelected];
            _drawer         = (IBTElementDrawer)Activator.CreateInstance(Type.GetType(_selectedDrawer));
            _drawer.SetDecoratorsList(_decoratorTypes);
            PlayerPrefs.SetString("BTElementDrawer", _selectedDrawer);
            PlayerPrefs.Save();
        }
    }
Ejemplo n.º 2
0
    void Init()
    {
        EditorState[] stateValues  = (EditorState[])Enum.GetValues(typeof(EditorState));
        int           currentState = PlayerPrefs.GetInt("BTEditorState", 0);

        _state          = stateValues[currentState];
        _selectedDrawer = PlayerPrefs.GetString("BTElementDrawer", "BTWindowsDrawer");
        _autosave       = PlayerPrefs.GetInt("BTAutosave", 0) == 1;

        Type drawerType = Type.GetType(_selectedDrawer);

        if (drawerType == null)
        {
            drawerType = Type.GetType("BTSimpleDrawer");
        }
        _drawer = (IBTElementDrawer)Activator.CreateInstance(Type.GetType(_selectedDrawer));

        Assembly ass = Assembly.GetAssembly(typeof(BehaviorTree));

        Type[]      allTypes = ass.GetTypes();
        List <Type> types    = new List <Type>(allTypes);
        Assembly    ass2     = Assembly.GetAssembly(typeof(BehaviorTreeEditor));

        types.AddRange(ass2.GetTypes());
        allTypes = types.ToArray();

        //Fill drawers info and methods list
        foreach (Type t in allTypes)
        {
            if (t.IsInterface || t.GetInterface("INode") != null || t.FullName.Contains("+"))
            {
                continue;
            }
            else
            {
                if (t.GetInterface("IBTElementDrawer") != null)
                {
                    _drawers.Add(t.Name);
                }
            }
        }

        //General settings
        BTEditorWindow.titleContent.text = "BT Editor";
        Rect windowRect = new Rect(50.0f, 50.0f, 1000.0f, 800.0f);

        BTEditorWindow.position      = windowRect;
        BTEditorWindow._behaviorTree = null;
        BTEditorWindow.minSize       = new Vector2(800, 600);

        //Fill decorator type list
        Array dt = Enum.GetValues(typeof(DecoratorType));

        foreach (DecoratorType dtv in dt)
        {
            _decoratorTypes.Add(dtv.ToString());
        }

        _drawer.SetDecoratorsList(_decoratorTypes);
        Selection.selectionChanged += SelectionChanged;

        SelectionChanged();
    }
Ejemplo n.º 3
0
    void Init()
    {
        EditorState[] stateValues = (EditorState[])Enum.GetValues(typeof(EditorState));
        int currentState = PlayerPrefs.GetInt("BTEditorState", 0);
        _state = stateValues[currentState];
        _selectedDrawer = PlayerPrefs.GetString("BTElementDrawer", "BTWindowsDrawer");
        _autosave = PlayerPrefs.GetInt("BTAutosave", 0) == 1;

        Type drawerType = Type.GetType(_selectedDrawer);
        if(drawerType == null)
        {
            drawerType = Type.GetType("BTSimpleDrawer");
        }
        _drawer = (IBTElementDrawer)Activator.CreateInstance(Type.GetType(_selectedDrawer));

        Assembly ass = Assembly.GetAssembly(typeof(BehaviorTree));
        Type[] allTypes = ass.GetTypes();
        List<Type> types = new List<Type>(allTypes);
        Assembly ass2 = Assembly.GetAssembly(typeof(BehaviorTreeEditor));
        types.AddRange(ass2.GetTypes());
        allTypes = types.ToArray();

        //Fill drawers info and methods list
        foreach(Type t in allTypes)
        {
            if (t.IsInterface || t.GetInterface("INode") != null || t.FullName.Contains("+"))
            {
                continue;
            }
            else
            {
                if (t.GetInterface("IBTElementDrawer") != null)
                {
                    _drawers.Add(t.Name);
                }
            }
        }

        //General settings
        BTEditorWindow.titleContent.text = "BT Editor";
        Rect windowRect = new Rect(50.0f, 50.0f, 1000.0f, 800.0f);
        BTEditorWindow.position = windowRect;
        BTEditorWindow._behaviorTree = null;
        BTEditorWindow.minSize = new Vector2(800, 600);

        //Fill decorator type list
        Array dt = Enum.GetValues(typeof(DecoratorType));
        foreach (DecoratorType dtv in dt)
        {
            _decoratorTypes.Add(dtv.ToString());
        }

        _drawer.SetDecoratorsList(_decoratorTypes);
        Selection.selectionChanged += SelectionChanged;

        SelectionChanged();
    }
Ejemplo n.º 4
0
 private void DrawSelectDrawer()
 {
     int selected = _drawers.IndexOf(_selectedDrawer);
     int nSelected = EditorGUILayout.Popup(selected, _drawers.ToArray(), GUILayout.Width(165));
     if(nSelected != selected)
     {
         _selectedDrawer = _drawers[nSelected];
         _drawer = (IBTElementDrawer)Activator.CreateInstance(Type.GetType(_selectedDrawer));
         _drawer.SetDecoratorsList(_decoratorTypes);
         PlayerPrefs.SetString("BTElementDrawer", _selectedDrawer);
         PlayerPrefs.Save();
     }
 }