Skip to content

Commit

Permalink
fixed always transparent background bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MintLily committed Nov 30, 2024
1 parent 353185f commit ddac4c2
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 39 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
</p>

<h2>Updates</h2>
<b>2024-11-30: v1.4.0</b>
<p>
<ul>
<li>Fixed background being transparent when the "Hide Skybox" toggle is unchecked</li>
</ul>
</p>
<b>2024-09-24: v1.3.0</b>
<p>
<ul>
Expand Down Expand Up @@ -134,7 +140,6 @@
<li>Fixed Version Check URL being incorrect</li>
</ul>
</p>

<b>2024-09-29: v1.0.0</b>
<p>
<ul>
Expand Down
28 changes: 28 additions & 0 deletions Unity-Animation-Toggle-Generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<h1>Animation Toggle Generator</h1>
<p>Create simple object toggles on your VRChat avatar with ease.
<br><br>
<i>Inspired by ArhianaDev</i>
</p>

<h2>Download</h2>
<p>Head to <a href="https://mintylabs.booth.pm/items/6130982">Booth</a> or <a href="https://github.com/Minty-Labs/Unity-Tools/releases">Releases</a> or <a href="https://jinxxy.com/MintLily/AnimationToggleGenerator">Jinxxy</a> to download.</p>

<h2>Features</h2>
<ul>
<li>Manually set menu toggle name, separate FXLayer, ExpressionsMenu, and ExpressionParameter files.</li>
<li>Auto detection of Write Defaults</li>
</ul>

<h2>Updates</h2>
<b>2024-10-13: v1.0.1</b>
<p>
<ul>
<li>Fixed Version Check URL being incorrect</li>
</ul>
</p>
<b>2024-09-29: v1.0.0</b>
<p>
<ul>
<li>Initial Release</li>
</ul>
</p>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Debug = UnityEngine.Debug;

