コード例 #1
0
ファイル: PSD4UGUI.cs プロジェクト: vinhphu3000/mg01
        //-------∽-★-∽------∽-★-∽--------∽-★-∽Batch相关∽-★-∽--------∽-★-∽------∽-★-∽--------//

        //初始化打包图集设置
        void InitBatchSetting()
        {
            JsonAsset jsonAsset = KAssetManager.GetJson(KAssetManager.AtlasBatchSettingPath);

            if (jsonAsset == null)
            {
                //没找到BatchSetting
                _batchNames  = new string[] { "请选择图集名称" };
                _batchIndice = 0;
                return;
            }

            JsonData data    = jsonAsset.GetJsonData();
            JsonData setting = data["setting"];

            _batchNames     = new string[setting.Count + 1];
            _batchNames[0]  = "请选择图集名称";
            _batchIndice    = 0;
            _batch2chlidren = new Dictionary <string, List <string> >();

            int i = 1;

            foreach (JsonData part in setting)
            {
                string partname = part[0].ToString();
                _batchNames[i]            = partname;
                _batch2chlidren[partname] = new List <string>();
                for (int j = 1; j < part.Count; j++)
                {
                    _batch2chlidren[partname].Add(part[j].ToString());
                }

                ++i;
            }
        }
コード例 #2
0
ファイル: PSD4UGUI.cs プロジェクト: vinhphu3000/mg01
        //显示当前Batch的所有Assets
        void ShowBatchAssets()
        {
            if (_batchIndice == 0)
            {
                return;
            }

            string        batchName     = _batchNames[_batchIndice];
            List <string> batchChildren = _batch2chlidren[batchName];

            JsonAsset[] newJsonAssets  = new JsonAsset[batchChildren.Count];
            int[]       newJsonIndices = new int[batchChildren.Count];
            for (int i = 0; i < batchChildren.Count; i++)
            {
                JsonAsset asset = KAssetManager.GetJson(KAssetManager.FOLDER_JSON + "/" + batchChildren[i] + ".json");
                if (asset != null)
                {
                    int indexInArr = Array.IndexOf <string>(_popupJsonNames, GetMenuItemLabel(batchChildren[i]));
                    newJsonAssets[i]  = asset;
                    newJsonIndices[i] = indexInArr;
                }
                else
                {
                    newJsonAssets[i]  = null;
                    newJsonIndices[i] = 0;
                }
            }
            _jsonAssets  = newJsonAssets;
            _jsonIndices = newJsonIndices;
        }
コード例 #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");
        }
