88using Debug = UnityEngine . Debug ;
99
1010public class SnapshotUtility : EditorWindow {
11- private const string Version = "1.3 .0" ;
11+ private const string Version = "1.4 .0" ;
1212 private const string SaveFileVersion = "2" ;
1313 private const string LogPrefix = "[<color=#9fffe3>MintySnapshot Utility</color>] " ;
1414 private static readonly string ProjectUserAgent = $ "MintySnapshot Utility/{ Version } Internal UnityWebRequest";
@@ -240,7 +240,7 @@ private void OnGUI() {
240240 _height = EditorGUILayout . IntField ( LanguageModel . Height ( _languageSelected ) , _height ) * _resolutionMultiplier ;
241241 }
242242
243- if ( _resolutionSelected is 2 or 3 ) {
243+ if ( _resolutionSelected is 4 or 5 ) {
244244 EditorGUILayout . BeginHorizontal ( ) ;
245245 _resolutionMultiplier = EditorGUILayout . IntSlider ( label : LanguageModel . Multiplier ( _languageSelected ) , _resolutionMultiplier , 1 , 16 ) ;
246246 EditorGUILayout . EndHorizontal ( ) ;
@@ -341,8 +341,8 @@ private void OnGUI() {
341341 EditorGUILayout . BeginHorizontal ( ) ;
342342 if ( GUILayout . Button ( LanguageModel . OpenBoothPage ( _languageSelected ) ) )
343343 Application . OpenURL ( "https://mintylabs.booth.pm/items/4949097" ) ;
344- if ( GUILayout . Button ( LanguageModel . OpenGumroadPage ( _languageSelected ) ) )
345- Application . OpenURL ( "https://mintylabs.gumroad.com/l/ScreenshotUtility" ) ;
344+ // if (GUILayout.Button(LanguageModel.OpenGumroadPage(_languageSelected)))
345+ // Application.OpenURL("https://mintylabs.gumroad.com/l/ScreenshotUtility");
346346 if ( GUILayout . Button ( LanguageModel . OpenGitHubPage ( _languageSelected ) ) )
347347 Application . OpenURL ( "https://github.com/Minty-Labs/Unity-Tools/releases" ) ;
348348 }
@@ -368,6 +368,10 @@ private void OnGUI() {
368368 GUI . backgroundColor = new Color32 ( 29 , 155 , 240 , 255 ) ;
369369 if ( GUILayout . Button ( "X (Twitter)" ) )
370370 Application . OpenURL ( "https://x.com/MintLiIy" ) ;
371+
372+ GUI . backgroundColor = new Color32 ( 0 , 133 , 255 , 255 ) ;
373+ if ( GUILayout . Button ( "Bluesky" ) )
374+ Application . OpenURL ( "https://bsky.app/profile/lily.mintylabs.dev" ) ;
371375
372376 EditorGUILayout . EndHorizontal ( ) ;
373377
@@ -376,11 +380,13 @@ private void OnGUI() {
376380 GUI . backgroundColor = new Color32 ( 252 , 77 , 80 , 255 ) ;
377381 if ( GUILayout . Button ( "Booth" ) )
378382 Application . OpenURL ( "https://mintylabs.booth.pm/" ) ;
379-
383+
384+ GUI . enabled = false ;
380385 GUI . backgroundColor = new Color32 ( 255 , 144 , 232 , 255 ) ;
381386 if ( GUILayout . Button ( "Gumroad" ) )
382387 Application . OpenURL ( "https://mintylabs.gumroad.com/" ) ;
383388
389+ GUI . enabled = true ;
384390 GUI . backgroundColor = new Color32 ( 12 , 14 , 29 , 255 ) ;
385391 if ( GUILayout . Button ( "Jinxxy" ) )
386392 Application . OpenURL ( "https://jinxxy.com/MintLily" ) ;
@@ -430,44 +436,32 @@ private static byte[] CaptureSnapshot(bool isTransparent, int width, int height,
430436 EditorGUILayout . HelpBox ( LanguageModel . NoCameraError ( _languageSelected ) , MessageType . Error ) ;
431437 return null ;
432438 }
433-
434- if ( isTransparent ) {
435- var transRenderTex = new RenderTexture ( width , height , ( int ) TextureFormat . ARGB32 ) ;
436- var normalCamClearFlags = camera . clearFlags ;
437- var normalCamBgColor = camera . backgroundColor ;
438- camera . targetTexture = transRenderTex ;
439- camera . clearFlags = CameraClearFlags . Nothing ;
440- camera . backgroundColor = new Color ( 0 , 0 , 0 , 0 ) ;
441- camera . nearClipPlane = 0.01f ;
442- var transSnapshot = new Texture2D ( width , height , TextureFormat . ARGB32 , false ) ;
443-
444- camera . Render ( ) ;
445- RenderTexture . active = transRenderTex ;
446- transSnapshot . ReadPixels ( new Rect ( 0 , 0 , width , height ) , 0 , 0 ) ;
447-
448- camera . backgroundColor = normalCamBgColor ;
449- camera . clearFlags = normalCamClearFlags ;
450- camera . targetTexture = null ;
451- RenderTexture . active = null ;
452- DestroyImmediate ( transRenderTex ) ;
453-
454- return transSnapshot . EncodeToPNG ( ) ;
455- }
456-
457- var normRenderTex = new RenderTexture ( width , height , ( int ) TextureFormat . ARGB32 ) ;
458- camera . targetTexture = normRenderTex ;
439+
440+ var newRenderTex = new RenderTexture ( width , height , ( int ) ( isTransparent ? TextureFormat . ARGB32 : TextureFormat . RGB24 ) ) ;
441+ var currentHdrSetting = camera . allowHDR ;
442+ var currentCamClearFlags = camera . clearFlags ;
443+ var currentCamBgColor = camera . backgroundColor ;
444+
445+ camera . targetTexture = newRenderTex ;
446+ camera . backgroundColor = new Color ( 0 , 0 , 0 , isTransparent ? 0 : 1 ) ;
459447 camera . nearClipPlane = 0.01f ;
460- var normSnapshot = new Texture2D ( width , height , TextureFormat . ARGB32 , false ) ;
461-
448+ if ( ! currentHdrSetting )
449+ camera . allowHDR = true ;
450+
451+ var snapshotTexture = new Texture2D ( width , height , isTransparent ? TextureFormat . ARGB32 : TextureFormat . RGB24 , false ) ;
462452 camera . Render ( ) ;
463- RenderTexture . active = normRenderTex ;
464- normSnapshot . ReadPixels ( new Rect ( 0 , 0 , width , height ) , 0 , 0 ) ;
453+ RenderTexture . active = newRenderTex ;
454+ snapshotTexture . ReadPixels ( new Rect ( 0 , 0 , width , height ) , 0 , 0 ) ;
465455
456+ // Reset camera settings
457+ camera . backgroundColor = currentCamBgColor ;
458+ camera . clearFlags = currentCamClearFlags ;
466459 camera . targetTexture = null ;
467460 RenderTexture . active = null ;
468- DestroyImmediate ( normRenderTex ) ;
461+ camera . allowHDR = currentHdrSetting ;
462+ DestroyImmediate ( newRenderTex ) ;
469463
470- return normSnapshot . EncodeToPNG ( ) ;
464+ return snapshotTexture . EncodeToPNG ( ) ;
471465 }
472466
473467 private static string ScreenshotName ( string width , string height ) => $ "{ Application . productName } _snapshot_{ width } x{ height } _{ DateTime . Now : yyyy-MM-dd_HH-mm-ss} .png";
0 commit comments