-
Notifications
You must be signed in to change notification settings - Fork 0
Oculus Camera App Prototype #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
462fae1
de94403
b7dd7ae
9f23d47
2495a99
84f8b6f
7bf7a42
050a269
2f47ddf
28d0ca6
7a15515
16e6cd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| using UnityEngine; | ||
| using UnityEngine.UI; | ||
| using System.Collections; | ||
|
|
||
| public class ScreenShotScript : MonoBehaviour | ||
| { | ||
|
|
||
| public AudioSource shutterAudio; | ||
| public RawImage screenShot; | ||
| private Texture2D screenShotTexture; | ||
| private string lastScreenShotPath; | ||
|
|
||
| // Use this for initialization | ||
| void Start () | ||
| { | ||
| screenShotTexture = new Texture2D (100, 100); | ||
| screenShot.texture = screenShotTexture; | ||
| } | ||
|
|
||
| // Update is called once per frame | ||
| void Update () | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void OnGUI () | ||
| { | ||
| Event e = Event.current; | ||
|
|
||
| if (e.type == EventType.KeyDown && e.keyCode == KeyCode.F) { | ||
| string current_time = System.DateTime.Now.ToString ().Replace ("/", "_").Replace (":", "_"); | ||
| lastScreenShotPath = Application.temporaryCachePath + "/" + current_time + ".png"; | ||
| Debug.Log ("Screenshot saved: " + lastScreenShotPath); | ||
| TakeScreenShot (lastScreenShotPath); | ||
| shutterAudio.Play (); | ||
| } | ||
| } | ||
|
|
||
| void LateUpdate () | ||
| { | ||
| StartCoroutine (DisplayScreenShot ()); | ||
| } | ||
|
|
||
| private void TakeScreenShot (string path) | ||
| { | ||
| StartCoroutine (CaptureScreen (path)); | ||
| } | ||
|
|
||
| private IEnumerator CaptureScreen (string path) | ||
| { | ||
| // Wait till the last possible moment before screen rendering to hide the UI | ||
| yield return null; | ||
|
|
||
| // Wait for screen rendering to complete | ||
| yield return new WaitForEndOfFrame (); | ||
|
|
||
| // Take screenshot | ||
| Application.CaptureScreenshot (path); | ||
| } | ||
|
|
||
| private IEnumerator DisplayScreenShot () | ||
| { | ||
| yield return null; | ||
|
|
||
| if (System.IO.File.Exists (lastScreenShotPath)) { | ||
| Debug.Log ("Last screenshot found!"); | ||
| var screenShotBytes = System.IO.File.ReadAllBytes (lastScreenShotPath); | ||
| screenShotTexture.LoadImage (screenShotBytes); | ||
| screenShot.material.mainTexture = screenShotTexture; | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,80 @@ Transform: | |
| m_Children: [] | ||
| m_Father: {fileID: 0} | ||
| m_RootOrder: 2 | ||
| --- !u!1 &614197765 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the file
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah if 'UnityEditor' is not available, which path should I use to save the screenshot?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I'll change the code and the scene name |
||
| GameObject: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| serializedVersion: 4 | ||
| m_Component: | ||
| - 224: {fileID: 614197769} | ||
| - 222: {fileID: 614197768} | ||
| - 114: {fileID: 614197767} | ||
| - 114: {fileID: 614197766} | ||
| m_Layer: 5 | ||
| m_Name: LastScreenShot | ||
| m_TagString: Untagged | ||
| m_Icon: {fileID: 0} | ||
| m_NavMeshLayer: 0 | ||
| m_StaticEditorFlags: 0 | ||
| m_IsActive: 1 | ||
| --- !u!114 &614197766 | ||
| MonoBehaviour: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 614197765} | ||
| m_Enabled: 1 | ||
| m_EditorHideFlags: 0 | ||
| m_Script: {fileID: 11500000, guid: 8ae231a950bd349ba978d2b63ffc82c7, type: 3} | ||
| m_Name: | ||
| m_EditorClassIdentifier: | ||
| shutterAudio: {fileID: 1001552816} | ||
| screenShot: {fileID: 614197767} | ||
| --- !u!114 &614197767 | ||
| MonoBehaviour: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 614197765} | ||
| m_Enabled: 1 | ||
| m_EditorHideFlags: 0 | ||
| m_Script: {fileID: -98529514, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} | ||
| m_Name: | ||
| m_EditorClassIdentifier: | ||
| m_Material: {fileID: 0} | ||
| m_Color: {r: 1, g: 1, b: 1, a: 1} | ||
| m_Texture: {fileID: 0} | ||
| m_UVRect: | ||
| serializedVersion: 2 | ||
| x: 0 | ||
| y: 0 | ||
| width: 1 | ||
| height: 1 | ||
| --- !u!222 &614197768 | ||
| CanvasRenderer: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 614197765} | ||
| --- !u!224 &614197769 | ||
| RectTransform: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 614197765} | ||
| m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
| m_LocalPosition: {x: 0, y: 0, z: 0} | ||
| m_LocalScale: {x: 1, y: 1, z: 1} | ||
| m_Children: [] | ||
| m_Father: {fileID: 1655184830} | ||
| m_RootOrder: 0 | ||
| m_AnchorMin: {x: .5, y: .5} | ||
| m_AnchorMax: {x: .5, y: .5} | ||
| m_AnchoredPosition: {x: 0, y: 0} | ||
| m_SizeDelta: {x: 100, y: 100} | ||
| m_Pivot: {x: .5, y: .5} | ||
| --- !u!1 &1001552815 | ||
| GameObject: | ||
| m_ObjectHideFlags: 0 | ||
|
|
@@ -213,7 +287,7 @@ GameObject: | |
| - 4: {fileID: 1001552817} | ||
| - 82: {fileID: 1001552816} | ||
| m_Layer: 0 | ||
| m_Name: Audio Source | ||
| m_Name: ScreenShotShutterAudioSource | ||
| m_TagString: Untagged | ||
| m_Icon: {fileID: 0} | ||
| m_NavMeshLayer: 0 | ||
|
|
@@ -228,7 +302,7 @@ AudioSource: | |
| m_Enabled: 1 | ||
| serializedVersion: 4 | ||
| OutputAudioMixerGroup: {fileID: 0} | ||
| m_audioClip: {fileID: 8300000, guid: 4a64aea7c38a8432996fe575a7fc694e, type: 3} | ||
| m_audioClip: {fileID: 8300000, guid: 8ceb0f4b3eec34e7fb161b668911eb22, type: 3} | ||
| m_PlayOnAwake: 0 | ||
| m_Volume: 1 | ||
| m_Pitch: 1 | ||
|
|
@@ -295,11 +369,22 @@ Transform: | |
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 1001552815} | ||
| m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
| m_LocalPosition: {x: 2, y: 19, z: 159} | ||
| m_LocalPosition: {x: 0, y: 0, z: 0} | ||
| m_LocalScale: {x: 1, y: 1, z: 1} | ||
| m_Children: [] | ||
| m_Father: {fileID: 0} | ||
| m_RootOrder: 3 | ||
| --- !u!1 &1074163266 stripped | ||
| GameObject: | ||
| m_PrefabParentObject: {fileID: 120736, guid: 3ec5dd60dda4e49ba89053ede7744b29, type: 2} | ||
| m_PrefabInternal: {fileID: 460777660} | ||
| --- !u!81 &1074163271 | ||
| AudioListener: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 1074163266} | ||
| m_Enabled: 1 | ||
| --- !u!1 &1243471458 | ||
| GameObject: | ||
| m_ObjectHideFlags: 0 | ||
|
|
@@ -360,3 +445,93 @@ Transform: | |
| m_Children: [] | ||
| m_Father: {fileID: 0} | ||
| m_RootOrder: 1 | ||
| --- !u!1 &1655184829 | ||
| GameObject: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| serializedVersion: 4 | ||
| m_Component: | ||
| - 224: {fileID: 1655184830} | ||
| - 223: {fileID: 1655184833} | ||
| - 114: {fileID: 1655184832} | ||
| - 114: {fileID: 1655184831} | ||
| m_Layer: 5 | ||
| m_Name: ScreenShotCanvas | ||
| m_TagString: Untagged | ||
| m_Icon: {fileID: 0} | ||
| m_NavMeshLayer: 0 | ||
| m_StaticEditorFlags: 0 | ||
| m_IsActive: 1 | ||
| --- !u!224 &1655184830 | ||
| RectTransform: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 1655184829} | ||
| m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||
| m_LocalPosition: {x: 0, y: 0, z: 128} | ||
| m_LocalScale: {x: 1, y: 1, z: 1} | ||
| m_Children: | ||
| - {fileID: 614197769} | ||
| m_Father: {fileID: 0} | ||
| m_RootOrder: 4 | ||
| m_AnchorMin: {x: .5, y: .5} | ||
| m_AnchorMax: {x: .5, y: .5} | ||
| m_AnchoredPosition: {x: 0, y: 0} | ||
| m_SizeDelta: {x: 100, y: 100} | ||
| m_Pivot: {x: .5, y: .5} | ||
| --- !u!114 &1655184831 | ||
| MonoBehaviour: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 1655184829} | ||
| m_Enabled: 1 | ||
| m_EditorHideFlags: 0 | ||
| m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} | ||
| m_Name: | ||
| m_EditorClassIdentifier: | ||
| m_IgnoreReversedGraphics: 1 | ||
| m_BlockingObjects: 0 | ||
| m_BlockingMask: | ||
| serializedVersion: 2 | ||
| m_Bits: 4294967295 | ||
| --- !u!114 &1655184832 | ||
| MonoBehaviour: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 1655184829} | ||
| m_Enabled: 1 | ||
| m_EditorHideFlags: 0 | ||
| m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} | ||
| m_Name: | ||
| m_EditorClassIdentifier: | ||
| m_UiScaleMode: 0 | ||
| m_ReferencePixelsPerUnit: 100 | ||
| m_ScaleFactor: 1 | ||
| m_ReferenceResolution: {x: 800, y: 600} | ||
| m_ScreenMatchMode: 0 | ||
| m_MatchWidthOrHeight: 0 | ||
| m_PhysicalUnit: 3 | ||
| m_FallbackScreenDPI: 96 | ||
| m_DefaultSpriteDPI: 96 | ||
| m_DynamicPixelsPerUnit: 1 | ||
| --- !u!223 &1655184833 | ||
| Canvas: | ||
| m_ObjectHideFlags: 0 | ||
| m_PrefabParentObject: {fileID: 0} | ||
| m_PrefabInternal: {fileID: 0} | ||
| m_GameObject: {fileID: 1655184829} | ||
| m_Enabled: 1 | ||
| serializedVersion: 2 | ||
| m_RenderMode: 2 | ||
| m_Camera: {fileID: 0} | ||
| m_PlaneDistance: 100 | ||
| m_PixelPerfect: 0 | ||
| m_ReceivesEvents: 1 | ||
| m_OverrideSorting: 0 | ||
| m_OverridePixelPerfect: 0 | ||
| m_SortingLayerID: 0 | ||
| m_SortingOrder: 0 | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reasons, this path has a problem. After replacing
Application.temporaryCachePathwith~/Desktop/, the number of errors are dramatically decreased.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my machine this is how it's like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That "Application.temporaryCachePath" returns a path for temporary usage. reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this was my misunderstanding. Path has no problem.