Example #1
0
    public static void GenWindowScript()
    {
        if (Selection.activeTransform == null || Selection.activeGameObject == null)
        {
            Debug.LogError("未选中节点!");
            return;
        }

        if (!Selection.activeGameObject.name.EndsWith("Window"))
        {
            Debug.LogError("后缀必须为Window!");
            return;
        }

        var go = Selection.activeGameObject;

        if (go.GetComponent <RectTransform>() == null)
        {
            Debug.LogError("改功能仅支持UGUI!");
            return;
        }

        var nodeName = go.name.Substring(0, go.name.IndexOf("Window"));

        GenGlobal.Log("开始生成!");

        CodeGenerator.UGUIWindowInit(Selection.activeTransform);
        GenGlobal.Log("完成生成");
    }
Example #2
0
    public static void WriteClsesToDirectory(List <GenClassInfo> clese, CodeBuilder codeBuilder, bool writeToDir = true)
    {
        if (clese == null && clese.Count == 0)
        {
            Debug.LogError("clese为空");
            return;
        }

        //统一写入
        foreach (var cls in clese)
        {
            string path = CodeSavePath + (cls.namespaceStr + "/");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var sb = codeBuilder.Build(cls);
            if (writeToDir)
            {
                WriteSbToDirectory(path + cls.name + ".cs", sb);
            }

            GenGlobal.Log("\n" + sb.ToString());          //测试代码
        }

        AssetDatabase.Refresh();
    }