void SaveTemplate() { IList fsmStates = FSM.FsmStates <XFsmStateComponent>(); XTemplateComponent sc = XTemplateComponent.Create(); string path = EditorUtility.SaveFilePanel("Create A Templete", XEditorSetting.ProjectPath, "123" + ".asset", "asset"); if (path == "") { return; } path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(sc, path); for (int pos = 0; pos < fsmStates.Count; pos++) { // TODO loop in fsmStateS.Count XFsmStateComponent state = fsmStates[pos] as XFsmStateComponent; Debug.Log("pos is : " + pos); state.name = state.GetType().ToString(); AssetDatabase.AddObjectToAsset(state, path); } // Refresh/Reimport AssetDatabase.Refresh(); AssetDatabase.ImportAsset(path); AssetDatabase.SaveAssets(); }
public XFsmStateWindow(XFsmStateComponent state) { this.state = state; }