关于AR应用,一个简单的屏幕截图功能可以让你把原本绚丽多彩分享给其他小伙伴,一起快乐的玩耍,科技生活,有趣世界。不说了,直接上代码:
using UnityEngine;
using System.Collections;
using System.IO;
public class GalleryScreenshotExample : MonoBehaviour {
public Texture2D texture;
bool saved = false;
bool saved2 = false;
void Start ()
{
ScreenshotManager.ScreenshotFinishedSaving += ScreenshotSaved;
ScreenshotManager.ImageFinishedSaving += ImageSaved;
}
void OnGUI ()
{
GUILayout.Label("Example scene showing: \n1. how to save a screenshot\n" +
"2. how to save an image from your assets");
if(GUILayout.Button ("Take Screenshot", GUILayout.Width (200), GUILayout.Height(80)))
{
StartCoroutine(ScreenshotManager.Save("MyScreenshot", "Czd", true));
}
if(saved) GUILayout.Label ("Screenshot was successfully saved");
GUILayout.Space(40);