private void DrawRenderer() // Renderer { m_Tools.BiaoTi_O("Renderer 结构图"); MyCreate.Box_Hei(() => { m_Tools.Text_B("Object -> Component", "(附加到 GameObject 的组件)".AddHui(), " -> Renderer"); m_Tools.TextText_BY(" Renderer -> SkinnedMeshRenderer" + ONE, "带动画的 Mesh", 90); m_Tools.TextText_BY(" Renderer -> MeshRenderer" + TWO, "静态物体的 Mesh", 90); m_Tools.TextText_BY(" Renderer -> LineRenderer" + THREE, "线性," + LOOKATstr, 90); m_Tools.TextText_BY(" Renderer -> TrailRenderer" + FOUR, "拖尾", 90); m_Tools.TextText_BY(" Renderer -> SpriteRenderer" + FIVE, "图", 90); m_Tools.TextText_BG(" Renderer -> BillboardRenderer" + SIX, LOOKATstr, 90); }); AddSpace(); m_Tools.BiaoTi_B("回调函数 " + "脚本有 Renderer 组件才触发".AddGreen()); MyCreate.Box(() => { m_Tools.TextText_OY("OnBecameVisible", "Renderer 变成可见时调用"); m_Tools.TextText_OY("OnBecameInvisible", "Renderer 在" + "任何相机不再可见".AddGreen() + "的情况下调用"); }); AddSpace(); TheSameMainBan(); }
//——————————————————行为—————————————————— private void XingWeiOther() // 行为其他 { AddSpace(); m_Tools.BiaoTi_B("解释器模式"); AddSpace(); m_Tools.BiaoTi_B("访问者模式"); m_Tools.Text_H("想不到那里会需要这模式"); AddSpace(); m_Tools.BiaoTi_B("备忘录模式"); m_Tools.Text_H("就是 数据Bean,然后写多一个类来记录这个 数据Bean"); AddSpace(); m_Tools.BiaoTi_B("命令模式"); m_Tools.Text_H("就是将一个方法封装成对象来调用"); m_Tools.Text_H("类巨多,不喜欢"); AddSpace(); m_Tools.BiaoTi_B("模板方法模式"); m_Tools.BiaoTi_L("动机、意图、何时用" + "(这个模式简单、常用)".AddGreen()); MyCreate.Box(() => { m_Tools.Text_R("就是把父类定义成一个模板,给子类实现"); m_Tools.Text_H("一次性实现一个算法的不变的部分,并将可变的行为留给子类来实现"); m_Tools.Text_H("各子类中公共的行为应被提取出来并集中到一个公共父类中以避免代码重复"); }); AddSpace(); m_Tools.BiaoTi_B("中介者模式"); ShowImage("https://images2018.cnblogs.com/blog/959112/201807/959112-20180709225152340-1096691406.png", 15); }
private void DrawHashtable() //Hashtable { m_Tools.ButtonText("Hashtable", "Key不可重复,添加重复报错,取[不存在]null", ref isHashtable, () => { MyCreate.TextCenter("foreach 出来的结果不是按照顺序排列的"); m_Tools.Text_G("1.Key 与 Dictionary 相同不可重复,区分大小写"); m_Tools.Text_G("2.元素存储在DictionaryEntry对象中"); m_Tools.BiaoTi_O("foreach 的使用", ref isForeach, () => { MyCreate.Window("用 DictionaryEntry 对象 声明", () => { m_Tools.Text_Y("foreach ( DictionaryEntry de in hashtable )"); }); AddSpace(); AddSpace(); MyCreate.Window("用 key/value 对象 声明", () => { m_Tools.Text_Y("foreach ( Object key in hashtable.Keys )"); }); }); m_Tools.BiaoTi_O("方法", true); MyCreate.Box(() => { m_Tools.Method_YG("Add", "Object,Object", "添加"); m_Tools.Method_YG("Remove", "Object key", "根据 key 来删除"); m_Tools.Method_YG("ContainsKey", "Object key", "key 是否包含"); m_Tools.Method_YG("ContainsValue", "Object Value", "Value 是否包含"); }); }, -60); }
//——————————————————创建—————————————————— private void DrawJianZaoZhe() // 建造者模式 { MyCreate.Text("建造者模式与工厂模式结合:"); MyCreate.Box_Hei(() => { m_Tools.Text_H("public class ", JianGongLie); m_Tools.Text_H(" private static string ", gnmcStr, " =“", gaStr, "”"); m_Tools.Text_H(" public static ", GongNeng, " ", CreateStr); m_Tools.Text_H(" AssemblyName name = Assembly.GetExecutingAssembly().GetName()"); m_Tools.Text_H(" ", GongNeng, " g =", "(", GongNeng, ") Assembly.Load(name).CreateInstance(", gnmcStr, ")"); m_Tools.Text_H(" g.", "加属性()".AddWhite()); m_Tools.Text_H(" g.", "加武器()".AddWhite()); m_Tools.Text_H(" g.", "加装备()".AddWhite()); m_Tools.Text_H(" return g"); }); MyCreate.Text("实际的功能实现类,要做什么功能就在子类实现"); MyCreate.Box_Hei(() => { m_Tools.Text_H("public abstract class ", GongNeng); m_Tools.Text_H(" public abstract void ", "加属性()".AddWhite()); m_Tools.Text_H(" public abstract void ", "加武器()".AddWhite()); m_Tools.Text_H(" public abstract void ", "加装备()".AddWhite()); }); MyCreate.Box(() => { m_Tools.Text_H("public class ", gaStr, " : ", GongNeng, " { ", "实现加属性、加武器、加装备".AddWhite(), " } "); m_Tools.Text_H("public class 功能B : ", GongNeng, " { ", "实现加属性、加武器、加装备".AddWhite(), " } "); }); MyCreate.Text("客户端只需要改变 " + gnmcStr + " 里面的类名称即可"); MyCreate.Box_Hei(() => { m_Tools.TextText_HG(GongNeng + " g = " + JianGongLie + "." + CreateStr, "// 工厂类已经是 Static 方法"); }); }
private void DrawGongChang() // 工厂模式 { m_Tools.BiaoTi_B("工厂模式"); MoBan(() => { m_Tools.Text_R("比如一开始用这个功能类 A,过段时间又要用相同结构的功能类 B,或者再来个 C"); m_Tools.Text_W("隔离”这个易变对象“的变化,保持”其它依赖的对象“不随需求的变化而变化"); }, () => { MyCreate.Text("客户端就和工厂类打交道,不会与实际实现类有任何交互"); MyCreate.Box_Hei(() => { m_Tools.Text_H("public abstract class ", GongJiLie); m_Tools.Text_H(" public abstract 功能基类 ", CreateStr); }); MyCreate.Box(() => { m_Tools.Text_H("public class", " 功能A的工厂".AddRed(), ": ", GongJiLie); m_Tools.Text_H(" public override 功能基类 ", CreateStr); m_Tools.Text_H(" return new 功能A();"); }); MyCreate.Box(() => { m_Tools.Text_H("public class 功能B的工厂 : ", GongJiLie); m_Tools.Text_H(" public override 功能基类 ", CreateStr); m_Tools.Text_H(" return new 功能B();"); }); MyCreate.Text("实际的功能实现类,要做什么功能就在子类实现"); MyCreate.Box_Hei(() => { m_Tools.Text_H("public abstract class ", GongNeng, " { ... } "); }); MyCreate.Box(() => { m_Tools.Text_H("public class 功能A : ", GongNeng, " { ... } "); m_Tools.Text_H("public class 功能B : ", GongNeng, " { ... } "); }); MyCreate.Text("客户端只需要改变 方法名" + gAStr + " 即可改变对应的功能"); MyCreate.Box_Hei(() => { m_Tools.Text_H("AssemblyName name = Assembly.GetExecutingAssembly().GetName()"); m_Tools.Text_H(GongJiLie, " f = (", GongJiLie, ") Assembly.Load(name).CreateInstance", gAStr); m_Tools.Text_H(GongNeng, " g = f.", CreateStr); m_Tools.Text_G("// 这时的”g“已经是想要的类了,想调用那个方法就调用那个方法叭"); }); }, () => { MyCreate.Text("1. 工厂模式 -> 利用工厂 -> 创建想要的对象"); MyCreate.Text("2. 如增加一个 C 功能类并使用:增加功能C的工厂、功能C、客户端调用”功能C的工厂“".AddRed()); MyCreate.Text(" 优点:原来的功能代码不需要更改,隔离了使用者和具体类型之间的耦合关系"); MyCreate.Text(" 缺点:每加一个功能就需要加一个功能的工厂类"); }); AddSpace_3(); m_Tools.BiaoTi_L("UML 图", ref isUML1, () => { ShowImage("https://images2018.cnblogs.com/blog/959112/201807/959112-20180709223754285-530795452.png"); }); AddSpace(); DrawChuXiang(); }
private void DrawMiMa() // 网站密码 { MyCreate.Text("博客园:"); m_Tools.TextSelectText_B("账号", "泡水泡"); m_Tools.TextSelectText_B("密码(最后有个点)", "nan729611611."); AddSpace_3(); MyCreate.Text("CSDN:"); m_Tools.TextSelectText_B("账号", "15361253090"); m_Tools.TextSelectText_B("密码(最后有个点)", "nan729611611."); AddSpace_3(); MyCreate.Text("Unity:"); m_Tools.TextSelectText_B("账号", "wwknan"); m_Tools.TextSelectText_B("密码", "nanNAN123"); AddSpace_3(); MyCreate.Text("高通AR :"); m_Tools.TextSelectText_B("账号", "paoshuipao"); m_Tools.TextSelectText_B("密码", "nanNAN123"); AddSpace_3(); MyCreate.Text("Github :"); m_Tools.TextSelectText_B("账号", "paoshuipao"); m_Tools.TextSelectText_B("密码", "nan729611611"); AddSpace_3(); MyCreate.Text("微信小号 :"); m_Tools.SelectTextText_B("13944637913", "abc729611611"); m_Tools.SelectTextText_B("13778664598", "abc729611611"); }
private void DrawRightPage(Texture text, [NotNull] Action page, bool isBox, Action nextButton) // 画任意 右边页面都使用这个 { QUI.Space(5); if (isNeedTu) { QUI.DrawTexture(text, mWindowSettings.CurrentPageContentWidth, 620); QUI.Space(-620); } QUI.Space(2); if (isBox) { MyCreate.Box(page); } else { MyCreate.Box_Hei(page); } MyCreate.AddSpace(); if (null != nextButton) { MyCreate.Heng(() => { MyCreate.AddSpace(); if (GUILayout.Button("", QStyles.GetStyle(Style.LinkButton.Unity), GUILayout.Width(80), GUILayout.Height(20))) { nextButton(); } }); } }
private void DrawMonoBehaviourAPI() // MonoBehaviour API { m_Tools.BiaoTi_O("MonoBehaviour API " + "(就多了 Invoke 和 协程)".AddGreen()); MyCreate.Box_Hei(() => { m_Tools.Text_H("继承 ->" + " Component ".AddOrange() + "(组件基类) ->" + " Behavior ".AddOrange() + "(可启用、禁用)"); }); AddSpace(); MyCreate.MethodWindow(() => { m_Tools.BiaoTi_B("Invoke 调用"); MyCreate.Box(() => { m_Tools.Method_BL("Invoke", "string 方法名,float 几秒调用该方法", ""); m_Tools.Method_BL("InvokeRepeating", "string 方法名,float 几秒调用该方法,float 几秒重复一次", ""); m_Tools.Method_BL("CancelInvoke", "", "取消此 Mono 上的所有Invoke调用"); m_Tools.Method_BL("IsInvoking", "string 方法名", "这个方法是否被 Invoke 调用"); }); AddSpace(); m_Tools.BiaoTi_B("Coroutine 协程"); MyCreate.Box(() => { m_Tools.Text_G("开始协程 ", "StartCoroutine".AddBlue(), " 结束协程", " StopCoroutine".AddBlue()); m_Tools.Text_G("(开始协程与结束协程的参数要一致才能结束)"); m_Tools.Method_BL("StopAllCoroutines", "", "停止所有运行的协程"); }); }); }
private void DrawAudioSource() // AudioSource { m_Tools.GuangFangWenDan("https://docs.unity3d.com/Manual/class-AudioSource.html"); m_Tools.TextText_BL("Audio Clip", "", -20); m_Tools.TextText_BL("Output", "", -20); m_Tools.TextText_BL("Mute", OpenSure + "", -20); m_Tools.TextText_BL("Bypass Effects", OpenSure + "", -20); m_Tools.TextText_BL("Bypass Listener Effects", OpenSure + "", -20); m_Tools.TextText_BL("Bypass Reverb Zones", OpenSure + "", -20); m_Tools.TextText_BL("Play On Awake", OpenSure + "", -20); m_Tools.TextText_BL("Loop", OpenSure + "", -20); m_Tools.TextText_BL("Priority", "", -20); m_Tools.TextText_BL("Volume", "", -20); m_Tools.TextText_BL("Pitch", "", -20); m_Tools.TextText_BL("Stereo Pan", "", -20); m_Tools.TextText_BL("Spatial Blend", "", -20); m_Tools.TextText_BL("Reverb Zone Mix", "", -20); m_Tools.TextText_BL("3D Sound Settings", "", -20); MyCreate.Box_Hei(() => { m_Tools.TextText_WL("Doppler Level", "", -20); m_Tools.TextText_WL("Spread", "", -20); m_Tools.TextText_WL("Volume Relloff", "", -20); m_Tools.TextText_WL("Min Distance", "", -20); m_Tools.TextText_WL("Max Distance", "", -20); }); }
void OnGUI() { GUISkin skin = LoadRes.ResourcesSkin; if (null == skin) { MyLog.Red("未能加载 GUISkin"); return; } GUI.skin = skin; string tittle = Tittle(); bool isNeedWindow = OnIsWindow(); if (isNeedWindow) { MyCreate.Window("", () => { MiddleGUI(tittle); }); } else { MiddleGUI(tittle); } OnEditorGUILast(); }
private void DrwUnityEvent() { m_Tools.BiaoTi_B("说明"); MyCreate.Box(() => { m_Tools.Text_L("• 如: Button 底下的 OnClick 也是使用这个 UnityEvent"); m_Tools.Text_L("• UnityEvent<T0> 是 abstract 类,必须继承才能用"); m_Tools.Text_L("• 一定要添加 ", SerializableStr, " 特性"); }); AddSpace_3(); m_Tools.BiaoTi_B("使用例子"); MyCreate.Box_Hei(() => { MyCreate.Text("1. 想要什么参数就在泛型中添加,直接继承类即可"); m_Tools.Text(SerializableStr); m_Tools.Text_H("public class MyEvent : UnityEvent<int> { }"); MyCreate.Text("2. 在真正的 MonoBehaviour 类中添加字段 即可"); m_Tools.Text(SerializableStr); m_Tools.Text_H("public MyEvent ", myEventStr); }); m_Tools.BiaoTi_B("注册与发送事件"); MyCreate.Box_Hei(() => { MyCreate.Text("注册:"); m_Tools.Text_L(" • 在面板上拖拽"); m_Tools.Text_L(" • ", myEventStr, ".AddListener( 方法 )"); MyCreate.Text("发送事件:"); m_Tools.Text_L(" • ", myEventStr, ".Invoke()"); }); }
#pragma warning restore //———————————————————————————————————— private void DrawUnityAtt() // Unity 的特性 { AddSearch(ref m_Input, l_AllTextAttribute, () => { isInspector = true; isMonoBehaviour = true; isEditorr = true; isSystem = true; }); MyCreate.TextButton(isOpen ? "收缩" : "张开", () => { isOpen = !isOpen; isInspector = isOpen; isMonoBehaviour = isOpen; isEditorr = isOpen; isSystem = isOpen; }); Item("改变 Inspector", ref isInspector, l_Inspector); MyCreate.AddSpace(3); Item("继承MonoBehaviour的组件Class使用", ref isMonoBehaviour, l_Mono); MyCreate.AddSpace(3); Item("Editor", ref isEditorr, l_Editor); MyCreate.AddSpace(3); Item("System", ref isSystem, l_System); }
private void DrawCollider() // Collider { m_Tools.BiaoTi_Y("先说一下 花Q 的注意事项"); MyCreate.Box(() => { m_Tools.Text_B("两两触发的回调事件 :", "OnTriggerEnter/Stay/Exit ".AddGreen()); m_Tools.Text_L(" • 脚本对象必须带上 Rigidbody,Collider 可在子对象"); m_Tools.Text_L(" • Rigidbody 必须勾选 IsKinematic"); m_Tools.Text_G(" • Collider 必须勾选 IsTrigger"); m_Tools.Text_L(" • 被触发的 Collider 可以不勾选 IsTrigger"); }); AddSpace(); m_Tools.BiaoTi_Y("Collider 与 Collision"); MyCreate.Box(() => { m_Tools.Text_B("Collider -> 碰撞体"); MyCreate.Box_Hei(() => { m_Tools.Text_H(" 1. 是 BoxCollider, SphereCollider, CapsuleCollider, MeshCollider 的父类"); m_Tools.Text_H(" 2. Collider ", "继承 <- Component <- Object".AddGreen()); m_Tools.Text_H(" 3. 使用 OnTriggerEnter/Stay/Exi 触发回调的参数是 Collider"); }); m_Tools.Text_B("Collision -> 碰撞信息"); MyCreate.Box_Hei(() => { m_Tools.Text_H(" 1. Collision ", "没有继承".AddGreen(), ",简单类"); m_Tools.Text_H(" 2. 使用 OnCollisionEnter/Stay/Exi 碰撞回调的参数是 Collision"); }); }); }
private void DrawSkinnedMesh() // Skinned Mesh Renderer 带动画的Mesh { m_Tools.BiaoTi_B("Skinned Mesh Renderer" + "(带动画的 Mesh)".AddGreen()); MyCreate.Box(() => { m_Tools.TextText_OY("Quality", "在蒙皮时每个顶点使用的" + "骨骼".AddWhite() + "的最大数量"); MyCreate.Box(() => { m_Tools.TextText("Auto", "自动 (获得所需的动画质量和帧率的平衡)"); m_Tools.TextText("1 2 4 Bone", "骨骼数,数量越多,渲染器的质量就越高"); m_Tools.Text_G("使用四块骨头可以得到最好的结果,但会带来更高的处理开销"); m_Tools.Text_G("游戏通常使用两个骨骼重量,这是视觉质量和性能之间的良好折衷"); }); m_Tools.TextText_OY("Update When Offscreen", "勾选在" + "屏幕外动画".AddWhite() + "也会运行,高消耗"); m_Tools.TextText_OY("Skinned Motion Vectors", "皮肤的" + "运动矢量".AddWhite()); m_Tools.Text_G("启用: Mesh蒙皮数据会双缓冲,蒙皮运动有缓存并放置到运动矢量Texture中"); m_Tools.Text_G(" GPU内存开销换更正确的运动向量"); m_Tools.TextText_OY("Mesh", "Mesh Filter 整合在这里"); m_Tools.TextText_OY("Root Bone", "使用它来定义作为动画“根”的骨骼"); m_Tools.TextText_OY("", "(即所有其他骨骼相对于其移动的骨骼)".AddGreen()); m_Tools.TextText_OY("Bounds", "边框"); DrawBounds(); }); MeshTheSame(); }
protected Vector3 TextVector3(string str1, string str2, Vector3 value, int changeJianGe = AddJianGe) { Vector3 tmp = m_Tools.TextVector3_B(str1 + (" (" + str2 + ")").AddLightBlue(), value, changeJianGe); MyCreate.AddSpace(4); return(tmp); }
private void DrawComponent() // Component { m_Tools.BiaoTi_B("Component " + "(所有附加到 GameObject 的组件基类)".AddGreen()); MyCreate.PropertiesWindow(() => { m_Tools.Method_BL("tag", "", "标签可以用来识别游戏对象", "string", -20); m_Tools.Method_BL("gameObject", "只读", "该组件附加到的游戏对象", "GameObject", -20); m_Tools.Method_BL("transform", "只读", "", "Transform", -20); }); MyCreate.MethodWindow(() => { MyCreate.Box_Hei(() => { m_Tools.Text_G("1.组件所有的方法都是根据 gameObject 来调用的"); m_Tools.Text_G("2.Component 所有方法与 GameObject 部分方法相同"); }); MyCreate.Text("与 " + "gameObject".AddGreen() + " 一样发送信息的方法"); m_Tools.Text_L("BroadcastMessage", "、".AddHui(), "SendMessage", "、".AddHui(), "SendMessageUpwards"); AddSpace(); MyCreate.Text("与 " + "gameObject".AddGreen() + " 一样判断 tag 方法"); m_Tools.Text_L("CompareTag"); AddSpace(); MyCreate.Text("获取身上的 一个 组件"); m_Tools.Text_L("GetComponent、GetComponentInChildren、GetComponentInParent"); MyCreate.Text("获取身上的组件 集合"); m_Tools.Text_L("GetComponents、GetComponentInChildren、GetComponentInParent"); }); }
protected bool TextBool(string trueStr1, string falseStr1, string str2, bool value, int changeJianGe = AddJianGe) { bool tmp = m_Tools.TextBool_B((value ? trueStr1 : falseStr1) + (" (" + str2 + ")").AddLightBlue(), value, changeJianGe); MyCreate.AddSpace(4); return(tmp); }
private void DrawTimeScale() { m_Tools.Text_O("当 Time.timeScale = 0 时:"); m_Tools.BiaoTi_B("一次性的函数" + "(都会执行)".AddGreen()); MyCreate.Box(() => { m_Tools.Text_L("Awake、Start、OnEnable、OnDestroy 等都会执行"); }); AddSpace(); m_Tools.BiaoTi_B("每帧函数" + "(只有 Update 会执行)".AddGreen()); MyCreate.Box_Hei(() => { m_Tools.Text_Y("Update" + "(执行)".AddGreen() + " FixedUpdate" + "(不执行)".AddGreen()); m_Tools.Text_Y("Time.deltaTime" + "( 0 )".AddGreen() + " Time.fixedTime" + "( 0 )".AddGreen()); m_Tools.Text_G("只有 Time.fixedDeltaTime -> 0.02 !"); }); AddSpace(); m_Tools.BiaoTi_B("协程" + "(只有 yield return 前部分会执行)".AddGreen()); MyCreate.Box_Hei(() => { m_Tools.Text_B("yield return 前部分的语句会执行"); m_Tools.Text_B("而 yield return 后面的语句就不会执行"); }); AddSpace(); m_Tools.BiaoTi_B("Invoke" + "( 延时函数不会执行 )".AddGreen()); }
private void DrawGuGe() // 谷歌浏览器 { m_Tools.BiaoTi_O("下载百度云保存的"); MyCreate.Box(() => { m_Tools.Text_G("不要安装最新版的谷歌,太坑了"); m_Tools.TextButton_Open("打开分享下载", "https://pan.baidu.com/s/1zk0BEPuAQLOpz3vV10bSVA"); m_Tools.Text_G("全部先用后缀改成 zip -> 然后解压出来"); m_Tools.Text_G("把 _metadata 去除 _"); m_Tools.Text_G("用开发模式加载"); }); AddSpace_3(); m_Tools.BiaoTi_O("复制网站地址"); MyCreate.Box(() => { MyCreate.SelectText("http://www.manew.com/"); MyCreate.SelectText("http://www.6m5m.com/"); MyCreate.SelectText("http://www.taikr.com/"); MyCreate.SelectText("https://translate.google.cn/#en/zh-CN"); }); AddSpace(); m_Tools.BiaoTi_O("Tampermonkey"); MyCreate.Box(() => { m_Tools.TextButton_Open("打开下载脚本网站", "https://greasyfork.org/zh-CN"); }); }
protected override void OnEditorGUI() { switch (_FenLie) { case YHType.性能优化: DrawWhat(); break; case YHType.脚本: DrawYouHua(); break; case YHType.图形与物理: DrawTu(); break; case YHType.文件: DrawWenJian(); break; case YHType.相机: DrawCamera(); break; } MyCreate.AddSpace(); }
protected void DrawnOne(string str, Action action, bool isKongGe = true) // 层次结构第一层 { if (isKongGe) { m_Tools.Text_L("─── ", str.AddBlue()); if (null != action) { MyCreate.Heng(() => { MyCreate.AddSpace(35); MyCreate.Box(action); }); } } else { MyCreate.Text(" ── " + str); if (null != action) { MyCreate.Heng(() => { MyCreate.AddSpace(18); MyCreate.Box(action); }); } } }
private void DrawDav3() // 导航数据与优化 { m_Tools.BiaoTi_L("导出".AddOrange() + "导航网格数据"); MyCreate.Box(() => { MyCreate.Text("用途例如:自己一份,导出去服务器定位一份".AddGreen()); MyCreate.Box_Hei(() => { m_Tools.Text_Y("使用 ", "NavMesh.CalculateTriangulation()".AddHui()); m_Tools.Text_Y("返回 ", "NavMeshTriangulation ".AddHui()); MyCreate.Box(() => { m_Tools.Method_BL("areas", "", "所有层的集合", "int[]", -30); m_Tools.Method_BL("vertices", "", "所有顶点的集合", "Vector3[]", -30); m_Tools.Method_BL("indices", "", "所有索引的集合", "int[]", -30); }); }); MyCreate.Text("Tip: 有插件直接可使用:".AddGreen() + " CAINav".AddOrange()); }); AddSpace_15(); m_Tools.BiaoTi_L("关于大型地图导航的" + "优化".AddOrange()); MyCreate.Box(() => { m_Tools.Text_Y("为什么:Unity导航是基于A*的广度优先的", "(需要记录全地图)".AddLightGreen()); m_Tools.Text_W(" 当在大地图从一个点导航到另一个点的消耗巨大"); m_Tools.Text_Y("所以:可以把大地图划分几个小地区,当从这个小区到另一个小区"); m_Tools.Text_H(" 位置 -> 区的记录点 -> 最终区的记录点 -> 再导航到目标点"); }); }
private void DrawChuXiang() // 抽象工厂模式 { m_Tools.BiaoTi_B("抽象工厂模式"); MyCreate.Text("客户端只需要和" + GongLie + "打交道,不会与实际实现类有任何交互"); MyCreate.Box_Hei(() => { m_Tools.Text_H("public class ", GongLie); m_Tools.Text_H(" private static string ", gnmcStr, " =“", gaStr, "”"); m_Tools.Text_H(" public static ", GongNeng, " ", CreateStr); m_Tools.Text_H(" AssemblyName name = Assembly.GetExecutingAssembly().GetName()"); m_Tools.Text_H(" return (", GongNeng, ") Assembly.Load(name).CreateInstance(", gnmcStr, ")"); }); MyCreate.Text("实际的功能实现类,要做什么功能就在子类实现"); MyCreate.Box_Hei(() => { m_Tools.Text_H("public abstract class ", GongNeng, " { ... } "); }); MyCreate.Box(() => { m_Tools.Text_H("public class ", gaStr, " : ", GongNeng, " { ... } "); m_Tools.Text_H("public class 功能B : ", GongNeng, " { ... } "); }); MyCreate.Text("客户端只需要改变 " + gnmcStr + " 里面的类名称即可"); MyCreate.Box_Hei(() => { m_Tools.TextText_HG(GongNeng + " g = " + GongLie + "." + CreateStr, "// 工厂类已经是 Static 方法"); }); m_Tools.BiaoTi_L("总结"); MyCreate.Box(() => { m_Tools.Text_R("简单好用,易扩展,功能名称甚至可以" + "使用配置文件/枚举".AddGreen() + "来解决"); }); }
//重新写过方法---------------------------------------------------------------------------------- protected Enum TextEnum(string str1, string str2, Enum value, int changeJianGe = AddJianGe) { Enum tmp = m_Tools.TextEnum_B(str1 + (" (" + str2 + ")").AddLightBlue(), value, changeJianGe); MyCreate.AddSpace(4); return(tmp); }
private void DrawZhuang() // 装饰模式 { m_Tools.BiaoTi_O("装饰模式" + "(动态地给一个对象添加一些额外职责,比生成子类更灵活)".AddYellow()); AddSpace(); MyCreate.Text("可以给人搭配不同的服饰的系统".AddBold()); MyCreate.FenGeXian_Blue(PersonStr + ",拥有 Show 形象展示方法"); MyCreate.Box_Hei(() => { m_Tools.Text_H("class ", PersonStr); m_Tools.TextText_HG(" public virtual void " + ShowStr + "{ ... }", "// 可以给子类继承"); }); MyCreate.FenGeXian_Blue("服饰类 继承 Person 类,构造方法要求带一个 Person"); MyCreate.Box_Hei(() => { m_Tools.Text_H("class ", FuStr, " : ", PersonStr); m_Tools.Text_H(" protected ", PersonStr, m_PersonStr); m_Tools.Text_G(" 服饰类构造方法 -> 带一个 Person -> 赋值给 " + m_PersonStr); m_Tools.Text_H(" public override void ", ShowStr); m_Tools.TextText_HG(" " + m_PersonStr + "." + ShowStr, "// 注意这里没有 base 了"); }); MyCreate.FenGeXian_Blue("下面就是想要怎么设计服饰就怎么设计服饰了"); MyCreate.Box(() => { m_Tools.Text_H("class T恤类 : ", FuStr); m_Tools.Text_H(" public override void ", ShowStr); m_Tools.TextText_HG(" ....", "// 具体设计 T 恤的方法"); m_Tools.TextText_HG(" base.Show()", "// 先调用自己的再调用父类"); }); MyCreate.Box(() => { m_Tools.Text_H("class 裤类 : ", FuStr); m_Tools.Text_H(" public override void ", ShowStr); m_Tools.TextText_HG(" ....", "// 具体设计裤方法,与上面一致"); m_Tools.Text_H(" base.Show()"); }); MyCreate.FenGeXian_Blue("客户端最终只需要一层叠一层添加即可"); MyCreate.Box_Hei(() => { MyCreate.Text("一个人只穿一件T恤"); m_Tools.Text_H(PersonStr, " p = ", PersonStr, "()"); m_Tools.Text_H("T恤类 t = T恤类(p)"); m_Tools.TextText_HG("t.Show();", "// 同时会调用 p 内部的 Show 方法的了"); MyCreate.AddSpace(5); MyCreate.Text("一个人先穿T恤再穿上裤" + "再穿上等等的装饰".AddLightGreen()); m_Tools.Text_H(PersonStr, " p = ", PersonStr, "()"); m_Tools.Text_H("裤类 h = 裤类(p)"); m_Tools.Text_H("T恤类 t = T恤类(h)"); m_Tools.Text_LG("其他的装饰同理..."); m_Tools.TextText_HG("t.Show();", "// 先是T恤Show ->裤类Show->Person Show"); }); AddSpace(); MyCreate.FenGeXian("总结:"); MyCreate.Box(() => { m_Tools.Text_B("1. 这样做,把装饰这功能从 Person 类中抽取出来了(修改与添加也不会影响)"); m_Tools.Text_B("2. 同时去除了重复的 Show"); }); }
protected int TextEnum(string str2, int value, string[] ops, int changeJianGe = AddJianGe) { int tmp = m_Tools.TextEnum_B(GetArrayStr(ops, value) + (" (" + str2 + ")").AddLightBlue(), value, ops, changeJianGe); MyCreate.AddSpace(4); return(tmp); }
private void DrawDictionary() //Dictionary { m_Tools.ButtonText("Dictionary<k,v>", "Key不可重复,添加重复报错,取[不存在]报错", ref isDictionary, () => { m_Tools.BiaoTi_O("foreach 的使用", ref isForeach2, () => { MyCreate.Window("用 KeyValuePair<int, string> 对象 声明", () => { m_Tools.Text_Y("foreach (KeyValuePair<int, string> kvp in dic)"); }); AddSpace(); AddSpace(); MyCreate.Window("用 key/value 对象 声明", () => { m_Tools.Text_Y("foreach ( T key in dic.Keys )"); }); }); m_Tools.BiaoTi_O("方法", true); MyCreate.Box(() => { MyCreate.Text("查"); m_Tools.Method_YG("ContainsKey", "K key", "key 是否包含"); m_Tools.Method_YG("ContainsValue", "V Value", "Value 是否包含"); MyCreate.Text("获取"); m_Tools.Method_YG("this", "K", "通过key获取value,没有报错", "V"); m_Tools.Method_YG("TryGetValue", "K,out V", "通过key获取value,没有不报错", "bool"); m_Tools.Text_G("继承 IEnumerable<T>,都有它的扩展方法"); }); }, -60); AddSpace_3(); }
protected int TextInt(string str1, string str2, int value, int max, int changeJianGe = AddJianGe, int minValue = 0) { int tmp = m_Tools.TextInt_B(str1 + (" (" + str2 + ")").AddLightBlue(), value, minValue, max, changeJianGe); MyCreate.AddSpace(4); return(tmp); }
private void DrawFirst() // First { m_Tools.Text_B("Level Manager"); MyCreate.Box(() => { m_Tools.Text_L("使用一配置文件 来记录每个 Level "); m_Tools.Text_L("只提供一个 NextLevel 的方法"); m_Tools.Text_L("同时控制跳转时的特效"); m_Tools.Text_L("可以看看 Mad Level Manager 这个插件"); }); m_Tools.Text_B("Pool Manager"); MyCreate.Box(() => { m_Tools.Text_L("每个 Perfab 对一个 Pool ,控制 pool 最多数量"); m_Tools.Text_L("就是不是无限加进池子中,当超过数量就删除"); }); m_Tools.Text_B("Save Manager"); MyCreate.Box(() => { m_Tools.Text_L("推荐使用 Easy Save2 插件,它用二进制存储"); }); MyCreate.Box_Hei(() => { m_Tools.Text_L("mvcs 用反射比下面慢,没界面,免费"); m_Tools.Text_L("MVVM UFRAME 可视化框架,收费,快"); }); MyCreate.Box_Hei(() => { m_Tools.Text_L("Published by unity 测试工具"); m_Tools.Text_L("Unity test /Integration test /Assertion component"); }); }
private void FindMiss(GameObject[] gos) { if (gos.Length == 0) { m_Tools.Text_L("Resources 都没有东西"); } else { bool isNull = true; foreach (GameObject go in gos) { MonoBehaviour[] cs = go.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour component in cs) { if (null == component) { MyCreate.SelectText(go.name); isNull = false; } } } if (isNull) { m_Tools.Text_L("没有"); } } }