コード例 #4
0
ファイル: PSD4UGUI.cs プロジェクト: vinhphu3000/mg01
        void ShowJsonAssets()
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(500), GUILayout.Height(400));

            if (_jsonAssets != null)
            {
                for (int i = 0; i < _jsonAssets.Length; i++)
                {
                    GUILayout.Space(5);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Json文件:", GUILayout.Width(70));
                    JsonAsset json = _jsonAssets[i];
                    if (json == null)
                    {
                        GUI.contentColor = COLOR_RED;
                    }

                    //
                    //拖动输入框, json放在外部了,不用支持拖放
                    //TextAsset jsonAsset = EditorGUILayout.ObjectField(_jsonAssets[i], typeof(TextAsset), false, GUILayout.Width(200)) as TextAsset;
                    //int jsonIndex = EditorGUILayout.Popup(_jsonIndices[i], _jsonNames, GUILayout.Width(120));
                    //if (jsonAsset != _jsonAssets[i])
                    //{
                    //    _jsonIndices[i] = Array.IndexOf<string>(_jsonNames, GetMenuItemLabel(jsonAsset.name));
                    //    _jsonAssets[i] = jsonAsset;
                    //}
                    //else if (jsonIndex != _jsonIndices[i])
                    //{
                    //    _jsonAssets[i] = AssetDatabase.LoadAssetAtPath(KAssetManager.FOLDER_JSON + "/" + _jsonNames[jsonIndex].Substring(2) + ".json", typeof(TextAsset)) as TextAsset;
                    //    _jsonIndices[i] = jsonIndex;
                    //}

                    GUILayout.TextArea(json != null ? json.name : _popupJsonNames[0], GUILayout.Width(200));
                    int jsonIndex = EditorGUILayout.Popup(_jsonIndices[i], _popupJsonNames, GUILayout.Width(120));
                    if (jsonIndex != _jsonIndices[i])
                    {
                        if (jsonIndex == 0)
                        {
                            //删除此项
                            _jsonAssets[i]  = null;
                            _jsonIndices[i] = 0;
                        }
                        else
                        {
                            string name = _popupJsonNames[jsonIndex].Substring(2); //去掉"A/"
                            _jsonAssets[i]  = KAssetManager.GetUIJson(name);
                            _jsonIndices[i] = jsonIndex;                           //记录选中序号
                        }
                    }

                    GUI.contentColor = Color.white;
                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.EndScrollView();
        }
コード例 #5
0
ファイル: KAssetManager.cs プロジェクト: vinhphu3000/mg01
        public static JsonData GetUIJsonData(string name)
        {
            JsonAsset jsonAsset = GetUIJson(name);

            if (jsonAsset != null)
            {
                return(jsonAsset.GetJsonData());
            }
            return(null);
        }
コード例 #6
0
ファイル: KAssetManager.cs プロジェクト: vinhphu3000/mg01
        public static JsonAsset GetUIJson(string name)
        {
            string    path      = string.Concat(FOLDER_JSON, "/", name, ".json");
            JsonAsset jsonAsset = GetJson(path);

            if (jsonAsset == null)
            {
                throw new Exception("未找到Json: " + path);
            }
            return(jsonAsset);
        }
コード例 #7
0
ファイル: PSD4UGUI.cs プロジェクト: vinhphu3000/mg01
 //添加json按钮
 void AddJsonAsset()
 {
     JsonAsset[] newJsonAssets  = new JsonAsset[_jsonAssets.Length + 1]; //增加一个空位
     int[]       newJsonIndices = new int[_jsonIndices.Length + 1];
     for (int i = 0; i < _jsonAssets.Length; i++)
     {
         newJsonAssets[i]  = _jsonAssets[i];
         newJsonIndices[i] = _jsonIndices[i];
     }
     _jsonAssets  = newJsonAssets;
     _jsonIndices = newJsonIndices;
 }
コード例 #8
0
        public static void Initialize()
        {
            JsonAsset jsonAsset = KAssetManager.GetJson(KAssetManager.AtlasQualitySettingPath);

            if (jsonAsset != null)
            {
                Dictionary <string, List <string> > dict = JsonMapper.ToObject <Dictionary <string, List <string> > >(jsonAsset.text);
                _highQualityAtlasList = dict["highQuality"];
            }
            else
            {
                _highQualityAtlasList = new List <string>();
            }
        }
コード例 #9
0
        private static HashSet <string> _atlasNameSet; //在某次运行中已经生成的Atlas集合,避免重复生成Atlas

        public static void Initialize()
        {
            _batchSetting = new List <List <string> >();
            _atlasNameSet = new HashSet <string>();

            JsonAsset jsonAsset = KAssetManager.GetJson(KAssetManager.AtlasBatchSettingPath);

            if (jsonAsset == null)
            {
                Debug.LogWarning("未找到图集合并设置 " + KAssetManager.AtlasBatchSettingPath);
            }
            else
            {
                Dictionary <string, List <List <string> > > dict = JsonMapper.ToObject <Dictionary <string, List <List <string> > > >(jsonAsset.text);
                _batchSetting = dict["setting"];
                for (int i = 0; i < _batchSetting.Count; ++i)
                {
                    _batchSetting[i] = ListUtil.RemoveRepeat(_batchSetting[i]); //剔除重复项
                }
            }
        }
コード例 #10
0
ファイル: KAssetManager.cs プロジェクト: vinhphu3000/mg01
        /// <summary>
        /// 获取json文件
        /// </summary>
        /// <param name="path_"></param>
        /// <returns></returns>
        public static JsonAsset GetJson(string path_)
        {
            JsonAsset json;

            if (_path2json.ContainsKey(path_))
            {
                json = _path2json[path_];
            }
            else
            {
                json = new JsonAsset(path_);
                _path2json[path_] = json;
            }

            if (json.text == null)
            {
                //没有这文件
                return(null);
            }

            return(json);
        }
コード例 #11
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽生成预制∽-★-∽--------∽-★-∽------∽-★-∽--------//

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