Пример #1
0
        // 检索指定UI中的所有Image所用的图集
        public static void QueryTexture()
        {
            // 原理:找到Prefab上的所有的guid值和所有的纹理和图集做比较
            // 通过Sprite的guid来查询Sprite的详细信息

            // 1.其中的Guid和Packing Tag <Key=Guid,Value=PackingTag>
            Dictionary <string, ESpriteCnf> all_sprite_guids = ESpriteHelper.GetAllSpriteInfo();

            // 2.查找Prefab的实际保存的路径
            string path = EPrefabHelper.FindPrefabPath(Selection.activeGameObject);

            // 3.读取指定位置的prefab的Guid值集合
            List <string> guid_list = EGuidHelper.GetGuidsByFile(path);

            // 4.统计用到的纹理tag
            List <string> sprite_packing_tags = new List <string>();
            // 5.统计使用到的空的tag
            List <ESpriteCnf> empty_list = new List <ESpriteCnf>();
            int length = guid_list.Count;

            for (int i = 0; i < length; i++)
            {
                if (!all_sprite_guids.ContainsKey(guid_list[i]))
                {
                    continue;
                }

                ESpriteCnf info = all_sprite_guids[guid_list[i]];
                if (string.IsNullOrEmpty(info.packingtag))
                {
                    empty_list.Add(info);
                    continue;
                }

                if (sprite_packing_tags.Contains(info.packingtag))
                {
                    continue;
                }
                sprite_packing_tags.Add(info.packingtag);
            }

            Debug.Log("使用到的Sprite Packing Tag Count:" + sprite_packing_tags.Count);
            for (int i = 0; i < sprite_packing_tags.Count; i++)
            {
                Debug.Log(sprite_packing_tags[i]);
            }

            Debug.Log("没有使用Sprite Packing Tag 或者是Texture 的");
            for (int i = 0; i < empty_list.Count; i++)
            {
                Debug.Log("Path:" + empty_list[i].path);
            }
            // 输出相关信息
        }
Пример #2
0
        public static void CreateAvatarPrefab(GameObject pfb_go, string dir, string middir)
        {
            string pfb_dir_asset_path = EAvatarConst.PREFAB_ASSET_PATH + "/" + middir + "/";
            string material_dir_path  = EAvatarConst.MAT_ASSET_PATH + middir + "/";

            EDirectoryHelper.CreateDirectory(pfb_dir_asset_path);
            // 实例化并且格式化
            GameObject go = Object.Instantiate <GameObject>(pfb_go);

            // 创建子部件
            List <Material> materials = EDirectoryHelper.CollectAll <Material>(material_dir_path);

            SkinnedMeshRenderer[] skinneds = go.GetComponentsInChildren <SkinnedMeshRenderer>(true);



            /* Dictionary<string, SkinnedMeshRenderer> skinned_map = new Dictionary<string, SkinnedMeshRenderer>();
             * for (int i = 0; i < skinneds.Length; i++)
             *   skinned_map.Add(skinneds[i].gameObject.name, skinneds[i]);*/
            /*for (int i = 0; i < materials.Count; i++)
             * {
             *  Material mat = materials[i];
             *
             *  for (int j = 0; j < skinneds.Length; j++)
             *  {
             *      if (mat == null) continue;
             *      if (!mat.name.Contains(obj.name))continue;
             *  }
             *
             * }*/
            foreach (SkinnedMeshRenderer smr in skinneds)
            {
                GameObject new_part_go = Object.Instantiate <GameObject>(smr.gameObject);

                Material mat = FindMaterialByName(materials, smr.gameObject.name);
                TransformHelper.Normalizle(new_part_go);

                SkinnedMeshRenderer newrenderer = new_part_go.GetComponentInChildren <SkinnedMeshRenderer>();
                newrenderer.material = mat;


                EPrefabHelper.CreatePrefab(pfb_dir_asset_path + "/" + new_part_go.name.ToLower() + EAvatarConst.PREAFAB_SUFFIX, new_part_go);
            }
        }
Пример #3
0
        public static void CreateSkeletonPrefab(GameObject pfb_go, string dir, string middir)
        {
            string pfb_dir_asset_path = EAvatarConst.PREFAB_ASSET_PATH + "/" + middir + "/";

            EDirectoryHelper.CreateDirectory(pfb_dir_asset_path);
            // 实例化并且格式化
            GameObject go = Object.Instantiate <GameObject>(pfb_go);

            go.name = middir + EAvatarConst.SKELETON_SUFFIX;
            TransformHelper.Normalizle(go);

            // 剔除SkinnedMeshRenderer
            foreach (SkinnedMeshRenderer smr in go.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                Object.DestroyImmediate(smr.gameObject);
            }

            // 创建Prefab
            EPrefabHelper.CreatePrefab(pfb_dir_asset_path + "/" + go.name.ToLower() + EAvatarConst.PREAFAB_SUFFIX, go);
        }