private void AppendBody(StringAppender appender, YuScriptCreateSetting setting) { var nameSpace = setting.NameSpace; appender.AppendLine("namespace " + nameSpace); appender.AppendLine("{"); appender.ToRight(); var scriptId = setting.ScriptId; var inheritText = setting.IsAotuCreateInterface ? ": I" + scriptId : null; switch (setting.inherits) { case Inherits.Class: TryAppendAotuInterface(appender, setting); appender.AppendLine($"public class {scriptId} {inheritText}"); break; case Inherits.AbstractClass: TryAppendAotuInterface(appender, setting); appender.AppendLine($"public abstract class {scriptId} {inheritText}"); break; case Inherits.Enum: appender.AppendLine($"public enum {scriptId} : byte"); break; case Inherits.Interface: appender.AppendLine($"public interface {scriptId}"); break; default: throw new ArgumentOutOfRangeException(); } if (!string.IsNullOrEmpty(setting.Inherit) && setting.inherits != Inherits.Enum) { appender.Append(" : " + setting.Inherit); } appender.AppendLine("{"); appender.AppendLine("}"); appender.ToLeft(); appender.AppendLine("}"); appender.AppendLine(); if (!string.IsNullOrEmpty(setting.PreComplie)) { appender.AppendLine("#endif"); } }
private void CreateScript() { Appender.Clean(); //Appender.AppendLine($"#if {u3DAppSetting.LocAppId}Play"); Appender.AppCsNoteHeader(); Appender.AppendUsingNamespace( "Client.LegoUI", "UnityEngine", "YuU3dPlay" ); Appender.AppendSingleComment("在这里处理UI的生命周期!"); //Appender.AppendLine($"namespace {u3DAppSetting.LocAppId}Play"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine($"public class {ClassId} : IYuLegoUIPipelineHandler"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine($"public string UiId => \"{uiRect.name}\";"); Appender.AppendLine($"public YuUIPipelineType PipelineType => " + $"YuUIPipelineType.{pipelineType};"); Appender.AppendLine(); Appender.AppendLine($"public void Execute(IYuLegoUI legoUI)"); Appender.AppendLine("{"); Appender.ToRight(); Appender.AppendLine("#if UNITY_EDITOR"); Appender.AppendLine($"Debug.Log(\"{ClassId} is Invoked!\");"); Appender.AppendLine("#endif"); Appender.ToLeft(); Appender.AppendLine("}"); Appender.AppendCsFooter(); Appender.AppendLine("#endif"); //var developerId = YuU3dAppSettingDati.CurrentActual.CurrentDeveloper.Name; //var path = u3DAppSetting.Helper.CsLegoUIDir + developerId + "/" // + GetUITypeDir() + "/" + uiRect.name + "/LogicCode/LogicAndPipeline/" // + ClassId + ".cs"; //var codeContent = Appender.ToString(); //YuIOUtility.TryWriteAllText(path, codeContent); }