Пример #1
0
        public void ReadFromFile()
        {
            var path = EditorUtility.OpenFilePanel("Load graded file", _settings.FilePath ?? "", "png");

            if (!string.IsNullOrEmpty(path))
            {
                _settings.FilePath = path;

                if (File.Exists(_settings.FilePath))
                {
                    var data = File.ReadAllBytes(_settings.FilePath);

                    var screenshottexture = new Texture2D(16, 16, TextureFormat.ARGB32, false);
                    screenshottexture.LoadImage(data);

                    var imageResult = ImageResult.FromTexture(screenshottexture);

                    if (imageResult != null)
                    {
                        LUTResult lutResult = imageResult.GetLUT(_settings.LUT);

                        if (lutResult != null)
                        {
                            _lutWriter.SaveLUT(lutResult);
                        }

                        lutResult.Release();
                    }

                    Texture2D.DestroyImmediate(screenshottexture);
                }
            }
        }
Пример #2
0
        public void Reload()
        {
            if (string.IsNullOrEmpty(_settings.FilePath))
            {
                ReadFromFile();
                return;
            }

            if (File.Exists(_settings.FilePath))
            {
                var data = File.ReadAllBytes(_settings.FilePath);

                var screenshottexture = new Texture2D(16, 16, TextureFormat.ARGB32, false);
                screenshottexture.LoadImage(data);

                var imageResult = ImageResult.FromTexture(screenshottexture);

                if (imageResult != null)
                {
                    LUTResult lutResult = imageResult.GetLUT(_settings.LUT);

                    if (lutResult != null)
                    {
                        _lutWriter.SaveLUT(lutResult);
                    }

                    lutResult.Release();
                }

                Texture2D.DestroyImmediate(screenshottexture);
            }
            else
            {
                if (EditorUtility.DisplayDialog("File doesnt exist", "Target file doesn't exit. Please select a new one.", "ok", "cancel"))
                {
                    ReadFromFile();
                    return;
                }
            }
        }