Ejemplo n.º 1
0
        /// <summary>
        /// 从Resources中读取数据
        /// </summary>
        private static byte[] ReadFromResources(string fileName)
        {
            IResourceMgr resourceMgr = Framework.GameKernel.GetResourceMgr();

            byte[] streamBytes = resourceMgr.LoadConfigFile("ProtobufDataConfig/" + fileName, "bytes");

            //byte[] streamBytes = null;
            //string filePath = "ProtobufDataConfig/" + fileName;
            //string fileUrl = string.Format("{0}{1}.bytes", BundleConfig.Instance.BundlesPathForPersist, filePath);
            //if (!File.Exists(fileUrl))
            //{
            //    TextAsset asset = Resources.Load<TextAsset>(filePath);
            //    if (asset != null)
            //    {
            //        streamBytes = asset.bytes;
            //    }
            //}
            //else
            //{
            //    using (FileStream fs = new FileStream(fileUrl, FileMode.Open))
            //    {
            //        BinaryReader br = new BinaryReader(fs);
            //        streamBytes = br.ReadBytes((int)fs.Length);
            //    }
            //}

            return(streamBytes);
        }