예제 #1
0
        private static void WriteMd5Record(Dictionary <string, string> value, string folderPath, Md5Record record)
        {
            if (record == null)
            {
                record       = new Md5Record();
                record.value = new Dictionary <string, List <string> >();
            }
            string        buildTarget = AssetPathHelper.GetBuildTarget(AssetPathHelper.GetBuildTarget());
            List <string> tokenList   = new List <string>();

            foreach (string key in value.Keys)
            {
                tokenList.Add(key);
                tokenList.Add(value[key]);
            }
            if (record.value.Keys.Contains(buildTarget))
            {
                record.value[buildTarget] = tokenList;
            }
            else
            {
                record.value.Add(buildTarget, tokenList);
            }
            string content = JsonMapper.ToJson(record);

            content = content.Replace("\"Assets/Things/", "\n\"Assets/Things/");
            string path = GetMd5RecordPath(folderPath);

            WriteJson(content, path);
        }
예제 #2
0
    // 返回贴图打包的平台名字
    public static string GetTextureBuildTargetName()
    {
        switch (AssetPathHelper.GetBuildTarget())
        {
        case BuildTarget.StandaloneWindows:
        case BuildTarget.StandaloneWindows64:
        case BuildTarget.StandaloneOSX:
            return("Standalone");

        case BuildTarget.Android:
            return("Android");

        case BuildTarget.iOS:
            return("iPhone");
        }
        return("Standalone");
    }
예제 #3
0
        /// <summary>
        /// 返回值 Key为资源路径,Value为资源Md5值,资源包括meta文件
        /// </summary>
        /// <param name="folderPath"></param>
        /// <returns></returns>
        private static Dictionary <string, string> ReadMd5(Md5Record record)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();

            if (record != null)
            {
                string buildTarget = AssetPathHelper.GetBuildTarget(AssetPathHelper.GetBuildTarget());
                if (record.value.Keys.Contains(buildTarget))
                {
                    List <string> tokenList = record.value[buildTarget];
                    for (int i = 0; i < tokenList.Count; i += 2)
                    {
                        result.Add(tokenList[i], tokenList[i + 1]);
                    }
                }
            }
            return(result);
        }
예제 #4
0
        public static TextureImporterFormat GetTextureFormat()
        {
            switch (AssetPathHelper.GetBuildTarget())
            {
            case BuildTarget.StandaloneWindows:
            case BuildTarget.StandaloneWindows64:
            case BuildTarget.StandaloneOSXIntel:
            case BuildTarget.StandaloneOSXIntel64:
                return(TextureImporterFormat.DXT5);

            case BuildTarget.Android:
                return(TextureImporterFormat.ETC_RGB4);

            case BuildTarget.iOS:
                return(TextureImporterFormat.PVRTC_RGBA4);
            }
            return(TextureImporterFormat.DXT1);
        }
예제 #5
0
        private static Texture2D CreateAtlas(string atlasPath, TextureData[] textureDatas)
        {
            Texture2D atlas = new Texture2D(ATLAS_MAX_SIZE, ATLAS_MAX_SIZE);

            Rect[] rects = atlas.PackTextures(GetPackTextures(textureDatas), 0, ATLAS_MAX_SIZE, false);
            AtlasWriter.Write(atlas, atlasPath);
            int    atlasWidth     = atlas.width;
            int    atlasHeight    = atlas.height;
            string alphaAtlasPath = atlasPath.Replace(".png", "_alpha.png");

            AssetDatabase.ImportAsset(atlasPath, ImportAssetOptions.ForceUpdate);
            //安卓平台图集分离通道
            if (AssetPathHelper.GetBuildTarget() == BuildTarget.Android && !atlasPath.Contains("UI_Base"))
            {
                try
                {
                    ImageChannelSpliterWrapper.Execute(atlasPath);
                    AssetDatabase.ImportAsset(alphaAtlasPath, ImportAssetOptions.ForceUpdate);
                    TextureImporterUtil.CreateAlphaChannelImporter(alphaAtlasPath);
                    AssetDatabase.ImportAsset(alphaAtlasPath, ImportAssetOptions.ForceUpdate);
                }
                catch (Exception e)
                {
                    Debug.LogError("通道分离过程中发生错误: " + e.Message);
                    Debug.LogException(e);
                }
            }
            TextureImporterFormat textureFormat = TextureImporterUtil.GetTextureFormat();

            if (atlasPath.Contains("UI_Base"))
            {
                textureFormat = TextureImporterFormat.ARGB32;
            }
            AssetDatabase.ImportAsset(atlasPath, ImportAssetOptions.ForceUpdate);
            TextureImporterUtil.CreateMultipleSpriteImporter(atlasPath, rects, GetPackTexturesNames(textureDatas), GetSpriteBorders(textureDatas),
                                                             atlasWidth, atlasHeight, textureFormat, ATLAS_MAX_SIZE);
            AssetDatabase.ImportAsset(atlasPath, ImportAssetOptions.ForceUpdate);
            MaterialCreator.Create(atlasPath, alphaAtlasPath);
            return(atlas);
        }
예제 #6
0
 private static BuildTarget GetBuildTarget()
 {
     return(AssetPathHelper.GetBuildTarget());
 }
예제 #7
0
 public static string GetShadowPrefabFolderRoot()
 {
     return(string.Format(UI_PREFAB_ROOT_SHADOW, AssetPathHelper.GetBuildTarget(AssetPathHelper.GetBuildTarget())));
 }
예제 #8
0
 public static string GetShadowTextureFolderRoot()
 {
     return(string.Format(UI_TEXTURE_ROOT_SHADOW, AssetPathHelper.GetBuildTarget(AssetPathHelper.GetBuildTarget())));
 }