public class SnapshotUtility : EditorWindow {
private const string Version = "1.3.0";
private const string Version = "1.4.0";
private const string SaveFileVersion = "2";
private const string LogPrefix = "[<color=#9fffe3>MintySnapshot Utility</color>] ";
private static readonly string ProjectUserAgent = $"MintySnapshot Utility/{Version} Internal UnityWebRequest";
Expand Down Expand Up @@ -240,7 +240,7 @@ private void OnGUI() {
_height = EditorGUILayout.IntField(LanguageModel.Height(_languageSelected), _height) * _resolutionMultiplier;
}

if (_resolutionSelected is 2 or 3) {
if (_resolutionSelected is 4 or 5) {
EditorGUILayout.BeginHorizontal();
_resolutionMultiplier = EditorGUILayout.IntSlider(label: LanguageModel.Multiplier(_languageSelected), _resolutionMultiplier, 1, 16);
EditorGUILayout.EndHorizontal();
Expand Down Expand Up @@ -341,8 +341,8 @@ private void OnGUI() {
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button(LanguageModel.OpenBoothPage(_languageSelected)))
Application.OpenURL("https://mintylabs.booth.pm/items/4949097");
if (GUILayout.Button(LanguageModel.OpenGumroadPage(_languageSelected)))
Application.OpenURL("https://mintylabs.gumroad.com/l/ScreenshotUtility");
// if (GUILayout.Button(LanguageModel.OpenGumroadPage(_languageSelected)))
// Application.OpenURL("https://mintylabs.gumroad.com/l/ScreenshotUtility");
if (GUILayout.Button(LanguageModel.OpenGitHubPage(_languageSelected)))
Application.OpenURL("https://github.com/Minty-Labs/Unity-Tools/releases");
}
Expand All @@ -368,6 +368,10 @@ private void OnGUI() {
GUI.backgroundColor = new Color32(29, 155, 240, 255);
if (GUILayout.Button("X (Twitter)"))
Application.OpenURL("https://x.com/MintLiIy");

GUI.backgroundColor = new Color32(0, 133, 255, 255);
if (GUILayout.Button("Bluesky"))
Application.OpenURL("https://bsky.app/profile/lily.mintylabs.dev");

EditorGUILayout.EndHorizontal();

Expand All @@ -376,11 +380,13 @@ private void OnGUI() {
GUI.backgroundColor = new Color32(252, 77, 80, 255);
if (GUILayout.Button("Booth"))
Application.OpenURL("https://mintylabs.booth.pm/");


GUI.enabled = false;
GUI.backgroundColor = new Color32(255, 144, 232, 255);
if (GUILayout.Button("Gumroad"))
Application.OpenURL("https://mintylabs.gumroad.com/");

GUI.enabled = true;
GUI.backgroundColor = new Color32(12, 14, 29, 255);
if (GUILayout.Button("Jinxxy"))
Application.OpenURL("https://jinxxy.com/MintLily");
Expand Down Expand Up @@ -430,44 +436,32 @@ private static byte[] CaptureSnapshot(bool isTransparent, int width, int height,
EditorGUILayout.HelpBox(LanguageModel.NoCameraError(_languageSelected), MessageType.Error);
return null;
}

if (isTransparent) {
var transRenderTex = new RenderTexture(width, height, (int)TextureFormat.ARGB32);
var normalCamClearFlags = camera.clearFlags;
var normalCamBgColor = camera.backgroundColor;
camera.targetTexture = transRenderTex;
camera.clearFlags = CameraClearFlags.Nothing;
camera.backgroundColor = new Color(0, 0, 0, 0);
camera.nearClipPlane = 0.01f;
var transSnapshot = new Texture2D(width, height, TextureFormat.ARGB32, false);

camera.Render();
RenderTexture.active = transRenderTex;
transSnapshot.ReadPixels(new Rect(0, 0, width, height), 0, 0);

camera.backgroundColor = normalCamBgColor;
camera.clearFlags = normalCamClearFlags;
camera.targetTexture = null;
RenderTexture.active = null;
DestroyImmediate(transRenderTex);

return transSnapshot.EncodeToPNG();
}

var normRenderTex = new RenderTexture(width, height, (int)TextureFormat.ARGB32);
camera.targetTexture = normRenderTex;

var newRenderTex = new RenderTexture(width, height, (int)(isTransparent ? TextureFormat.ARGB32 : TextureFormat.RGB24));
var currentHdrSetting = camera.allowHDR;
var currentCamClearFlags = camera.clearFlags;
var currentCamBgColor = camera.backgroundColor;

camera.targetTexture = newRenderTex;
camera.backgroundColor = new Color(0, 0, 0, isTransparent ? 0 : 1);
camera.nearClipPlane = 0.01f;
var normSnapshot = new Texture2D(width, height, TextureFormat.ARGB32, false);

if (!currentHdrSetting)
camera.allowHDR = true;

var snapshotTexture = new Texture2D(width, height, isTransparent ? TextureFormat.ARGB32 : TextureFormat.RGB24, false);
camera.Render();
RenderTexture.active = normRenderTex;
normSnapshot.ReadPixels(new Rect(0, 0, width, height), 0, 0);
RenderTexture.active = newRenderTex;
snapshotTexture.ReadPixels(new Rect(0, 0, width, height), 0, 0);

// Reset camera settings
camera.backgroundColor = currentCamBgColor;
camera.clearFlags = currentCamClearFlags;
camera.targetTexture = null;
RenderTexture.active = null;
DestroyImmediate(normRenderTex);
camera.allowHDR = currentHdrSetting;
DestroyImmediate(newRenderTex);

return normSnapshot.EncodeToPNG();
return snapshotTexture.EncodeToPNG();
}

private static string ScreenshotName(string width, string height) => $"{Application.productName}_snapshot_{width}x{height}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png";
Expand Down
15 changes: 15 additions & 0 deletions Unity-Snapshot-Utility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
</p>

<h1>Updates</h1>
<b>2024-11-30: v1.4.0</b>
<p>
<ul>
<li>Fixed background being transparent when the "Hide Skybox" toggle is unchecked</li>
</ul>
</p>
<b>2024-09-24: v1.3.0</b>
<p>
<ul>
<li>Added an option to use your Scene View as a camera</li>
<li>Added resolution presets: 240p & 360p</li>
<li>Small code/logic edits</li>
<li>Updated About page layout & links</li>
</ul>
</p>
<b>2024-03-02: v1.2.0</b>
<p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion Unity-Snapshot-Utility/Remote/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0

0 comments on commit ddac4c2

Please sign in to comment.