8
8
using Debug = UnityEngine . Debug ;
9
9
10
10
public class SnapshotUtility : EditorWindow {
11
- private const string Version = "1.3 .0" ;
11
+ private const string Version = "1.4 .0" ;
12
12
private const string SaveFileVersion = "2" ;
13
13
private const string LogPrefix = "[<color=#9fffe3>MintySnapshot Utility</color>] " ;
14
14
private static readonly string ProjectUserAgent = $ "MintySnapshot Utility/{ Version } Internal UnityWebRequest";
@@ -240,7 +240,7 @@ private void OnGUI() {
240
240
_height = EditorGUILayout . IntField ( LanguageModel . Height ( _languageSelected ) , _height ) * _resolutionMultiplier ;
241
241
}
242
242
243
- if ( _resolutionSelected is 2 or 3 ) {
243
+ if ( _resolutionSelected is 4 or 5 ) {
244
244
EditorGUILayout . BeginHorizontal ( ) ;
245
245
_resolutionMultiplier = EditorGUILayout . IntSlider ( label : LanguageModel . Multiplier ( _languageSelected ) , _resolutionMultiplier , 1 , 16 ) ;
246
246
EditorGUILayout . EndHorizontal ( ) ;
@@ -341,8 +341,8 @@ private void OnGUI() {
341
341
EditorGUILayout . BeginHorizontal ( ) ;
342
342
if ( GUILayout . Button ( LanguageModel . OpenBoothPage ( _languageSelected ) ) )
343
343
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");
346
346
if ( GUILayout . Button ( LanguageModel . OpenGitHubPage ( _languageSelected ) ) )
347
347
Application . OpenURL ( "https://github.com/Minty-Labs/Unity-Tools/releases" ) ;
348
348
}
@@ -368,6 +368,10 @@ private void OnGUI() {
368
368
GUI . backgroundColor = new Color32 ( 29 , 155 , 240 , 255 ) ;
369
369
if ( GUILayout . Button ( "X (Twitter)" ) )
370
370
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" ) ;
371
375
372
376
EditorGUILayout . EndHorizontal ( ) ;
373
377
@@ -376,11 +380,13 @@ private void OnGUI() {
376
380
GUI . backgroundColor = new Color32 ( 252 , 77 , 80 , 255 ) ;
377
381
if ( GUILayout . Button ( "Booth" ) )
378
382
Application . OpenURL ( "https://mintylabs.booth.pm/" ) ;
379
-
383
+
384
+ GUI . enabled = false ;
380
385
GUI . backgroundColor = new Color32 ( 255 , 144 , 232 , 255 ) ;
381
386
if ( GUILayout . Button ( "Gumroad" ) )
382
387
Application . OpenURL ( "https://mintylabs.gumroad.com/" ) ;
383
388
389
+ GUI . enabled = true ;
384
390
GUI . backgroundColor = new Color32 ( 12 , 14 , 29 , 255 ) ;
385
391
if ( GUILayout . Button ( "Jinxxy" ) )
386
392
Application . OpenURL ( "https://jinxxy.com/MintLily" ) ;
@@ -430,44 +436,32 @@ private static byte[] CaptureSnapshot(bool isTransparent, int width, int height,
430
436
EditorGUILayout . HelpBox ( LanguageModel . NoCameraError ( _languageSelected ) , MessageType . Error ) ;
431
437
return null ;
432
438
}
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 ) ;
459
447
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 ) ;
462
452
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 ) ;
465
455
456
+ // Reset camera settings
457
+ camera . backgroundColor = currentCamBgColor ;
458
+ camera . clearFlags = currentCamClearFlags ;
466
459
camera . targetTexture = null ;
467
460
RenderTexture . active = null ;
468
- DestroyImmediate ( normRenderTex ) ;
461
+ camera . allowHDR = currentHdrSetting ;
462
+ DestroyImmediate ( newRenderTex ) ;
469
463
470
- return normSnapshot . EncodeToPNG ( ) ;
464
+ return snapshotTexture . EncodeToPNG ( ) ;
471
465
}
472
466
473
467
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