Exemplo n.º 1
0
        private StreamingTexture CreateStreamingTexture(Texture obj, ref ImageDescription imageDescription, ref ContentStorageHeader storageHeader)
        {
            // Get content storage container
            var storage = ContentStreaming.GetStorage(ref storageHeader);

            if (storage == null)
            {
                throw new ContentStreamingException("Missing content storage.");
            }

            // Find resource or create new
            var resource = Get(obj);

            if (resource == null)
            {
                resource = new StreamingTexture(this, obj);
                RegisterResource(resource);
            }

            // Update resource storage/description information (may be modified on asset rebuilding)
            resource.Init(storage, ref imageDescription);

            // Check if cannot use streaming
            if (!Enabled)
            {
                FullyLoadResource(resource);
            }

            return(resource);
        }
Exemplo n.º 2
0
        private void SetResourceStreamingOptions(StreamingTexture resource, StreamingOptions options, bool combineOptions)
        {
            var alreadyHasOptions = resource.StreamingOptions.HasValue;
            var newOptions        = combineOptions && alreadyHasOptions?options.CombineWith(resource.StreamingOptions.Value) : options;

            lock (resources)
            {
                resource.StreamingOptions = newOptions;

                if (newOptions.LoadImmediately)
                {
                    // ensure that the resource is not currently streaming
                    if (!resource.CanBeUpdated)
                    {
                        resource.StopStreaming();
                        FlushSync();
                    }

                    // Stream resource to the maximum level
                    FullyLoadResource(resource);
                }
            }
        }