public static string Gen(string className, string context, ECSSystemGenerateType type, string componentName = null) { CodeWriter writer = new CodeWriter(true); if (type < ECSSystemGenerateType.GroupExecute) { writer.Write($"public class {className} : ECS.Core.I{type}System"); using (new CodeWriter.Scop(writer)) { writer.Write($"{context}Context context;").NewLine(); writer.Write($"public {className}({context}Context context)"); using (new CodeWriter.Scop(writer)) { writer.Write("this.context = context;"); } writer.Write($"public void On{type}()"); writer.EmptyScop(); } } else if (type == ECSSystemGenerateType.GroupExecute) { GenGroupExecuteSystem(writer, className, context, componentName); } else if (type == ECSSystemGenerateType.ReactiveExecute) { GenReactiveExecuteSystem(writer, className, context, componentName); } return(writer.ToString()); }
private void DrawCreateSystem() { using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("系统类型"); systemType = (ECSSystemGenerateType)EditorGUILayout.EnumPopup(systemType); } if (systemType >= ECSSystemGenerateType.GroupExecute && componentTypes != null) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("指定组件类型"); componentSelectIdx = EditorGUILayout.Popup(componentSelectIdx, componentTypes); } } GUILayout.Label("输入需要创建的System的名字 : ", EditorStyles.boldLabel); DrawNameInput(); GUILayout.Label("为了防止多个Context有重名的System,创建时会自动加上Context的名字做前缀,加上System做后缀和组件类名做区分", EditorStyles.wordWrappedLabel); }