예제 #1
0
        public Texture2D GetCachedTexture(string url)
        {
            string             key = CFileManager.GetMd5(url.ToLower());
            CCachedTextureInfo cachedTextureInfo = this.m_cachedTextureInfoSet.GetCachedTextureInfo(key);

            if (cachedTextureInfo != null)
            {
                TimeSpan span = (TimeSpan)(DateTime.Now - cachedTextureInfo.m_lastModifyTime);
                if (span.TotalDays < 2.0)
                {
                    string filePath = CFileManager.CombinePath(s_cachedTextureDirectory, key + ".bytes");
                    if (!CFileManager.IsFileExist(filePath))
                    {
                        return(null);
                    }
                    byte[] buffer = CFileManager.ReadFile(filePath);
                    if ((buffer == null) || (buffer.Length <= 0))
                    {
                        return(null);
                    }
                    Texture2D textured = null;
                    if (cachedTextureInfo.m_isGif)
                    {
                        using (MemoryStream stream = new MemoryStream(buffer))
                        {
                            return(GifHelper.GifToTexture(stream, 0));
                        }
                    }
                    textured = new Texture2D(cachedTextureInfo.m_width, cachedTextureInfo.m_height, TextureFormat.ARGB32, false);
                    textured.LoadImage(buffer);
                    return(textured);
                }
            }
            return(null);
        }
예제 #2
0
    public static string GetSoundBankPathInResources(string bankName)
    {
        string str = string.Empty;

        str = "Sound/Android/";
        return(CFileManager.CombinePath(str, bankName));
    }
예제 #3
0
    //--------------------------------------------------
    /// 文件是否存在于StreamingAssets目录下
    /// @fileName
    //--------------------------------------------------
    public static bool IsFileExistInStreamingAssets(string fileName)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        return(AndroidJavaUtility.Android_IsFileExistInStreamingAssets(fileName));
#else
        return(IsFileExist(CFileManager.CombinePath(Application.streamingAssetsPath, fileName)));
#endif
    }
예제 #4
0
        public void AddCachedTexture(string url, int width, int height, bool isGif, byte[] data)
        {
            string key = CFileManager.GetMd5(url.ToLower());

            if (this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.ContainsKey(key))
            {
                CCachedTextureInfo info = null;
                this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.TryGetValue(key, out info);
                DebugHelper.Assert(this.m_cachedTextureInfoSet.m_cachedTextureInfos.Contains(info), "zen me ke neng?");
                info.m_width          = width;
                info.m_height         = height;
                info.m_lastModifyTime = DateTime.Now;
                info.m_isGif          = isGif;
            }
            else
            {
                if (this.m_cachedTextureInfoSet.m_cachedTextureInfos.Count >= 100)
                {
                    string str2 = this.m_cachedTextureInfoSet.RemoveEarliestTextureInfo();
                    if (!string.IsNullOrEmpty(str2))
                    {
                        string str3 = CFileManager.CombinePath(s_cachedTextureDirectory, str2 + ".bytes");
                        if (CFileManager.IsFileExist(str3))
                        {
                            CFileManager.DeleteFile(str3);
                        }
                    }
                }
                CCachedTextureInfo cachedTextureInfo = new CCachedTextureInfo {
                    m_key            = key,
                    m_width          = width,
                    m_height         = height,
                    m_lastModifyTime = DateTime.Now,
                    m_isGif          = isGif
                };
                this.m_cachedTextureInfoSet.AddTextureInfo(key, cachedTextureInfo);
            }
            this.m_cachedTextureInfoSet.SortTextureInfo();
            int offset = 0;

            this.m_cachedTextureInfoSet.Write(s_buffer, ref offset);
            if (CFileManager.IsFileExist(s_cachedTextureInfoSetFileFullPath))
            {
                CFileManager.DeleteFile(s_cachedTextureInfoSetFileFullPath);
            }
            CFileManager.WriteFile(s_cachedTextureInfoSetFileFullPath, s_buffer, 0, offset);
            string filePath = CFileManager.CombinePath(s_cachedTextureDirectory, key + ".bytes");

            if (CFileManager.IsFileExist(filePath))
            {
                CFileManager.DeleteFile(filePath);
            }
            CFileManager.WriteFile(filePath, data);
        }
예제 #5
0
        public void AddCachedTexture(string url, int width, int height, bool isGif, byte[] data)
        {
            string md = CFileManager.GetMd5(url.ToLower());

            if (this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.ContainsKey(md))
            {
                CCachedTextureInfo cCachedTextureInfo = null;
                this.m_cachedTextureInfoSet.m_cachedTextureInfoMap.TryGetValue(md, ref cCachedTextureInfo);
                DebugHelper.Assert(this.m_cachedTextureInfoSet.m_cachedTextureInfos.Contains(cCachedTextureInfo), "zen me ke neng?");
                cCachedTextureInfo.m_width          = width;
                cCachedTextureInfo.m_height         = height;
                cCachedTextureInfo.m_lastModifyTime = DateTime.get_Now();
                cCachedTextureInfo.m_isGif          = isGif;
            }
            else
            {
                if (this.m_cachedTextureInfoSet.m_cachedTextureInfos.get_Count() >= 100)
                {
                    string text = this.m_cachedTextureInfoSet.RemoveEarliestTextureInfo();
                    if (!string.IsNullOrEmpty(text))
                    {
                        string text2 = CFileManager.CombinePath(CCachedTextureManager.s_cachedTextureDirectory, text + ".bytes");
                        if (CFileManager.IsFileExist(text2))
                        {
                            CFileManager.DeleteFile(text2);
                        }
                    }
                }
                CCachedTextureInfo cCachedTextureInfo2 = new CCachedTextureInfo();
                cCachedTextureInfo2.m_key            = md;
                cCachedTextureInfo2.m_width          = width;
                cCachedTextureInfo2.m_height         = height;
                cCachedTextureInfo2.m_lastModifyTime = DateTime.get_Now();
                cCachedTextureInfo2.m_isGif          = isGif;
                this.m_cachedTextureInfoSet.AddTextureInfo(md, cCachedTextureInfo2);
            }
            this.m_cachedTextureInfoSet.SortTextureInfo();
            int num = 0;

            this.m_cachedTextureInfoSet.Write(CCachedTextureManager.s_buffer, ref num);
            if (CFileManager.IsFileExist(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath))
            {
                CFileManager.DeleteFile(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath);
            }
            CFileManager.WriteFile(CCachedTextureManager.s_cachedTextureInfoSetFileFullPath, CCachedTextureManager.s_buffer, 0, num);
            string text3 = CFileManager.CombinePath(CCachedTextureManager.s_cachedTextureDirectory, md + ".bytes");

            if (CFileManager.IsFileExist(text3))
            {
                CFileManager.DeleteFile(text3);
            }
            CFileManager.WriteFile(text3, data);
        }
