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); } }
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); } }
public override void OnXGUI() { base.OnXGUI(); DoButton("Open In EditorWindow", () => { BTEditorWindow.InitWindow <BTEditorWindow>(); BTEditorWindow.target = target as BTFsm; }); }
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); }
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); }
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); }
public void OpenScript() { BTEditorWindow.OpenTypeScript(BtState.GetType()); }