Ejemplo n.º 1
0
        /// <summary>
        /// find the  app/data path *.pak  into  m_InternalPakas
        /// find  document path *.pan    into  m_outPaks;
        /// </summary>
        void initAllPakFiles()
        {
            m_InternalPaks.Clear();
            m_OutPaks.Clear();

            string InterPath = null;
//		string outPath=null;

            bool isFileExists = false;
            //InterPath = GTResourceManager.GetSavePath () + "/res/";

            DirectoryInfo internalDir = null;

            FileInfo[] files = null;
            if (InterPath != null)
            {
                internalDir = new DirectoryInfo(InterPath);
                if (internalDir.Exists)
                {
                    //Debug.LogError("get save data path!!!!");
                    files = internalDir.GetFiles("*.PAK", SearchOption.AllDirectories);
                    if (files != null && files.Length != 0)
                    {
                        isFileExists = true;
                    }
                }
            }
            if (isFileExists == false)
            {
                //InterPath = GTResourceManager.GetDataPath ();
                if (InterPath != null)
                {
                    internalDir = new DirectoryInfo(InterPath);
                    if (internalDir.Exists)
                    {
                        //Debug.LogError("get res data path!!!!");
                        files = internalDir.GetFiles("*.PAK", SearchOption.AllDirectories);
                        if (files != null && files.Length != 0)
                        {
                            isFileExists = true;
                        }
                    }
                }
            }



//#if UNITY_IPHONE
//		outPath=Application.persistentDataPath;
//#endif

            //if (InterPath != null)
            //{
            //
            //    DirectoryInfo internalDir = new DirectoryInfo(InterPath);

            if (isFileExists == true && files != null && files.Length != 0 /*&& internalDir != null && internalDir.Exists*/)
            {
                for (int i = 0; i < files.Length; ++i)
                {
                    PakFile ptemfile = new PakFile();

                    // Helper.Log("find pak file:" + files[i].FullName);

                    if (ptemfile.loadPakFile(files [i].FullName) == true)
                    {
                        Helper.Log("load pak file success:" + files [i].FullName);
                        m_InternalPaks.Add(ptemfile);
                    }
                    else
                    {
                        Helper.LogError("load pak file failed:" + files [i].FullName);
                    }
                }
            }

            //}


            //if (outPath != null)
            //{
            //
            //    DirectoryInfo outDir = new DirectoryInfo(outPath);
            //
            //    if (outDir.Exists)
            //    {
            //        FileInfo[] files = outDir.GetFiles("*.PAK", SearchOption.AllDirectories);
            //
            //        for (int i = 0; i < files.Length; ++i)
            //        {
            //            PakFile ptemfile = new PakFile();
            //
            //            Helper.Log("find pak file:" + files[i].FullName);
            //            if (ptemfile.loadPakFile(files[i].FullName) == true)
            //            {
            //                Helper.Log("load pak file success:" + files[i].FullName);
            //                m_OutPaks.Add(ptemfile);
            //
            //            }
            //            else
            //            {
            //                Helper.LogError("load pak file failed:" + files[i].FullName);
            //            }
            //
            //        }
            //    }
            //
            //
            //}
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the texture from pak.  asynchronous load
        /// </summary>
        /// <returns>
        /// The texture from pak.
        /// </returns>
        /// <param name='texture'>
        /// Texture.
        /// </param>
        public IEnumerator  getTextureFromPak(string filename, TextureHolder textureholder)
        {
            /*
             #if UNITY_EDITOR
             *
             * textureholder.m_Texture = loadTextureFromTexturePath(filename);
             * if(textureholder.m_Texture != null)
             * {
             * yield break;
             * }
             #endif
             * //*/

            PakFile pFile = null;

            for (int i = 0; i < m_InternalPaks.Count; ++i)
            {
                if (m_InternalPaks [i] != null && m_InternalPaks [i].ContainFile(filename))
                {
                    pFile = m_InternalPaks [i];
                    break;
                }
            }

            if (pFile == null)
            {
                for (int i = 0; i < m_OutPaks.Count; ++i)
                {
                    if (m_OutPaks [i] != null && m_OutPaks [i].ContainFile(filename))
                    {
                        pFile = m_OutPaks [i];
                    }
                }
            }


            string titu = "icon/titu.png";


            if (pFile != null)
            {
                //Helper.Log("begin ays load texture:"+filename);
                textureholder.m_Texture = pFile.getTextureFromFile(filename);
            }
            else
            {
                for (int i = 0; i < m_InternalPaks.Count; ++i)
                {
                    if (m_InternalPaks [i] != null && m_InternalPaks [i].ContainFile(titu))
                    {
                        pFile = m_InternalPaks [i];
                        break;
                    }
                }
                if (pFile == null)
                {
                    for (int i = 0; i < m_OutPaks.Count; ++i)
                    {
                        if (m_OutPaks [i] != null && m_OutPaks [i].ContainFile(titu))
                        {
                            pFile = m_OutPaks [i];
                        }
                    }
                }

                textureholder.m_Texture = pFile.getTextureFromFile(titu);
                //   Helper.LogError("pFile null " + filename);
            }


            yield return(0);
        }