Ejemplo n.º 1
0
        public static string Generate(string jsonName, InputParam param_)
        {
            JsonData data = KAssetManager.GetUIJsonData(jsonName);

            //1.创建canvas
            GameObject root = new GameObject("Canvas_" + jsonName);

            root.layer = LayerMask.NameToLayer("UI");
            AddCanvas(root, jsonName);  //canvas组件

            //2.构建go
            ComponentCreator creator = ComponentCreatorFactory.GetTypeCreator("Container");
            GameObject       panel   = creator.Create(data, root); //创建对象

            AddPanelToRoot(panel, root);

            //3.执行builder
            //AddPanelBuilder(root);
            //RemoveAllBuildHelper(panel);

            //4.创建预制
            GenPrefabs(root, param_.isBuildAssetbundle);

            return(string.Empty);
        }
Ejemplo n.º 2
0
        public static void Generate(string jsonName, InputParam inputParam_)
        {
            Initialize();

            _isHighQuality = inputParam_.isHighQuality;

            _atlasName = AtlasBatchSetting.GetBatchedAtlasName(jsonName);   //获取实际的图集名称

            //WriteBatchedReadme(_atlasName, jsonName);   //提醒图集已经移到partxx

            List <string> batchedAtlasNameList = AtlasBatchSetting.GetBatchedAtlasNameList(jsonName);    //收集此图集包含的所有json名称

            for (int i = 0; i < batchedAtlasNameList.Count; i++)
            {
                string name = batchedAtlasNameList[i];
                if (batchedAtlasNameList.Count == 1 || i > 0)   //如果多于一个,跳过第一个,因为那个是目标图集,不是界面
                {
                    JsonData jsonData = KAssetManager.GetUIJsonData(name);
                    ProcessJson(jsonData);  //处理所有该图集需要用到的json, 不只是该界面的json
                }
            }

            //处理散图
            ProcessTextureDataList();

            if (_uniqueTextureDataList.Count > 0)
            {
                //需要生成图集
                GenerateAtlas();
            }
            else
            {
                Debug.Log("面板资源都在公共图集中~~~~");
            }
        }
Ejemplo n.º 3
0
        static void ProcessJson(JsonAsset json, InputParam param_)
        {
            StopWatch.StartST();

            try
            {
                if (param_.isGenerateAtlas)
                {
                    //需要生成图集
                    if (AtlasBatchSetting.IsAtlasNameRecord(json.name))
                    {
                        //记录已经生成过, 之后不再生成
                    }
                    else
                    {
                        AtlasBatchSetting.RecordAtlasName(json.name);
                        GenerateAtlas(json.name, param_);
                    }
                }


                GeneratePrefab(json, param_);
            }
            catch (Exception e)
            {
                throw e;
            }

            Debug.Log("导出成功: " + json.name + "  耗时:" + (StopWatch.StopST(false) / 1000).ToString("f2") + " s");
        }
Ejemplo n.º 4
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽生成图集∽-★-∽--------∽-★-∽------∽-★-∽--------//

        // 生成图集
        static void GenerateAtlas(string atlasName, InputParam param_)
        {
            //准备临时目录
            PrepareTmpAtlasFolders();

            //PrepareAtlasFolders(atlasName);   //这里不预先创建全部文件夹
            AtlasGenerator.Generate(atlasName, param_);

            //删除临时目录
            DeleteTmpAtlasFolders();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 执行生成_文件模式
        /// </summary>
        /// <param name="jsonAssets"></param>
        /// <param name="isGenerateAtlas">是否生成图集</param>
        /// <param name="isHighQuality"></param>
        /// <param name="isBuildAssetbundle"></param>
        public static void ExecuteFileMode(JsonAsset[] jsonAssets, InputParam param_)
        {
            AtlasBatchSetting.Initialize();
            AtlasQualitySetting.Initialize();
            AtlasSpritePaddingHelper.Initialize();
            PrefabGenerator.Initialize();

            for (int i = 0; i < jsonAssets.Length; i++)
            {
                if (jsonAssets[i] != null)
                {
                    ProcessJson(jsonAssets[i], param_);
                }
            }
        }
Ejemplo n.º 6
0
        void Initialize()
        {
            KAssetManager.Initialize();

            _jsonAssets     = new JsonAsset[1];
            _jsonIndices    = new int[1];
            _popupJsonNames = new string[] { "选择Json文件" };

            _constructError = string.Empty;
            _error          = string.Empty;

            _inputParam = new InputParam();

            RefreshJsonNames();  //初始化json列表
            InitBatchSetting();
        }
Ejemplo n.º 7
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽生成预制∽-★-∽--------∽-★-∽------∽-★-∽--------//

        static void GeneratePrefab(JsonAsset json, InputParam param_)
        {
            PrefabGenerator.Generate(json.name, param_);
        }