void OpenInGenerateCodeWindow() { wuxingogo.Code.CodeGenerateEditor codeEditor = InitWindow <wuxingogo.Code.CodeGenerateEditor>(); wuxingogo.Code.XCodeObject codeObject = codeEditor.GenerateNewCode(); wuxingogo.Code.XCodeClass classUnit = codeObject.classUnit; classUnit.name = Target.GetType().Name; var type = Target.GetType(); foreach (var item in type.GetMethods()) { classUnit.methods.Add(new wuxingogo.Code.XCodeMethod() { name = item.Name, type = new wuxingogo.Code.XCodeType(item.ReturnType), }); } foreach (var item in type.GetProperties()) { classUnit.properties.Add(new wuxingogo.Code.XCodeProperty() { name = item.Name, type = new wuxingogo.Code.XCodeType(item.PropertyType) }); } foreach (var item in type.GetFields()) { classUnit.fields.Add(new wuxingogo.Code.XCodeField() { name = item.Name, type = new wuxingogo.Code.XCodeType(item.FieldType) }); } }
public override void OnXGUI() { if (null != codeObject) { DoButton <XCodeObject>("SaveTemplate", SaveTemplete, codeObject); DoButton("Clean", () => codeObject = null); DoButton("Compile", Compile); DoButton("Help MemberAttributes", () => { for (int i = 0; i <= 61440; i++) { XLogger.Log(Enum.ToObject(typeof(MemberAttributes), i).ToString()); } }); codeObject.Draw(this); } else { if (CreateSpaceButton("Create")) { GenerateNewCode(); } DoButton("OpenTemplate", () => codeObject = OpenTemplate()); } }
XCodeObject OpenTemplate() { string path = EditorUtility.OpenFilePanel("Open A Template", XEditorSetting.PluginPath, ""); if (path == "") { return(null); } path = FileUtil.GetProjectRelativePath(path); XCodeObject co = AssetDatabase.LoadAssetAtPath <XCodeObject>(path); return(co); }
public override void OnXGUI() { if (null != codeObject) { DoButton <ScriptableObject>("SaveTemplate", SaveTemplete, codeObject); DoButton("Clean", () => codeObject = null); DoButton("Compile", Compile); codeObject.Draw(this); } else { if (CreateSpaceButton("Create")) { GenerateNewCode(); } DoButton("OpenTemplate", () => codeObject = OpenTemplate()); } }
void SaveTemplete(XCodeObject so) { if (so.isFile) { EditorUtility.SetDirty(so); } else { string path = EditorUtility.SaveFilePanel("Create A Templete", XEditorSetting.PluginPath, codeObject.className + ".asset", "asset"); if (path == "") { return; } path = FileUtil.GetProjectRelativePath(path); so.isFile = true; AssetDatabase.CreateAsset(so, path); AssetDatabase.SaveAssets(); } }
public override void OnXGUI() { if( null != codeObject ) { DoButton<XCodeObject>( "SaveTemplate", SaveTemplete, codeObject ); DoButton( "Clean", () => codeObject = null ); DoButton("Compile", Compile); DoButton("Help MemberAttributes", () => { for (int i = 0; i <= 61440; i++) { XLogger.Log(Enum.ToObject(typeof(MemberAttributes), i).ToString()); } }); codeObject.Draw( this ); } else { if(CreateSpaceButton("Create")){ GenerateNewCode(); } DoButton( "OpenTemplate", () => codeObject = OpenTemplate() ); } }
public XCodeObject GenerateNewCode() { codeObject = ScriptableObject.CreateInstance <XCodeObject>(); return(codeObject); }
void SaveTemplete(XCodeObject so) { if (so.isFile) { EditorUtility.SetDirty(so); } else { string path = EditorUtility.SaveFilePanel("Create A Templete", XEditorSetting.ProjectPath, codeObject.className + ".asset", "asset"); if (path == "") return; path = FileUtil.GetProjectRelativePath(path); so.isFile = true; AssetDatabase.CreateAsset(so, path); AssetDatabase.SaveAssets(); } }
public XCodeObject GenerateNewCode() { codeObject = ScriptableObject.CreateInstance<XCodeObject>(); return codeObject; }