コード例 #1
0
        private void OnEnable()
        {
            GreenFont                  = new GUIStyle();
            GreenFont.fontStyle        = FontStyle.Bold;
            GreenFont.fontSize         = 11;
            GreenFont.normal.textColor = Color.green;
            RedFont                  = new GUIStyle();
            RedFont.fontStyle        = FontStyle.Bold;
            RedFont.fontSize         = 11;
            RedFont.normal.textColor = Color.red;

            m_Target = (CompCollector)target;

            m_HelperTypeNames = GetTypeNames(typeof(IAutoBindRuleHelper), s_AssemblyNames);
            m_CodeTypeNames   = GetTypeNames(typeof(ICodeGenerateHelper), s_AssemblyNames);
            m_SearchTypeNames = GetTypeNames(typeof(ICompSearchHelper), s_AssemblyNames);

            m_SearchTypeCustomNames = new string[m_SearchTypeNames.Length];
            for (var index = 0; index < m_SearchTypeNames.Length; index++)
            {
                var variable             = m_SearchTypeNames[index];
                ICompSearchHelper helper = (ICompSearchHelper)CreateHelperInstance(variable, s_AssemblyNames);
                m_SearchTypeCustomNames[index] = helper.CustomName();
            }
        }
コード例 #2
0
        public void GenerateCode(CompCollector collector)
        {
            string modName = SceneManager.GetActiveScene().name;
            string uiName  = collector.gameObject.name;

            CreateUI(modName, uiName);
            CreateUIView(modName, uiName, collector);
        }
コード例 #3
0
        private void CreateItemView(string modName, string itemName, CompCollector collector)
        {
            string outPath = Path.GetFullPath($"Assets/Scripts/Hotfix/Module/{modName}/Item/View/{itemName}View.cs");

            outPath = GameFramework.Utility.Path.GetRegularPath(outPath);

            ToolsHelper.SaveFile(outPath, getItemViewCodeStr(modName, itemName, collector));
            AssetDatabase.Refresh();
        }
コード例 #4
0
        private void CreateLogicView(string entityName, CompCollector collector)
        {
            string outPath = Path.GetFullPath($"{path_entity}/Entity/{entityName}/EntityView_{entityName}.cs");

            outPath = GameFramework.Utility.Path.GetRegularPath(outPath);

            ToolsHelper.SaveFile(outPath, getViewCodeStr(entityName, collector));
            AssetDatabase.Refresh();
        }
コード例 #5
0
ファイル: StoreUIView.cs プロジェクト: q425163005/GF
 /// <summary>初始化UI控件</summary>
 protected override void InitializeComponent()
 {
     Btn_Back     = Get <Button>("Btn_Back");
     Tog_Pay      = Get <Toggle>("Tog_Pay");
     Tog_Gift     = Get <Toggle>("Tog_Gift");
     Tog_Equip    = Get <Toggle>("Tog_Equip");
     Tog_Prop     = Get <Toggle>("Tog_Prop");
     PayContent   = Get("PayContent");
     GiftContent  = Get("GiftContent");
     EquipContent = Get("EquipContent");
     PropContent  = Get("PropContent");
     PayItem      = Get <CompCollector>("PayItem");
 }
コード例 #6
0
        public void GenerateCode(CompCollector collector)
        {
            string entityName = collector.m_EntityName;

            if (string.IsNullOrEmpty(entityName))
            {
                Debug.LogError("Entity不能为空!");
                return;
            }
            CreateLogic(entityName);
            CreateLogicView(entityName, collector);
            CreateData(entityName);
        }
コード例 #7
0
        private string getItemViewCodeStr(string modName, string itemName, CompCollector collector)
        {
            StringBuilder codeStr = new StringBuilder();

            //引用
            codeStr.AppendLine("//工具生成不要修改");
            codeStr.AppendLine($"//生成时间:{DateTime.Now}");
            codeStr.AppendLine("using UnityEngine;");
            codeStr.AppendLine("using UnityEngine.UI;");
            codeStr.AppendLine("");

            //命名空间
            codeStr.AppendLine("namespace Fuse.Hotfix." + modName);
            codeStr.AppendLine("{");

            //类名
            codeStr.AppendLine($"\tpublic partial class {itemName} : BaseItem");
            codeStr.AppendLine("\t{");

            StringBuilder compStr = new StringBuilder();

            string objType;

            //组件
            foreach (var variable in collector.CompCollectorInfos)
            {
                objType = getTypeName(variable.ComponentType);
                codeStr.AppendLine($"\t\tprivate {objType} {variable.Name};");
                if (objType == "GameObject")
                {
                    compStr.AppendLine($"\t\t\t{variable.Name} = Get(\"{variable.Name}\");");
                }
                else
                {
                    compStr.AppendLine($"\t\t\t{variable.Name} = Get<{objType}>(\"{variable.Name}\");");
                }
            }

            codeStr.AppendLine("\t\t/// <summary>初始化UI控件</summary>");
            codeStr.AppendLine("\t\tprotected override void InitializeComponent()");
            codeStr.AppendLine("\t\t{");

            codeStr.Append(compStr);

            codeStr.AppendLine("\t\t}");

            codeStr.AppendLine("\t}");
            codeStr.AppendLine("}");
            return(codeStr.ToString());
        }
コード例 #8
0
        public void GenerateCode(CompCollector collector)
        {
            string modName  = SceneManager.GetActiveScene().name;
            string itemName = collector.gameObject.name;

            if (!itemName.EndsWith("Item"))
            {
                Debug.LogError("命名结尾必须为Item");
                return;
            }

            CreateItem(modName, itemName);
            CreateItemView(modName, itemName, collector);
        }
コード例 #9
0
        private static void HierarchyItemCB(int instanceid, Rect selectionrect)
        {
            var obj = EditorUtility.InstanceIDToObject(instanceid) as GameObject;

            if (obj != null)
            {
                CompCollector compCollector = obj.GetComponent <CompCollector>();
                if (compCollector != null)
                {
                    Rect r = new Rect(selectionrect);
                    r.x  = r.width + 20;
                    r.y += 2;
                    var style = new GUIStyle();
                    style.normal.textColor = Color.yellow;
                    GUI.Label(r, $"Infos:{compCollector.CompCollectorInfos.Count}", style);
                }

                if (_cachedCompInfo.ContainsKey(obj))
                {
                    Rect r = new Rect(selectionrect);
                    r.x  = r.x + GetStringWidth(obj.name) + 25;
                    r.y += 2;
                    GUIStyle style = new GUIStyle();
                    style.normal.textColor = Color.green;
                    //GUI.Label(r, string.Format("{0} [{1}]", _outletObjects[obj][0], _outletObjects[obj][1]), style);

                    string str = "";
                    foreach (var variable in _cachedCompInfo[obj])
                    {
                        str += $"[{variable}]";
                    }

                    GUI.Label(r, str, style);
                }
            }
        }
コード例 #10
0
ファイル: BaseItem.cs プロジェクト: q425163005/GF
 /// <summary>
 /// 实例化Item
 /// </summary>
 /// <param name="prefab">预制体,会重新实例一个</param>
 /// <param name="parent">父对象</param>
 public void Instantiate(CompCollector uiOut, Transform parent)
 {
     Instantiate(uiOut.gameObject, parent);
 }