Пример #1
0
 public static void AddVarToFsm(BTFsm owner, BTVariable variable)
 {
     if (BTEditorWindow.HasPrefab(owner))
     {
         if (owner.template == null)
         {
             AddTemplateToFsm(owner);
             owner.template.startEvent = owner.startEvent;
             owner.template.totalEvent = owner.totalEvent;
         }
         if (owner.template.totalVariable == null)
         {
             owner.template.totalVariable = new List <BTVariable>();
         }
         owner.template.totalVariable.Add(variable);
         BTEditorWindow.AddObjectToAsset(variable, owner.template);
         EditorUtility.SetDirty(owner);
     }
     else
     {
         if (owner.template != null)
         {
             owner.template.totalVariable.Add(variable);
             BTEditorWindow.AddObjectToAsset(variable, owner.template);
         }
         EditorUtility.SetDirty(owner);
     }
 }
Пример #2
0
 public static void AddStateToFsm(BTFsm owner, BTState targetState)
 {
     if (BTEditorWindow.HasPrefab(owner))
     {
         if (owner.template == null)
         {
             AddTemplateToFsm(owner);
             owner.template.startEvent = owner.startEvent;
             owner.template.totalEvent = owner.totalEvent;
             if (owner.template.totalState == null)
             {
                 owner.template.totalState = new List <BTState>();
             }
         }
         BTEditorWindow.AddObjectToAsset(targetState, owner.template);
         owner.template.totalState.Add(targetState);
         EditorUtility.SetDirty(owner);
     }
     else if (owner.template != null)
     {
         owner.template.totalState.Add(targetState);
         BTEditorWindow.AddObjectToAsset(targetState, owner.template);
         EditorUtility.SetDirty(owner.template);
     }
 }
Пример #3
0
 public override void OnXGUI()
 {
     base.OnXGUI();
     DoButton("Open In EditorWindow", () =>
     {
         BTEditorWindow.InitWindow <BTEditorWindow>();
         BTEditorWindow.target = target as BTFsm;
     });
 }
Пример #4
0
        public static void AddTemplateToFsm(BTFsm fsm)
        {
            fsm.template = BTTemplate.Create(fsm);
            /// Set Labels
            var labels = AssetDatabase.GetLabels(fsm.gameObject).ToList();

            if (labels.Contains("BTFsm") == false)
            {
                labels.Add("BTFsm");
                AssetDatabase.SetLabels(fsm.gameObject, labels.ToArray());
            }

            BTEditorWindow.AddObjectToAsset(fsm.template, fsm.gameObject);
            EditorUtility.SetDirty(fsm);
        }
Пример #5
0
        public static void AddActionToState(BTState Owner, BTAction action)
        {
            var Fsm = Owner.Owner;

            if (BTEditorWindow.HasPrefab(Fsm))
            {
                if (Fsm.template == null)
                {
                    AddTemplateToFsm(Fsm);
                    Fsm.template.startEvent = Fsm.startEvent;
                    Fsm.template.totalEvent = Fsm.totalEvent;
                }
                BTEditorWindow.AddObjectToAsset(action, Owner);
            }
            EditorUtility.SetDirty(Fsm);
        }
Пример #6
0
        public static void AddActionToState(BTState Owner, BTAction action)
        {
            var Fsm = Owner.Owner;

            if (BTEditorWindow.HasPrefab(Fsm))
            {
                if (Fsm.template == null)
                {
                    Fsm.template = XScriptableObject.CreateInstance <BTTemplate> ();
                    BTEditorWindow.AddObjectToAsset(Fsm.template, Fsm.gameObject);
                    EditorUtility.SetDirty(Fsm);
                    Fsm.template.startEvent = Fsm.startEvent;
                    Fsm.template.totalEvent = Fsm.totalEvent;
                }
                BTEditorWindow.AddObjectToAsset(action, Owner);
            }
            EditorUtility.SetDirty(Fsm);
        }
Пример #7
0
 public void OpenScript()
 {
     BTEditorWindow.OpenTypeScript(BtState.GetType());
 }