예제 #6
0
    //----------------------------------------------
    /// 构建IFSMountPoint
    /// @用于区别哪种路径需要从IFS中读取
    //----------------------------------------------
    public static string MakeMountPoint(string ifsFileName)
    {
        if (s_ifsMountPath == null)
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            s_ifsMountPath = CFileManager.CombinePath(Application.dataPath, string.Format("/assets/{0}", ifsFileName));
#else
            s_ifsMountPath = CFileManager.CombinePath(Application.streamingAssetsPath, string.Format("/{0}", ifsFileName));
#endif
        }

        return(s_ifsMountPath);
    }
예제 #7
0
 public void Load(string ifsExtractPath)
 {
     if (this.m_isAbandon)
     {
         this.m_state = enResourceState.Unload;
         return;
     }
     byte[] array = CFileManager.ReadFile(CFileManager.CombinePath(ifsExtractPath, this.m_fileFullPathInResources));
     this.m_state = enResourceState.Loaded;
     if (array != null)
     {
         CBinaryObject cBinaryObject = ScriptableObject.CreateInstance <CBinaryObject>();
         cBinaryObject.m_data = array;
         cBinaryObject.name   = this.m_name;
         this.m_content       = cBinaryObject;
     }
 }
예제 #8
0
    public void LoadResourcePackerInfoSet()
    {
        if (this.m_resourcePackerInfoSet != null)
        {
            this.m_resourcePackerInfoSet.Dispose();
            this.m_resourcePackerInfoSet = null;
        }
        string filePath = CFileManager.CombinePath(CFileManager.GetIFSExtractPath(), CResourcePackerInfoSet.s_resourcePackerInfoSetFileName);

        if (CFileManager.IsFileExist(filePath))
        {
            byte[] data = CFileManager.ReadFile(filePath);
            int    num  = 0;
            this.m_resourcePackerInfoSet = new CResourcePackerInfoSet();
            this.m_resourcePackerInfoSet.Read(data, ref num);
            CVersion.SetUsedResourceVersion(this.m_resourcePackerInfoSet.m_version);
            this.m_resourcePackerInfoSet.CreateResourceMap();
        }
    }
예제 #9
0
 public void Load(string ifsExtractPath)
 {
     if (this.m_isAbandon)
     {
         this.m_state = enResourceState.Unload;
     }
     else
     {
         byte[] buffer = CFileManager.ReadFile(CFileManager.CombinePath(ifsExtractPath, this.m_fileFullPathInResources));
         this.m_state = enResourceState.Loaded;
         if (buffer != null)
         {
             CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>();
             obj2.m_data    = buffer;
             obj2.name      = this.m_name;
             this.m_content = obj2;
         }
     }
 }
 public static string CombinePaths(params string[] values)
 {
     if (values.Length <= 0)
     {
         return(string.Empty);
     }
     if (values.Length == 1)
     {
         return(CFileManager.CombinePath(values[0], string.Empty));
     }
     if (values.Length > 1)
     {
         string text = CFileManager.CombinePath(values[0], values[1]);
         for (int i = 2; i < values.Length; i++)
         {
             text = CFileManager.CombinePath(text, values[i]);
         }
         return(text);
     }
     return(string.Empty);
 }
예제 #11
0
        public Texture2D GetCachedTexture(string url, float validDays)
        {
            string             md = CFileManager.GetMd5(url.ToLower());
            CCachedTextureInfo cachedTextureInfo = this.m_cachedTextureInfoSet.GetCachedTextureInfo(md);

            if (cachedTextureInfo == null || (DateTime.get_Now() - cachedTextureInfo.m_lastModifyTime).get_TotalDays() >= (double)validDays)
            {
                return(null);
            }
            string text = CFileManager.CombinePath(CCachedTextureManager.s_cachedTextureDirectory, md + ".bytes");

            if (!CFileManager.IsFileExist(text))
            {
                return(null);
            }
            byte[] array = CFileManager.ReadFile(text);
            if (array == null || array.Length <= 0)
            {
                return(null);
            }
            Texture2D texture2D = null;

            if (cachedTextureInfo.m_isGif)
            {
                using (MemoryStream memoryStream = new MemoryStream(array))
                {
                    texture2D = GifHelper.GifToTexture(memoryStream, 0);
                }
            }
            else
            {
                texture2D = new Texture2D(cachedTextureInfo.m_width, cachedTextureInfo.m_height, TextureFormat.ARGB32, false);
                texture2D.LoadImage(array);
            }
            return(texture2D);
        }