Created
January 20, 2022 00:28
-
-
Save AldeRoberge/b8157590abc166a841e6b81b9192a27a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uses Odin's Button and the following package to take a 360 capture | |
// https://assetstore.unity.com/packages/tools/camera/360-screenshot-capture-112864 | |
public class Take360Screenshot : MonoBehaviour | |
{ | |
public int imageWidth = 2048; | |
private bool saveAsJPEG = false; | |
[Button] | |
void TakePicture() | |
{ | |
// Take and save the 360 picture using Unity360ScreenshotCapture | |
byte[] bytes = I360Render.Capture(imageWidth, saveAsJPEG); | |
if (bytes != null) | |
{ | |
string filename = "360render" + (saveAsJPEG ? ".jpeg" : ".png"); | |
string path = Path.Combine(Application.persistentDataPath, filename); | |
File.WriteAllBytes(path, bytes); | |
Debug.Log("360 render saved to " + path); | |
// Open the file in explorer application | |
Application.OpenURL(path.RemoveCharactersFromString(filename)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment