diff --git a/Assets/Animations/NewSettingsBack.anim b/Assets/Animations/NewSettingsBack.anim index c2e3567..f346712 100644 --- a/Assets/Animations/NewSettingsBack.anim +++ b/Assets/Animations/NewSettingsBack.anim @@ -292,11 +292,4 @@ AnimationClip: m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 - m_Events: - - time: 0.33333334 - functionName: OnClose - data: - objectReferenceParameter: {fileID: 0} - floatParameter: 0 - intParameter: 0 - messageOptions: 0 + m_Events: [] diff --git a/Assets/Animations/NewSettingsClose.anim b/Assets/Animations/NewSettingsClose.anim index 2173f2f..94aa40b 100644 --- a/Assets/Animations/NewSettingsClose.anim +++ b/Assets/Animations/NewSettingsClose.anim @@ -176,4 +176,11 @@ AnimationClip: m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 - m_Events: [] + m_Events: + - time: 0 + functionName: OnClose + data: + objectReferenceParameter: {fileID: 0} + floatParameter: 0 + intParameter: 0 + messageOptions: 0 diff --git a/Assets/Scenes/LevelMenu.unity b/Assets/Scenes/LevelMenu.unity index c3dfd04..b16c2d8 100644 --- a/Assets/Scenes/LevelMenu.unity +++ b/Assets/Scenes/LevelMenu.unity @@ -1072,7 +1072,6 @@ GameObject: - component: {fileID: 420997512} - component: {fileID: 420997511} - component: {fileID: 420997510} - - component: {fileID: 420997513} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -1145,24 +1144,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &420997513 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 420997509} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a6e6e15bdc9f3f458c572dde1eaf007, type: 3} - m_Name: - m_EditorClassIdentifier: - captureWidth: 1080 - captureHeight: 1920 - hideGameObject: {fileID: 0} - optimizeForManyScreenshots: 1 - format: 2 - folder: --- !u!1 &460077773 GameObject: m_ObjectHideFlags: 0 @@ -4437,7 +4418,6 @@ GameObject: - component: {fileID: 1600350853} - component: {fileID: 1600350852} - component: {fileID: 1600350856} - - component: {fileID: 1600350857} m_Layer: 5 m_Name: Canvas m_TagString: Untagged @@ -4541,18 +4521,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: safeAreaRect: {fileID: 889844611} ---- !u!114 &1600350857 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1600350851} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: eadc0d2b4912bf34588a5a2b6ffd2a94, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &1631024869 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Lvl10.unity b/Assets/Scenes/Lvl10.unity index 9a5758f..89d6eb2 100644 --- a/Assets/Scenes/Lvl10.unity +++ b/Assets/Scenes/Lvl10.unity @@ -240,7 +240,6 @@ GameObject: - component: {fileID: 68151475} - component: {fileID: 68151473} - component: {fileID: 68151474} - - component: {fileID: 68151476} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -313,24 +312,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &68151476 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 68151472} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a6e6e15bdc9f3f458c572dde1eaf007, type: 3} - m_Name: - m_EditorClassIdentifier: - captureWidth: 1080 - captureHeight: 1920 - hideGameObject: {fileID: 0} - optimizeForManyScreenshots: 1 - format: 2 - folder: --- !u!4 &147113769 stripped Transform: m_CorrespondingSourceObject: {fileID: 3515597459712862942, guid: e24ea1f9b56630c428fd1c7aeb0d6ccc, type: 3} diff --git a/Assets/Scenes/Lvl2.unity b/Assets/Scenes/Lvl2.unity index 087a357..80e9922 100644 --- a/Assets/Scenes/Lvl2.unity +++ b/Assets/Scenes/Lvl2.unity @@ -1292,7 +1292,6 @@ GameObject: - component: {fileID: 1436291393} - component: {fileID: 1436291391} - component: {fileID: 1436291392} - - component: {fileID: 1436291394} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -1365,24 +1364,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1436291394 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1436291390} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a6e6e15bdc9f3f458c572dde1eaf007, type: 3} - m_Name: - m_EditorClassIdentifier: - captureWidth: 1080 - captureHeight: 1920 - hideGameObject: {fileID: 0} - optimizeForManyScreenshots: 1 - format: 2 - folder: --- !u!1001 &1456843510 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index a6de6f1..9bccbe0 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -136,7 +136,6 @@ GameObject: - component: {fileID: 62725457} - component: {fileID: 62725456} - component: {fileID: 62725460} - - component: {fileID: 62725461} m_Layer: 5 m_Name: Canvas m_TagString: Untagged @@ -239,18 +238,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: safeAreaRect: {fileID: 1342841530} ---- !u!114 &62725461 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 62725455} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: eadc0d2b4912bf34588a5a2b6ffd2a94, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &385496312 stripped GameObject: m_CorrespondingSourceObject: {fileID: 53865515122254991, guid: 3d7c6767b6a8f22499cdbc61e15bae76, type: 3} @@ -282,7 +269,6 @@ GameObject: - component: {fileID: 854964415} - component: {fileID: 854964414} - component: {fileID: 854964413} - - component: {fileID: 854964416} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -355,24 +341,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &854964416 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 854964412} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a6e6e15bdc9f3f458c572dde1eaf007, type: 3} - m_Name: - m_EditorClassIdentifier: - captureWidth: 1080 - captureHeight: 1920 - hideGameObject: {fileID: 0} - optimizeForManyScreenshots: 1 - format: 2 - folder: --- !u!1 &1296630632 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Tutorial.unity b/Assets/Scenes/Tutorial.unity index 7087ecf..76a4158 100644 --- a/Assets/Scenes/Tutorial.unity +++ b/Assets/Scenes/Tutorial.unity @@ -1535,7 +1535,6 @@ GameObject: - component: {fileID: 1543167983} - component: {fileID: 1543167981} - component: {fileID: 1543167982} - - component: {fileID: 1543167984} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -1608,24 +1607,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1543167984 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1543167980} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0a6e6e15bdc9f3f458c572dde1eaf007, type: 3} - m_Name: - m_EditorClassIdentifier: - captureWidth: 1080 - captureHeight: 1920 - hideGameObject: {fileID: 0} - optimizeForManyScreenshots: 1 - format: 2 - folder: --- !u!1001 &1595957028 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/ScreenRecorder.cs b/Assets/Scripts/ScreenRecorder.cs index bb09ec5..65f9870 100644 --- a/Assets/Scripts/ScreenRecorder.cs +++ b/Assets/Scripts/ScreenRecorder.cs @@ -1,163 +1,170 @@ +using System.IO; +using System.Text; +using System.Threading; using UnityEngine; - using System.Collections; - using System.IO; - - // Screen Recorder will save individual images of active scene in any resolution and of a specific image format - // including raw, jpg, png, and ppm. Raw and PPM are the fastest image formats for saving. - // - // You can compile these images into a video using ffmpeg: - // ffmpeg -i screen_3840x2160_%d.ppm -y test.avi - - public class ScreenRecorder : MonoBehaviour - { - // 4k = 3840 x 2160 1080p = 1920 x 1080 - public int captureWidth = 1080; - public int captureHeight = 1920; - - // optional game object to hide during screenshots (usually your scene canvas hud) - public GameObject hideGameObject; - - // optimize for many screenshots will not destroy any objects so future screenshots will be fast - public bool optimizeForManyScreenshots = true; - - // configure with raw, jpg, png, or ppm (simple raw format) - public enum Format { RAW, JPG, PNG, PPM }; - public Format format = Format.PNG; - - // folder to write output (defaults to data path) - public string folder; - - // private vars for screenshot - private Rect rect; - private RenderTexture renderTexture; - private Texture2D screenShot; - private int counter = 0; // image # - - // commands - private bool captureScreenshot = false; - private bool captureVideo = false; - - // create a unique filename using a one-up variable - private string uniqueFilename(int width, int height) - { - // if folder not specified by now use a good default - if (folder == null || folder.Length == 0) - { - folder = Application.dataPath; - if (Application.isEditor) - { - // put screenshots in folder above asset path so unity doesn't index the files - var stringPath = folder + "/.."; - folder = Path.GetFullPath(stringPath); - } - folder += "/screenshots"; - - // make sure directoroy exists - System.IO.Directory.CreateDirectory(folder); - - // count number of files of specified format in folder - string mask = string.Format("screen_{0}x{1}*.{2}", width, height, format.ToString().ToLower()); - counter = Directory.GetFiles(folder, mask, SearchOption.TopDirectoryOnly).Length; - } - - // use width, height, and counter for unique file name - var filename = string.Format("{0}/screen_{1}x{2}_{3}.{4}", folder, width, height, counter, format.ToString().ToLower()); - - // up counter for next call - ++counter; - - // return unique filename - return filename; - } - - public void CaptureScreenshot() - { - captureScreenshot = true; - } - - void Update() - { - // check keyboard 'k' for one time screenshot capture and holding down 'v' for continious screenshots - captureScreenshot |= Input.GetKeyDown("k"); - captureVideo = Input.GetKey("v"); - - if (captureScreenshot || captureVideo) - { - captureScreenshot = false; - - // hide optional game object if set - if (hideGameObject != null) hideGameObject.SetActive(false); - - // create screenshot objects if needed - if (renderTexture == null) - { - // creates off-screen render texture that can rendered into - rect = new Rect(0, 0, captureWidth, captureHeight); - renderTexture = new RenderTexture(captureWidth, captureHeight, 24); - screenShot = new Texture2D(captureWidth, captureHeight, TextureFormat.RGB24, false); - } - - // get main camera and manually render scene into rt - Camera camera = this.GetComponent(); // NOTE: added because there was no reference to camera in original script; must add this script to Camera - camera.targetTexture = renderTexture; - camera.Render(); - - // read pixels will read from the currently active render texture so make our offscreen - // render texture active and then read the pixels - RenderTexture.active = renderTexture; - screenShot.ReadPixels(rect, 0, 0); - - // reset active camera texture and render texture - camera.targetTexture = null; - RenderTexture.active = null; - - // get our unique filename - string filename = uniqueFilename((int) rect.width, (int) rect.height); - - // pull in our file header/data bytes for the specified image format (has to be done from main thread) - byte[] fileHeader = null; - byte[] fileData = null; - if (format == Format.RAW) - { - fileData = screenShot.GetRawTextureData(); - } - else if (format == Format.PNG) - { - fileData = screenShot.EncodeToPNG(); - } - else if (format == Format.JPG) - { - fileData = screenShot.EncodeToJPG(); - } - else // ppm - { - // create a file header for ppm formatted file - string headerStr = string.Format("P6\n{0} {1}\n255\n", rect.width, rect.height); - fileHeader = System.Text.Encoding.ASCII.GetBytes(headerStr); - fileData = screenShot.GetRawTextureData(); - } - - // create new thread to save the image to file (only operation that can be done in background) - new System.Threading.Thread(() => - { - // create file and write optional header with image bytes - var f = System.IO.File.Create(filename); - if (fileHeader != null) f.Write(fileHeader, 0, fileHeader.Length); - f.Write(fileData, 0, fileData.Length); - f.Close(); - Debug.Log(string.Format("Wrote screenshot {0} of size {1}", filename, fileData.Length)); - }).Start(); - - // unhide optional game object if set - if (hideGameObject != null) hideGameObject.SetActive(true); - - // cleanup if needed - if (optimizeForManyScreenshots == false) - { - Destroy(renderTexture); - renderTexture = null; - screenShot = null; - } - } - } - } \ No newline at end of file + +// Screen Recorder will save individual images of active scene in any resolution and of a specific image format +// including raw, jpg, png, and ppm. Raw and PPM are the fastest image formats for saving. + +// You can compile these images into a video using ffmpeg: +// ffmpeg -i screen_3840x2160_%d.ppm -y test.avi + +public class ScreenRecorder : MonoBehaviour +{ + // configure with raw, jpg, png, or ppm (simple raw format) + public enum Format + { + Raw, + Jpg, + Png, + Ppm + } + + public int captureWidth = 1080; + public int captureHeight = 1920; + + // optional game object to hide during screenshots (usually your scene canvas hud) + public GameObject hideGameObject; + + // optimize for many screenshots will not destroy any objects so future screenshots will be fast + public bool optimizeForManyScreenshots = true; + public Format format = Format.Png; + + // folder to write output (defaults to data path) + public string folder; + + // commands + private bool _captureScreenshot; + private bool _captureVideo; + private int _counter; // image # + + // private vars for screenshot + private Rect _rect; + private RenderTexture _renderTexture; + private Texture2D _screenShot; + + private void Update() + { + // check keyboard 'k' for one time screenshot capture and holding down 'v' for continious screenshots + _captureScreenshot |= Input.GetKeyDown("k"); + _captureVideo = Input.GetKey("v"); + + if (_captureScreenshot || _captureVideo) + { + _captureScreenshot = false; + + // hide optional game object if set + if (hideGameObject != null) hideGameObject.SetActive(false); + + // create screenshot objects if needed + if (_renderTexture == null) + { + // creates off-screen render texture that can rendered into + _rect = new Rect(0, 0, captureWidth, captureHeight); + _renderTexture = new RenderTexture(captureWidth, captureHeight, 24); + _screenShot = new Texture2D(captureWidth, captureHeight, TextureFormat.RGB24, false); + } + + // get main camera and manually render scene into rt + var camera = GetComponent(); // NOTE: added because there was no reference to camera in original script; must add this script to Camera + camera.targetTexture = _renderTexture; + camera.Render(); + + // read pixels will read from the currently active render texture so make our offscreen + // render texture active and then read the pixels + RenderTexture.active = _renderTexture; + _screenShot.ReadPixels(_rect, 0, 0); + + // reset active camera texture and render texture + camera.targetTexture = null; + RenderTexture.active = null; + + // get our unique filename + var filename = UniqueFilename((int) _rect.width, (int) _rect.height); + + // pull in our file header/data bytes for the specified image format (has to be done from main thread) + byte[] fileHeader = null; + byte[] fileData; + if (format == Format.Raw) + { + fileData = _screenShot.GetRawTextureData(); + } + else if (format == Format.Png) + { + fileData = _screenShot.EncodeToPNG(); + } + else if (format == Format.Jpg) + { + fileData = _screenShot.EncodeToJPG(); + } + else // ppm + { + // create a file header for ppm formatted file + var headerStr = $"P6\n{_rect.width} {_rect.height}\n255\n"; + fileHeader = Encoding.ASCII.GetBytes(headerStr); + fileData = _screenShot.GetRawTextureData(); + } + + // create new thread to save the image to file (only operation that can be done in background) + new Thread(() => + { + // create file and write optional header with image bytes + var f = File.Create(filename); + if (fileHeader != null) f.Write(fileHeader, 0, fileHeader.Length); + f.Write(fileData, 0, fileData.Length); + f.Close(); + Debug.Log($"Wrote screenshot {filename} of size {fileData.Length}"); + }).Start(); + + // unhide optional game object if set + if (hideGameObject != null) hideGameObject.SetActive(true); + + // cleanup if needed + if (optimizeForManyScreenshots == false) + { + Destroy(_renderTexture); + _renderTexture = null; + _screenShot = null; + } + } + } + + // create a unique filename using a one-up variable + private string UniqueFilename(int width, int height) + { + // if folder not specified by now use a good default + if (string.IsNullOrEmpty(folder)) + { + folder = Application.dataPath; + if (Application.isEditor) + { + // put screenshots in folder above asset path so unity doesn't index the files + var stringPath = folder + "/.."; + folder = Path.GetFullPath(stringPath); + } + + folder += "/screenshots"; + + // make sure directoroy exists + Directory.CreateDirectory(folder); + + // count number of files of specified format in folder + var mask = $"screen_{width}x{height}*.{format.ToString().ToLower()}"; + _counter = Directory.GetFiles(folder, mask, SearchOption.TopDirectoryOnly).Length; + } + + // use width, height, and counter for unique file name + var filename = $"{folder}/screen_{width}x{height}_{_counter}.{format.ToString().ToLower()}"; + + // up counter for next call + ++_counter; + + // return unique filename + return filename; + } + + public void CaptureScreenshot() + { + _captureScreenshot = true; + } +} \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 0124b52..5f4a051 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -129,7 +129,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 1.0.9 + bundleVersion: 1.0.10 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 @@ -158,8 +158,8 @@ PlayerSettings: iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 1 - AndroidBundleVersionCode: 2 - AndroidMinSdkVersion: 24 + AndroidBundleVersionCode: 3 + AndroidMinSdkVersion: 21 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: