/// <summary>
        /// Creates an asset cache which caches objects used in scene
        /// </summary>
        /// <param name="root">A glTF root whose assets will eventually be cached here</param>
        public AssetCache(GLTFRoot root)
        {
            ImageCache       = new Texture2D[root.Images?.Count ?? 0];
            ImageStreamCache = new Stream[ImageCache.Length];
            TextureCache     = new TextureCacheData[root.Textures?.Count ?? 0];
            MaterialCache    = new MaterialCacheData[root.Materials?.Count ?? 0];
            BufferCache      = new BufferCacheData[root.Buffers?.Count ?? 0];
            MeshCache        = new MeshCacheData[root.Meshes?.Count ?? 0];

            NodeCache      = new GameObject[root.Nodes?.Count ?? 0];
            AnimationCache = new AnimationCacheData[root.Animations?.Count ?? 0];
        }
Example #2
0
        /// <summary>
        /// Creates an asset cache which caches objects used in scene
        /// </summary>
        /// <param name="root">A glTF root whose assets will eventually be cached here</param>
        public AssetCache(GLTFRoot root)
        {
            ImageCache       = new Texture2D[root.Images?.Count ?? 0];
            ImageStreamCache = new Stream[ImageCache.Length];
            TextureCache     = new TextureCacheData[root.Textures?.Count ?? 0];
            MaterialCache    = new MaterialCacheData[root.Materials?.Count ?? 0];
            BufferCache      = new BufferCacheData[root.Buffers?.Count ?? 0];
            MeshCache        = new MeshCacheData[root.Meshes?.Count ?? 0][];
            for (int i = 0; i < MeshCache.Length; ++i)
            {
                MeshCache[i] = new MeshCacheData[root.Meshes?[i].Primitives.Count ?? 0];
            }

            NodeCache      = new GameObject[root.Nodes?.Count ?? 0];
            AnimationCache = new AnimationCacheData[root.Animations?.Count ?? 0];
        }