728x90
문답무용! 스크린샷, 스냅샷 F12로 찍기 :)
예제
private void Update()
{
#if UNITY_STANDALONE_WIN
if (Input.GetKeyDown("f12"))
Screenshot();
#endif
}
/// <summary>
/// 스냅샷
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public void Screenshot()
{
StartCoroutine(MakeSnapshot());
}
byte[] m_ImageByte;
IEnumerator MakeSnapshot()
{
yield return new WaitForEndOfFrame();
Texture2D tex = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, true);
tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
tex.Apply();
m_ImageByte = tex.EncodeToPNG();
DirectoryInfo dirInfo = new DirectoryInfo(string.Format("{0}/Screenshot", Application.dataPath));
if (dirInfo.Exists == false)
dirInfo.Create();
string sFullPath = string.Format("{0}/Screenshot/Image_{1}.png", Application.dataPath, DateTime.Now.ToString("yyyyMMddHmmss"));
File.WriteAllBytes(sFullPath, m_ImageByte);
Debug.LogFormat("### Save Screenshot {0}", sFullPath);
DestroyImmediate(tex);
}
728x90
'프로그래밍 > Unity' 카테고리의 다른 글
m_AssetBundleManifest 이 null 일 때 (0) | 2018.09.28 |
---|---|
FPS (Frame Per Sec) Display 표시, 출력하기 (0) | 2018.09.10 |
Super ScrollView (0) | 2018.01.24 |
[Unity3D] Singleton (0) | 2018.01.03 |
[Unity3D] Enable 과 Awake (0) | 2018.01.03 |
댓글