예제 #1
0
        private void ExecuteShaderTextureSave(FrameDebuggerEventData frameInfo)
        {
            if (!(this.captureFlag.HasFlag(CaptureFlag.ShaderTexture)))
            {
                return;
            }
            var textureParams = frameInfo.convertedProperties.convertedTextures;

            foreach (var textureParam in textureParams)
            {
                TextureUtility.SaveTextureInfo saveTextureInfo = null;
                var texture = textureParam.value as Texture;
                if (texture == null)
                {
                    continue;
                }

                // save texture
                string dir = System.IO.Path.Combine(this.saveDirectory, "shaderTexture");
                if (!System.IO.Directory.Exists(dir))
                {
                    System.IO.Directory.CreateDirectory(dir);
                }
                if (texture.GetType() == typeof(Texture2D))
                {
                    saveTextureInfo = SaveTexture2D((Texture2D)texture, dir);
                }
                if (texture.GetType() == typeof(RenderTexture))
                {
                    saveTextureInfo = SaveRenderTexture((RenderTexture)texture, dir);
                }
                textureParam.saveTextureInfo = saveTextureInfo;
            }
        }
예제 #2
0
        private TextureUtility.SaveTextureInfo SaveTexture2D(Texture2D texture, string dir)
        {
            TextureUtility.SaveTextureInfo saveTextureInfo = null;

            // already saved texture
            if (alreadyWriteTextureDict.TryGetValue(texture.GetInstanceID(), out saveTextureInfo))
            {
                return(saveTextureInfo);
            }
            string path = System.IO.Path.Combine(dir, texture.name + "_" + texture.GetInstanceID());;

            saveTextureInfo = TextureUtility.SaveTexture((Texture2D)texture, path);
            alreadyWriteTextureDict.Add(texture.GetInstanceID(), saveTextureInfo);
            return(saveTextureInfo);
        }
예제 #3
0
        private static TextureUtility.SaveTextureInfo Convert(SavedTextureInfo info)
        {
            TextureFormat format = TextureFormat.R8;

            foreach (var val in System.Enum.GetValues(typeof(TextureFormat)))
            {
                if (val.ToString() == info.rawFormat)
                {
                    format = (TextureFormat)val;
                    break;
                }
            }
            TextureUtility.SaveTextureInfo convert = new TextureUtility.SaveTextureInfo(info.path, info.type,
                                                                                        info.width, info.height, format, info.mipCount);
            return(convert);
        }
예제 #4
0
        private TextureUtility.SaveTextureInfo SaveRenderTexture(RenderTexture texture, string dir)
        {
            TextureUtility.SaveTextureInfo saveTextureInfo = null;
            int renderTextureChangedIdx = -1;

            renderTextureLastChanged.TryGetValue(texture.GetInstanceID(), out renderTextureChangedIdx);
            SavedRenderTextureInfo savedRTInfo = new SavedRenderTextureInfo(texture.GetInstanceID(), renderTextureChangedIdx);

            // not saved
            if (!this.savedRenderTexture.TryGetValue(savedRTInfo, out saveTextureInfo))
            {
                string path = System.IO.Path.Combine(dir, "RT_" + renderTextureChangedIdx + "_" + texture.name);
                saveTextureInfo = TextureUtility.SaveRenderTexture((RenderTexture)texture, path);
                savedRenderTexture.Add(savedRTInfo, saveTextureInfo);
            }
            return(saveTextureInfo);
        }
예제 #5
0
 private void AppendSavedTextureInfo(JsonStringGenerator jsonStringGenerator, string objName, TextureUtility.SaveTextureInfo saveInfo)
 {
     if (saveInfo == null)
     {
         return;
     }
     using (new JsonStringGenerator.ObjectScopeWithName(jsonStringGenerator, objName))
     {
         jsonStringGenerator.AddObjectValue("path", saveInfo.path);
         jsonStringGenerator.AddObjectValue("type", saveInfo.type);
         jsonStringGenerator.AddObjectValue("width", saveInfo.width);
         jsonStringGenerator.AddObjectValue("height", saveInfo.height);
         jsonStringGenerator.AddObjectValue("mipCount", saveInfo.mipCount);
         jsonStringGenerator.AddObjectValue("rawFormat", saveInfo.rawFormat.ToString());
     }
 }