public static bool ValidateImportSettings(Texture2D tex, bool isLUT) { if (!tex) { return(false); } bool valid = false; var importer = (TextureImporter)AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(tex)); if (importer != null) // Fails when using a non-persistent texture { valid = isLUT ? LUTUtilities.IsValidLUT(importer) : LUTUtilities.IsValidScreenshot(importer); if (!valid) { EditorGUILayout.HelpBox("Invalid import settings.", MessageType.Warning); GUILayout.Space(-32); using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Fix", GUILayout.Width(60))) { LUTUtilities.SetSSImportSettings(importer); valid = true; AssetDatabase.Refresh(); } GUILayout.Space(8); } GUILayout.Space(11); } } return(valid); }
private void OnGUI() { EditorGUILayout.Space(); using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Capture scene screenshot", null, "Captures a 720p screenshot from the scene-view and inserts a neutral LUT in the bottom-left corner\n\n" + "This file is saved to the Assets folder and automatically assigned as the input screenshot below\n\n" + "You can make any color adjustments to this screenshot. Once saved, the now modified LUT will be extracted and copied into the target LUT file"))) { LUTUtilities.CaptureScreenshotWithLUT(); } GUILayout.FlexibleSpace(); } EditorGUILayout.Space(); using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { GUILayout.Label("Input screenshot (8-bit depth)", EditorStyles.boldLabel); using (new EditorGUILayout.HorizontalScope()) { if (useAssetInput) { inputTexture = (Texture2D)EditorGUILayout.ObjectField(inputTexture, typeof(Texture2D), true); if (inputTexture) { LUTExtracter.InputName = inputTexture.name; } } /* * else * { * EditorGUILayout.TextField(LUTExtracter.InputPath, SCPE.SCPE_GUI.PathField); * if (GUILayout.Button("...", GUILayout.Width(50f))) * { * LUTExtracter.InputPath = EditorUtility.OpenFilePanel("Screenshot destination folder", LUTExtracter.InputPath, ""); * } * } */ if (GUILayout.Button("Open", GUILayout.Width(50f))) { if (inputTexture) { AssetDatabase.OpenAsset(inputTexture); } } } ValidateImportSettings(inputTexture, false); EditorGUILayout.Space(); } EditorGUILayout.Space(); using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { string lutLabel = (OutputLUT != null) ? " (" + OutputLUT.width + "x" + OutputLUT.height + ")" : string.Empty; GUILayout.Label("Output LUT" + lutLabel, EditorStyles.boldLabel); OutputLUT = (Texture2D)EditorGUILayout.ObjectField(OutputLUT, typeof(Texture2D), true); ValidateImportSettings(OutputLUT, true); EditorGUILayout.Space(); } if (inputTexture == null || OutputLUT == null) { EditorGUILayout.HelpBox("Empty input or output", MessageType.Warning); } EditorGUILayout.Space(); using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); using (new EditorGUI.DisabledGroupScope(inputTexture == null || OutputLUT == null || LUTExtracter.AutoExtract)) { if (GUILayout.Button(new GUIContent(" Extract", EditorGUIUtility.IconContent("LookDevObjRotation").image), GUILayout.Width(150f))) { LUTExtracter.ExtractLUT(inputTexture, OutputLUT); } } GUILayout.FlexibleSpace(); //LUTExtracter.AutoExtract = EditorGUILayout.ToggleLeft("Automatic", LUTExtracter.AutoExtract); } if (LUTExtracter.AutoExtract) { EditorGUILayout.HelpBox("Extracting on screenshot file change", MessageType.None); } }