Exemplo n.º 1
0
        /// <summary>
        /// 将场景内的对象保存到文件
        /// </summary>
        /// <param name="uiRoot"></param>
        /// <param name="path"></param>
        public static void SavePrefab(Transform uiRoot, string path)
        {
            DataBuffer db = new DataBuffer(1024);

            db.fakeStruct = GameBuffer.GetDataLoader(0).LoadFromObject(uiRoot, db);
            File.WriteAllBytes(path, db.ToBytes());
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uiRoot"></param>
        /// <returns></returns>
        public static DataBuffer GetPrefab(Transform uiRoot)
        {
            DataBuffer db     = new DataBuffer(1024);
            var        loader = GameBuffer.GetDataLoader(0);
            var        root   = loader.LoadFromObject(uiRoot, db);

            FakeStruct fake = new FakeStruct(db, 3);

            fake[0] = db.AddData(root);
            var list = AddDataTable(db);
            int c    = list.Count;

            Int16[] arr = new Int16[c];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = (Int16)db.AddData(list[i]);
            }
            fake[1]       = db.AddData(arr);
            fake[2]       = db.AddData(Version);
            db.fakeStruct = fake;
            return(db);
        }