Exemple #1
0
        private void CreateUIPanelCode(GameObject uiPrefab, string uiPrefabPath)
        {
            if (null == uiPrefab)
            {
                return;
            }

            var behaviourName = uiPrefab.name;
            var strFilePath   = uiPrefabPath.Replace(QFrameworkConfigData.Load().UIPrefabDir, GetScriptsPath());

            if (!uiPrefabPath.Contains(QFrameworkConfigData.Load().UIPrefabDir) &&
                uiPrefabPath.Contains("/Resources"))
            {
                strFilePath = uiPrefabPath.Replace("/Resources", GetScriptsPath());
            }

            strFilePath.Replace(uiPrefab.name + ".prefab", "").CreateDirIfNotExists();
            strFilePath = strFilePath.Replace(".prefab", ".cs");

            if (File.Exists(strFilePath) == false)
            {
                UIPanelCodeTemplate.Generate(strFilePath, behaviourName, GetProjectNamespace());
            }

            CreateUIPanelComponentsCode(behaviourName, strFilePath);
            Debug.Log(">>>>>>>Success Create UIPrefab Code: " + behaviourName);
        }
        private void CreateUIPanelCode(GameObject uiPrefab, string uiPrefabPath)
        {
            if (null == uiPrefab)
            {
                return;
            }

            var behaviourName = uiPrefab.name;

            var strFilePath = string.Empty;

            var prefabDirPattern = FrameworkSettingData.Load().UIPrefabDir;

            if (uiPrefabPath.Contains(prefabDirPattern))
            {
                strFilePath = uiPrefabPath.Replace(prefabDirPattern, GetScriptsPath());
            }
            else if (uiPrefabPath.Contains("/Resources"))
            {
                strFilePath = uiPrefabPath.Replace("/Resources", GetScriptsPath());
            }
            else
            {
                strFilePath = uiPrefabPath.Replace("/" + uiPrefabPath.GetLastDirName(), GetScriptsPath());
            }

            strFilePath.Replace(uiPrefab.name + ".prefab", string.Empty).CreateDirIfNotExists();

            strFilePath = strFilePath.Replace(".prefab", ".cs");

            if (File.Exists(strFilePath) == false)
            {
                UIPanelCodeTemplate.Generate(strFilePath, behaviourName, GetProjectNamespace());
            }

            CreateUIPanelComponentsCode(behaviourName, strFilePath);
            Debug.Log(">>>>>>>Success Create UIPrefab Code: " + behaviourName);
        }