//----------------------------------------------------------------------------------------------------------------------
        void DrawPreviewImage(ref PreviewDrawInfo drawInfo, TimelineClip clip, StreamingImageSequencePlayableAsset sisAsset)
        {
            int imageIndex = sisAsset.LocalTimeToImageIndex(clip, drawInfo.LocalTime);

            IList <string> imageFileNames = sisAsset.GetImageFileNames();

            //Load
            string imagePath = sisAsset.GetImageFilePath(imageIndex);

            ImageLoader.GetImageDataInto(imagePath, StreamingImageSequenceConstants.IMAGE_TYPE_PREVIEW
                                         , out ImageData readResult);

            switch (readResult.ReadStatus)
            {
            case StreamingImageSequenceConstants.READ_STATUS_LOADING:
                break;

            case StreamingImageSequenceConstants.READ_STATUS_SUCCESS: {
                Texture2D tex = PreviewTextureFactory.GetOrCreate(imagePath, ref readResult);
                if (null != tex)
                {
                    Graphics.DrawTexture(drawInfo.DrawRect, tex);
                }
                break;
            }

            default: {
                ImageLoader.RequestLoadPreviewImage(imagePath, (int)drawInfo.DrawRect.width, (int)drawInfo.DrawRect.height);
                break;
            }
            }
        }
//----------------------------------------------------------------------------------------------------------------------

        void DrawPreviewImage(ref PreviewDrawInfo drawInfo, TimelineClip clip,
                              RenderCachePlayableAsset renderCachePlayableAsset)
        {
            double         normalizedLocalTime = drawInfo.LocalTime / clip.duration;
            IList <string> imageFileNames      = renderCachePlayableAsset.GetImageFileNames();

            Assert.IsNotNull(imageFileNames);

            int count = imageFileNames.Count;

            Assert.IsTrue(imageFileNames.Count > 0);

            int index = Mathf.RoundToInt(count * (float)normalizedLocalTime);

            index = Mathf.Clamp(index, 0, count - 1);


            //Load
            string imagePath = renderCachePlayableAsset.GetImageFilePath(index);

            if (!File.Exists(imagePath))
            {
                return;
            }

            ImageLoader.GetImageDataInto(imagePath, StreamingImageSequenceConstants.IMAGE_TYPE_PREVIEW
                                         , out ImageData imageData);

            switch (imageData.ReadStatus)
            {
            case StreamingImageSequenceConstants.READ_STATUS_LOADING:
                break;

            case StreamingImageSequenceConstants.READ_STATUS_SUCCESS: {
                Texture2D tex = PreviewTextureFactory.GetOrCreate(imagePath, ref imageData);
                if (null != tex)
                {
                    Graphics.DrawTexture(drawInfo.DrawRect, tex);
                }
                break;
            }

            default: {
                ImageLoader.RequestLoadPreviewImage(imagePath, (int)drawInfo.DrawRect.width, (int)drawInfo.DrawRect.height);
                break;
            }
            }
        }
示例#3
0
        private static void ShowLoadedImages()
        {
            StringBuilder sb = new StringBuilder();

            for (int imageType = 0; imageType < StreamingImageSequenceConstants.MAX_IMAGE_TYPES; ++imageType)
            {
                sb.AppendLine("IMAGE_TYPE: " + imageType.ToString());

                List <string> loadedTextures = new List <string>();
                StreamingImageSequencePlugin.ListLoadedImages(imageType, (fileName) => {
                    loadedTextures.Add(fileName);
                });

                foreach (var fileName in loadedTextures)
                {
                    ImageLoader.GetImageDataInto(fileName, imageType, out ImageData readResult);
                    sb.Append("    ");
                    sb.Append(fileName);
                    sb.Append(". Status: " + readResult.ReadStatus);
                    sb.Append(", Size: (" + readResult.Width + ", " + readResult.Height);
                    sb.AppendLine(") ");
                }

                sb.AppendLine("----------------------------------------------------------------");
                sb.AppendLine();
                sb.AppendLine();
            }

            sb.AppendLine("Preview Textures: ");
            IDictionary <string, PreviewTexture> previewTextures = PreviewTextureFactory.GetPreviewTextures();

            foreach (var kvp in previewTextures)
            {
                sb.Append("    ");
                sb.AppendLine(kvp.Key);
            }

            Debug.Log(sb.ToString());
        }
示例#4
0
 static void PreviewTextureFactory_OnSceneCreated( Scene scene, NewSceneSetup setup, NewSceneMode mode) {
     PreviewTextureFactory.Reset();
 }
示例#5
0
 static void PreviewTextureFactory_OnSceneClosed(Scene scene) {
     PreviewTextureFactory.Reset();
 }
示例#6
0
 private static void Reset()
 {
     EditorUpdateManager.ResetImageLoading();
     PreviewTextureFactory.Reset();
 }