public static void AddVarToFsm(BTFsm owner, BTVariable variable) { if (BTEditorWindow.HasPrefab(owner)) { if (owner.template == null) { owner.template = XScriptableObject.CreateInstance <BTTemplate>(); BTEditorWindow.AddObjectToAsset(owner.template, owner.gameObject); EditorUtility.SetDirty(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 BTTemplate Create(BTFsm source) { var template = XScriptableObject.CreateInstance <BTTemplate>(); template.name = source.name; return(template); }
public static void AddStateToFsm(BTFsm owner, BTState targetState) { if (BTEditorWindow.HasPrefab(owner)) { if (owner.template == null) { owner.template = XScriptableObject.CreateInstance <BTTemplate>(); BTEditorWindow.AddObjectToAsset(owner.template, owner.gameObject); EditorUtility.SetDirty(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 static BTState Create(BTFsm parentFsm, System.Type type) { var newState = XScriptableObject.CreateInstance(type) as BTState; newState.Owner = parentFsm; parentFsm.AddNewState(newState); return(newState); }
public static BTState Create <T>(BTFsm parentFsm) where T : BTState { var newState = XScriptableObject.CreateInstance <T>(); newState.Owner = parentFsm; parentFsm.AddNewState(newState); return(newState); }
public static T CreateAction <T>(BTState parentState) where T : BTAction { var action = XScriptableObject.CreateInstance <T>(); action.Owner = parentState; parentState.totalActions.Add(action); return(action); }
public static void Save(XScriptableObject asset) { if (!Application.isPlaying) { System.Type type = Reflection.XReflectionUtils.GetEditorType("wuxingogo.Editor.XScriptObjectEditor"); var method = type.GetMethod("Save"); method.Invoke(null, new object[] { asset }); } }
public static BTVariable CreateVariable(Type type, BTFsm parentFsm) { BTVariable variable = XScriptableObject.CreateInstance(type) as BTVariable; variable.Name = type.Name; variable.Owner = parentFsm; parentFsm.totalVariable.Add(variable); AddVarToFsm(parentFsm, variable); return(variable); }
public static BTAction CreateAction(Type type, BTState parentState) { BTAction action = XScriptableObject.CreateInstance(type) as BTAction; action.Name = type.Name; action.Owner = parentState; parentState.totalActions.Add(action); AddActionToState(parentState, action); return(action); }
private void SaveTemplate(XBezierArrow script) { XBezierArrowTemplate template = XScriptableObject.Create <XBezierArrowTemplate>(null); template.Save(script); template.SaveInEditor(); // string path = AssetsUtilites.SaveFilePanel( "XBezierArrow Save Template", XEditorSetting.ProjectPath, script.gameObject.name + ".asset", "asset", true ); // if( path == "" ) // return; // // path = FileUtil.GetProjectRelativePath( path ); // // XBezierArrowTemplate template = XScriptableObject.Create<XBezierArrowTemplate>(); // template.Save (script); // AssetDatabase.CreateAsset( template, path ); // AssetDatabase.SaveAssets(); }
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 static void Save(XScriptableObject @object) { if (@object.hasFile) { EditorUtility.SetDirty(@object); } else { var type = @object.GetType(); string path = AssetsUtilites.SaveFilePanel(type.Name, XEditorSetting.PluginPath, @object.name + ".asset", "asset", true); if (path == "") { return; } path = FileUtil.GetProjectRelativePath(path); @object.hasFile = true; AssetDatabase.CreateAsset(@object, path); AssetDatabase.SaveAssets(); } }
public static void Create( XScriptableObject @object, Object parent = null ) { XLogger.Log( "OnCreate in XScriptableEditor" ); AssetDatabase.SetLabels( @object, new string[] { "XScriptObject" } ); AssetDatabase.AddObjectToAsset( @object, parent ); }
public static void AddObjectToAsset(XScriptableObject lhs, Object rhs) { lhs.hideFlags = isHide ? HideFlags.HideInHierarchy : HideFlags.None; AssetDatabase.SetLabels(lhs, new string[] { "BTFsm" }); AssetDatabase.AddObjectToAsset(lhs, rhs); }
public static void Create(XScriptableObject @object, Object parent) { XLogger.Log("OnCreate in XScriptableEditor"); AssetDatabase.SetLabels(@object, new string[] { "XScriptObject" }); AssetsUtilites.AddObjectToAsset(@object, parent); }
public static TSource Create() { TSource obj = XScriptableObject.CreateInstance <TSource>(); return(obj); }