Ejemplo n.º 1
0
        /// <summary>
        /// 载入一个预制体资源
        /// </summary>
        /// <param name="db">资源数据</param>
        /// <param name="name">资源名</param>
        /// <returns></returns>
        public unsafe static PrefabAsset LoadModels(DataBuffer db, string name)
        {
            var fake  = db.fakeStruct;
            var asset = new PrefabAsset();

            asset.models = fake.GetData <FakeStruct>(0);
            Int16[] arr = fake.GetData <Int16[]>(1);
            if (arr != null)
            {
                FakeStruct[] fsa = new FakeStruct[arr.Length];
                for (int i = 0; i < arr.Length; i++)
                {
                    fsa[i] = db.GetData(arr[i]) as FakeStruct;
                }
                asset.tables = fsa;
            }
            asset.Version = fake.GetData <string>(2);
            asset.name    = name;
            for (int i = 0; i < prefabAssets.Count; i++)
            {
                if (prefabAssets[i].name == name)
                {
                    prefabAssets.RemoveAt(i);
                    break;
                }
            }
            prefabAssets.Add(asset);
            return(asset);
        }
Ejemplo n.º 2
0
        public unsafe static PrefabAsset LoadModels(byte[] buff, string name)
        {
            DataBuffer db    = new DataBuffer(buff);
            var        asset = new PrefabAsset();

            asset.models = db.fakeStruct;
            asset.name   = name;
            for (int i = 0; i < prefabAssets.Count; i++)
            {
                if (prefabAssets[i].name == name)
                {
                    prefabAssets.RemoveAt(i); break;
                }
            }
            prefabAssets.Add(asset);
            return(asset);
        }