Skip to content

Instantly share code, notes, and snippets.

@AldeRoberge
Created January 20, 2022 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AldeRoberge/b8157590abc166a841e6b81b9192a27a to your computer and use it in GitHub Desktop.
Save AldeRoberge/b8157590abc166a841e6b81b9192a27a to your computer and use it in GitHub Desktop.
// 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