Example #1
0
        private static void CreateUIView(string modName, string uiName, UIOutlet ui)
        {
            string saveFilePath = $"{ExportScriptDir}{modName}/UI/View/{uiName}View.cs";

            StringBuilder fieldStrs = new StringBuilder();
            StringBuilder getStrs   = new StringBuilder();

            UIOutlet.OutletInfo info;
            string objType;

            for (int i = ui.OutletInfos.Count; --i >= 0;)
            {
                info = ui.OutletInfos[i];
                if (info == null)
                {
                    continue;
                }
                objType = getTypeName(info.ComponentType);
                fieldStrs.AppendLine($"        private {objType} {info.Name};");
                if (objType == "GameObject")
                {
                    getStrs.AppendLine($@"            {info.Name} = Get(""{info.Name}"");");
                }
                else
                {
                    getStrs.AppendLine($@"            {info.Name} = Get<{objType}>(""{info.Name}"");");
                }
            }

            string fieldStr = $@"//工具生成不要修改

using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using GameFramework;

namespace {AppSetting.MineGameName}.UI.{modName}
{{
    public partial class {uiName} : BaseUI
    {{
{fieldStrs} 
        /// <summary>初始化UI控件</summary>
        override protected void InitializeComponent()
        {{
{getStrs}
        }}
    }}
}}
";

            ToolsHelper.SaveFile(saveFilePath, fieldStr, true);
        }
Example #2
0
        //public static void BuildHotFixAssetBundles()
        //{
        //    if (ToolsHelper.IsPlaying()) return;
        //    ToolsHelper.ClearConsole();
        //    Stopwatch watch = new Stopwatch();
        //    watch.Start();
        //    CopyHotFix();
        //    Dictionary<string, List<string>> buildMap = new Dictionary<string, List<string>>();
        //    string baseBunldDir = "Assets/GameRes/BundleRes/Data";
        //    List<string> abNames;
        //    foreach (string filepath in Directory.GetFiles(baseBunldDir, "*.*", SearchOption.AllDirectories))
        //    {
        //        if (filepath.EndsWith(".meta")) continue;
        //        AssetImporter importer = AssetImporter.GetAtPath(filepath);
        //        if (importer == null)
        //            continue;
        //        if (importer.assetBundleName == string.Empty)
        //        {
        //            ToolsHelper.Warning("文件没设置AB名:" + filepath);
        //            continue;
        //        }
        //        if (!buildMap.TryGetValue(importer.assetBundleName, out abNames))
        //        {
        //            abNames = new List<string>();
        //            buildMap.Add(importer.assetBundleName, abNames);
        //        }
        //        abNames.Add(importer.assetPath);
        //    }
        //    // 设置新的资源名
        //    List<AssetBundleBuild> abList = new List<AssetBundleBuild>();
        //    foreach (KeyValuePair<string, List<string>> keyVal in buildMap)
        //    {
        //        AssetBundleBuild ab = new AssetBundleBuild();
        //        ab.assetBundleName = keyVal.Key;
        //        ab.assetNames = keyVal.Value.ToArray();
        //        abList.Add(ab);
        //    }
        //    var outputPath = GetExportPath();
        //    BuildPipeline.BuildAssetBundles(outputPath, abList.ToArray(), BuildAssetBundleOptions.DeterministicAssetBundle, EditorUserBuildSettings.activeBuildTarget);
        //    CreateAssetBundleFileInfo();
        //    watch.Stop();
        //    ToolsHelper.Log("Data文件打包完成!!用时:" + (watch.ElapsedMilliseconds / 1000.0f) + "秒");
        //}
        /// <summary>
        /// 保存碰撞矩阵数据
        /// </summary>
        public static void CreateLayerCollisionMatrix()
        {
            string FilePath = Application.dataPath + "/GameRes/BundleRes/Data/LayerCollisionMatrix.bytes";
            string content  = "";

            for (int i = 0; i < 32; i++)
            {
                for (int j = 31; j >= i; j--)
                {
                    bool Ignore = Physics.GetIgnoreLayerCollision(i, j);
                    if (Ignore)
                    {
                        content += $"{i},{j}_";
                    }
                }
            }
            ToolsHelper.SaveFile(FilePath, content);
            AssetDatabase.Refresh();
        }
Example #3
0
        private static void CreateUI(string modName, string uiName, UIOutlet ui)
        {
            string        saveFilePath = $"{ExportScriptDir}{modName}/UI/{uiName}.cs";
            StringBuilder eventAddStrs = new StringBuilder();
            StringBuilder eventStrs    = new StringBuilder();

            UIOutlet.OutletInfo info;
            string objType;

            for (int i = ui.OutletInfos.Count; --i >= 0;)
            {
                info = ui.OutletInfos[i];
                if (info == null)
                {
                    continue;
                }
                objType = getTypeName(info.ComponentType);
                if (info.Object.name.StartsWith("btn")) //自动生成按钮事件
                {
                    eventAddStrs.AppendLine($"            {info.Object.name}.AddClick({info.Object.name}_Click);   //");
                    eventStrs.AppendLine($@"        /// <summary></summary>
        void {info.Object.name}_Click()
        {{
        }}");
                }
            }

            string fieldStr = $@"using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using DG.Tweening;
using GameFramework;

namespace {AppSetting.MineGameName}.UI.{modName}
{{
    public partial class {uiName} : BaseUI
    {{
        /// <summary>XXXX界面</summary>
        public {uiName}()
        {{
            UINode = EUINode.UIWindow;     //UI节点
            OpenAnim = EUIAnim.None;      //UI打开效果
            CloseAnim = EUIAnim.None;   //UI关闭效果 
        }}
        
        /// <summary>添加事件监听</summary>
        override protected void Awake()
        {{ 
{eventAddStrs}
        }}
        
         /// <summary>刷新</summary>
        public override void Refresh()
        {{
        }}

{eventStrs}
        /// <summary>释放UI引用</summary>
        public override void Dispose()
        {{
        }}
    }}
}}
";

            ToolsHelper.SaveFile(saveFilePath, fieldStr, false);
        }
Example #4
0
        private static void CreateItem(string modName, string uiName, UIOutlet ui)
        {
            string        saveFilePath = $"{ExportScriptDir}{modName}/UI/Item/{uiName}.cs";
            StringBuilder eventAddStrs = new StringBuilder();
            StringBuilder eventStrs    = new StringBuilder();

            UIOutlet.OutletInfo info;
            string objType;

            for (int i = ui.OutletInfos.Count; --i >= 0;)
            {
                info = ui.OutletInfos[i];
                if (info == null)
                {
                    continue;
                }
                objType = getTypeName(info.ComponentType);
                if (info.Object.name.StartsWith("btn")) //自动生成按钮事件
                {
                    eventAddStrs.AppendLine($"            {info.Object.name}.AddClick({info.Object.name}_Click);   //");
                    eventStrs.AppendLine($@"        /// <summary></summary>
        void {info.Object.name}_Click()
        {{
        }}");
                }
            }

            string selClick = "             gameObject.AddClick(self_Click);     //当前对象点击事件";

            if (ui.GetComponent <Button>() != null)
            {
                selClick = "             gameObject.GetComponent<Button>().AddClick(self_Click);  //当前对象点击事件";
            }
            string fieldStr = $@"using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using GameFramework;

namespace {AppSetting.MineGameName}.UI.{modName}
{{
    public partial class {uiName} : BaseItem
    {{
        public Action<{uiName}> onClick; //Item点击事件

        /// <summary>添加事件监听</summary>
        override protected void Awake()
        {{
{selClick}             {eventAddStrs}
        }}
        /// <summary>设置数据<param name=""data""></param>
        /*public void SetData({uiName}Data data)
        {{
            Data = data;
            txtServerName.text = data.ServerName;
        }}*/
        /// <summary>刷新Item</summary>
        public override void Refresh()
        {{
        }}

        /// <summary>当前对象点击事件</summary>
        void self_Click()
        {{
            onClick?.Invoke(this);
        }}
{ eventStrs}
        /// <summary>释放Item引用</summary>
        public override void Dispose()
        {{
            onClick = null;
        }}
    }}
}}
";

            ToolsHelper.SaveFile(saveFilePath, fieldStr, false);
        }