How to Save Screenshots From Your Game - Unity Tutorial #5

  Рет қаралды 12,968

MaxMakesGames

MaxMakesGames

Күн бұрын

Пікірлер: 84
@SassyPantsy
@SassyPantsy 2 жыл бұрын
If anybody has any issues accessing NativeGallery from a script (i.e vsStudio or whatever doesn't recognize it and gives a red error line), transfer NativeGallery's folders to your script files.
@mikewigen8646
@mikewigen8646 3 жыл бұрын
omg yes! Dude. I've been following 10 different tutorials and read thousands of forum posts and I always got soldi black screenshots, they never show my stuff but your tut worked for me. thank you.
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
I'm glad it worked !
@marcellyrangel5419
@marcellyrangel5419 3 жыл бұрын
Man thank you so much for doing everything that I asked, you made me so happy you have no idea! You’re such a nice person, and your tutorials are 10/10 👌🏻😍
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
Thanks a lot ! And no problem, your ideas were good. Don't hesitate to ask if you want to see other things :)
@belajashark
@belajashark Жыл бұрын
Thank you so much, I exactly need taking screenshots without UI elements!!!!
@qabashameed7136
@qabashameed7136 2 жыл бұрын
Thank you so much for this video. It works from the first run I spent days for this solution and this is the only one that worked
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Glad I could help 😃
@haroo315
@haroo315 Жыл бұрын
Thank you so much!! I've been struggling with this problem and your video solved everything 😆 Have a great day! 👍
@MaxMakesGames
@MaxMakesGames Жыл бұрын
Thanks for watching, you too !
@28mukromka84
@28mukromka84 Ай бұрын
i love you man, u just save my life, thank u
@cloudbaseddev4913
@cloudbaseddev4913 3 жыл бұрын
Really Helpful Bro!! Subscribed!
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
Thanks a lot ! :)
@Wonder_Verse_Tech
@Wonder_Verse_Tech 3 жыл бұрын
You are a life saver, I got irritated from others video on screenshot and want some latest video. Will implement it in my game. Thank you. All the best , you will definitely grow so much. Edit : Bro please help, screenshot is not showing anywhere in my mobile... Where it is saved??
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
Thank you, if you use the Native Gallery package like I did after 6:43 the image should be saved into your gallery path so "On Android, your images/videos are saved at DCIM/album/filename. On iOS 14+, the image/video will be saved to the default Photos album (i.e. album parameter will be ignored). On earlier iOS versions, the image/video will be saved to the target album. Make sure that the filename parameter includes the file's extension, as well". If you use the PC code before 6:43 then it will be saved in your app's folder so you can only see it by exploring the files, not in your gallery. If you used Native Gallery and used the same code I did and made sure your file name is valid ( some characters may not be allowed and you need it to end with the right extension like .png ) and it did not work, you can try reading the github page for possible fixes or contact the devs, I didn't make the package so I can't help you if you get errors. github.com/yasirkula/UnityNativeGallery
@sevemz3359
@sevemz3359 3 жыл бұрын
Thank you, you made the process easier
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
Glad to hear that! :D
@hardworkerstudio
@hardworkerstudio 3 ай бұрын
Thank you very much for the tutorial, I followed you because of this tutorial! So.. for the Android I have to enable Developer mode every time? and my customer need to do it too? and for the iOS users?
@Yukisando
@Yukisando 8 ай бұрын
Thanks bud! Cool plugin.
@erbiis9961
@erbiis9961 Жыл бұрын
hello, is the savemanager script in the empty gameobject affecting the screenshot saving process? i dont see it when i create the empty gameobject and when i go through with all the steps, the screenshot is not taken
@elirapendora2397
@elirapendora2397 2 жыл бұрын
Uhmmm I have a question it works fine for me in Unity Thank you very much ! But I have a small problem when I build it and try to screenshot it doesn't work for some reason I dont need to save it I just need to pass the texture to the object it works in the compiler but when built it doesn't
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Hmmm that's very strange. I suggest you look on the plug-in GitHub page. They have a QnA where they explain how to fix common errors. I didn't make the plug-in so I couldn't tell you how to fix that, sorry.
@liviwilmore7337
@liviwilmore7337 2 жыл бұрын
Great Tutorial! Seem to be falling at a very early hurdle though; When I add my GameObject with the script attached to my button, Under function TakeScreenshot isn't listed under my Screenshot script. My script for this looks just like yours; public void TakeScreenshot() { StartCoroutine("DoScreenshot"); } Any ideas why this might be? My project is an AR project if you think that might effect anything at all?
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Hmmm that is really strange. If you have a public void TakeScreenshot() in your script, when you drag your gameobject with your script in your button, the function should appear. Do you see any other functions of your script appear ? Are you sure you dragged the right one ? Did you save your file after adding the function so Unity can see it ? You can also try restarting your project.
@hirannair5041
@hirannair5041 2 жыл бұрын
I'm getting this error: "ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame."
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Hmmm it seems like this could be due to when the code is ran. If it is ran in the middle or between frames, it could do that. Make sure you are yielding until the end of the frame like I did in the video at the top of the screenshot function. ( like this: docs.unity3d.com/ScriptReference/WaitForEndOfFrame.html ). This way, you can make sure the scene is done drawing before reading so you make sure everything is in the screenshot and that you don't get errors. If it doesn't work for some reason, try using the "OnPostRenderCallback" function like on this page: docs.unity3d.com/ScriptReference/Texture2D.ReadPixels.html
@Kerem_MertGakadatil
@Kerem_MertGakadatil 2 жыл бұрын
Image I saved turns out to be yellowish in PC
@graphiteji
@graphiteji 2 жыл бұрын
I want to load the saved file in the same scene tell me how
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
You can just keep the texture2d you created when saving and then set it on a sprite in your scene with Rect rect = new Rect(0, 0, texture.width, texture.height); Vector2 pivot = new Vector2(0.5f, 0.5f) Sprite sprite = Sprite.Create(texture, rect, pivot); spriteobject.GetComponent().sprite = sprite; //replace with whatever sprite you want to change.
@seanburns6208
@seanburns6208 3 жыл бұрын
Max great video, thank you very much. It's working great for me on PC but when I build to Android (Galaxy S7) the screenshot doesn't seem to work or else I just can't find it gallery. Any suggestions? Did you run into any similar issues at the start? Also, any tips on including a share button?
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
Hey, thanks a lot. When you built it on your phone, did you switch the code to using UnityNativeGallery ? After 6:43 I show a different code for mobile, using the PC code on mobile will not add it to the gallery. If you did and it doesn't work, then maybe try reading the github page for QnA and other information that may help you fix or contacting the UnityNativeGallery devs at github.com/yasirkula/UnityNativeGallery Since I didn't make it and it worked for me ( Huawei P20 ), I can't really help you with this :( For sharing I don't think it's worth taking time to make it yourself, as there are already things you can import and work with for free. With a quick search I found this that seems good, but you can probably find many others: forum.unity.com/threads/native-share-for-android-ios-open-source.519865/ ( "Native Share for Android & iOS" on asset store )
@adairvillalba1779
@adairvillalba1779 2 жыл бұрын
como le puedo agragar una marca de agua a esta captura de pantalla, la imagen de agua que sea otra imagen.
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
I don't know exactly but I'd suggest looking into doing it with textures. For example, the screenshot is loaded as a texture before being saved so if you load your watermark as a texture too, you can probably put the watermark on the screenshot. Try something like this: answers.unity.com/questions/1561563/combine-2-textures-of-different-sizes-at-specific.html
@noorsalama8911
@noorsalama8911 2 жыл бұрын
thanks for the tutorial , but where will these screenshots be located after taking a screenshot
@tabithaabbott5478
@tabithaabbott5478 2 жыл бұрын
Hello Hello! Does this approach work for WebGL builds? Ive been stuck for a week. Edit: do any of the multiple approaches in the video work for webl builds? I’m trying to save screenshot from game on website on to users devices.
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
I haven't tried it sorry. You can check the library's GitHub in the description they probably say if it does.
@Ekalaivan
@Ekalaivan 3 жыл бұрын
Thanks man, this working great, is there anyway to use the same plugin to record videos?
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
Sorry I don't think this plugin is made for that. Recording gameplay is usually pretty tricky so you might not find a plugin directly for it :(
@Ekalaivan
@Ekalaivan 3 жыл бұрын
@@MaxMakesGames exactly, got one plugin for recording video but it's deprecated from Android 9 it seems. I don't know why Google keep on reducing the controls. Stucking with another project for enabling mobile's flashlight for a AR session with Vuforia, where the Torch light working fine on Oreo devices but not working on latest Android Device.
@arnauz11
@arnauz11 2 жыл бұрын
if i want to save screenshot in downloads, what i have to do? because if i upload my game, the players will not have Application datapath
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
When you build the game for release, the Application datapath will become the folder where your game exe data is I believe. So when the player run your game and take a screenshot, it will be saved where they have your game in their PC. However, after looking into it a bit, I'd recommend using Application.persistentDataPath instead to make sure the screenshots wont be deleted in updates and that the path doesn't change. On Windows, the files will be saved at "%userprofile%\AppData\Local\Packages\\LocalState". You can see more details here: docs.unity3d.com/ScriptReference/Application-persistentDataPath.html If you really want the screenshots to be with the game files, then check out dataPath to see where it goes: docs.unity3d.com/ScriptReference/Application-dataPath.html
@arnauz11
@arnauz11 2 жыл бұрын
@@MaxMakesGames but this way is very complicate for player because he/she doesn't know where screenshot is. If the screenshot saves in download files of pc, will be perfect.
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
@@arnauz11 All games save their screenshot in the game folders. Minecraft saves it in appdata for example. If you really want to save in the download folder, you'll have to use C# to get the path and use that path instead of Application Data path.
@arnauz11
@arnauz11 2 жыл бұрын
@@MaxMakesGames thanks
@兔兔-y4f
@兔兔-y4f 2 жыл бұрын
ty i love u 😍
@adairvillalba1779
@adairvillalba1779 2 жыл бұрын
cual es la versión de Native Gallery para la versión de unity 2019.4.35f.
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Try the latest version, it should work.
@adairvillalba1779
@adairvillalba1779 2 жыл бұрын
@@MaxMakesGames no me funcionó, solo me funciona para las versiones superiores a 2019
@1234yokee
@1234yokee 2 жыл бұрын
Thank so much. You are my life saver . But i have a small problem. my screenshot image size is too small (284x568) . How to fix this sir? pls
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Thank you. If you used the same code as me, the screenshot size should be the size of the screen or window. When you create the texture, you can set the size. I put the screen width and height in the video, but you can put whatever you want. Just be aware that if you increase the texture size but use a smaller size in the ReadPixels, then it won't fill your texture. Maybe you are testing your game in a small 284x568 window ? Try making it full screen and see what it does 😁
@MegaCX
@MegaCX 3 жыл бұрын
How can I save a screenshot in documents?
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
You need to check the path for documents on your PC and use that instead of the application dataPath. In my case, it is "C:\Users\Admin\Documents\" so I would use File.WriteAllBytes("C:\Users\Admin\Documents\ScreenShot.png", bytes) And ofc like I showed after you can add a timestamp so every screenshot has a different name.
@shortStories197
@shortStories197 Жыл бұрын
How to load those pictures in game
@MaxMakesGames
@MaxMakesGames Жыл бұрын
You can load a PNG file as bytes onto a Texture2D in Unity by using the LoadImage function of the Texture2D class. This function takes a byte array as an argument, which can be obtained from the PNG file. Here’s an example: string filePath = ... // The path to the PNG file byte[] imageBytes = File.ReadAllBytes(filePath); Texture2D texture = new Texture2D(1,1); texture.LoadImage(imageBytes); Once you have the Texture2D, you can display it on a canvas by creating a new RawImage object and setting its texture property to the Texture2D you created. Here’s an example: RawImage image = GetComponent(); image.texture = texture;
@SassyPantsy
@SassyPantsy 2 жыл бұрын
Btw you're the man
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Thanks ! 😁
@farikhanniazi7042
@farikhanniazi7042 2 жыл бұрын
Plz Share the script screen short
@seymaple
@seymaple Жыл бұрын
do you know a way to do the same things just in a webgl build? and save to downloads?
@MaxMakesGames
@MaxMakesGames Жыл бұрын
I doubt it's possible from unity because to save a file from the web you need to ask the browser to ( kinda ). Maybe you could if you edit the JavaScript created after building the webgl and code that part in JavaScript directly but idk how exactly.
@mesmes9424
@mesmes9424 3 жыл бұрын
Can I assign the texture to the canvas image before saving it?
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
Yes ! I would suggest using Sprite.Create ( docs.unity3d.com/ScriptReference/Sprite.Create.html ) to create a sprite from your texture, so something like Sprite sprite = Sprite.Create(texture2d, new Rect(0, 0, size, size), new Vector2(size/2,size/2)); Then set your canvas image sprite to that sprite using image.sprite = sprite;
@mesmes9424
@mesmes9424 3 жыл бұрын
@@MaxMakesGames Thank you ! After trying that and not succeeded I figured it out that we need also to comment out the Destory(texture) function for it to work.
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
@@mesmes9424 Ahhhh yes it makes sense if you destroy the texture, it will not work. Thanks for telling your solution, maybe it can help others :)
@mesmes9424
@mesmes9424 3 жыл бұрын
@@MaxMakesGames Thank you for this great tutorial!
@paolademichelis5082
@paolademichelis5082 2 жыл бұрын
Thanks for the video tutorial, it's great! What about for WebGL build? How can I save screenshots directly from the web into my download folder?
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Thanks ! I searched a bit and apparently the only way would be to use JavaScript to open a file browser and save at the selected location. Apparently unity allows you to add custom JavaScript for web builds so try looking into that but I've never done it so I can't tell you more sorry.
@noorsalama8911
@noorsalama8911 2 жыл бұрын
when i added this to my button and i try it out on the phone it asks if its ok to give access to my photos and i said ok to screenshot but i dont seem to find the screenshot , how can i find it ?
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
If you used NativeGallery.SaveImageToGallery, the screenshot should be saved in your phone's gallery. The GitHub page for the plugin says this: On Android, your images/videos are saved at DCIM/album/filename. On iOS 14+, the image/video will be saved to the default Photos album (i.e. album parameter will be ignored). On earlier iOS versions, the image/video will be saved to the target album. You can read more and check for possible fixes if it's not working for you here: github.com/yasirkula/UnityNativeGallery
@noorsalama8911
@noorsalama8911 2 жыл бұрын
@@MaxMakesGames i did use native gallery , and when I click the camera button in the editor it says successfully screenshot Taken but when I have it on phone , it seems that it screenshots but I don’t find it when I go to my gallery ? i mean should I assign any name to my script or
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
@@noorsalama8911 Then it might be a problem with the plugin... I didn't make it so I can't really do anything about it. I suggest looking at their github I linked, they have a QnA and a bunch of infos. They also show different versions of the function you can try. If nothing works, maybe try contacting them. As you saw in the video it worked for me so I have no clue why it doesn't work for you... sorry :/
@noorsalama8911
@noorsalama8911 2 жыл бұрын
@@MaxMakesGames by the way did you use the new or old input system for this ?
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
@@noorsalama8911 I think I used the old one but it shouldn't matter as long as your code is being ran. You said it asked for permission so I'm guessing your code is being ran.
@nixter361
@nixter361 2 жыл бұрын
Great tutorial. Can we also send the screenshot to server ?
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Hmmm I guess once the file is saved on the PC/Phone then you can upload it to a server, but I've never done that. Maybe search "C# server file upload" or something like that.
@techlightdev
@techlightdev 3 жыл бұрын
I can not save ScreenShot on my android device but pc is work. Can you help me ? thank you
@MaxMakesGames
@MaxMakesGames 3 жыл бұрын
You need to use the native gallery plugin like I showed at the end. If it does not work, contact the devs on their GitHub. I didn't make it so I can't help you if you used the same code that worked for me but it doesn't for you, sorry...
@darkbatu
@darkbatu 2 жыл бұрын
thank you so much!!!
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
You're welcome!
@Abedalaziz_game_dev
@Abedalaziz_game_dev 2 жыл бұрын
Love you
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
Love you too
@simpleguyissimple
@simpleguyissimple 2 жыл бұрын
Does this also work on IOS?
@MaxMakesGames
@MaxMakesGames 2 жыл бұрын
The GitHub page says it does but I haven't tried it :)
@simpleguyissimple
@simpleguyissimple 2 жыл бұрын
@@MaxMakesGames okay thanks, man! Great content btw!
How to Save File with Screenshot! (Save System Unity Tutorial)
16:28
Device Camera - How to - Unity 3D [Tutorial]
14:11
N3K EN
Рет қаралды 190 М.
бабл ти гель для душа // Eva mash
01:00
EVA mash
Рет қаралды 8 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 123 МЛН
Best Way to take a Screenshot in Unity in 2023 (using Unity Recorder)
3:24
The Secrets of Apagayo Island
Рет қаралды 37 М.
Take PHOTOS in Unity (POLAROID Pictures Camera UI)
22:23
SpeedTutor
Рет қаралды 18 М.
How to take a Screenshot in Unity URP or HDRP! (Unity Tutorial)
10:40
Photo Save and Load as bytes in the memory in unity
9:18
Abolfazl Tanha - Game & XR maker
Рет қаралды 2,7 М.
Taking Screenshots - Unity 2021 Tips & Tricks
4:37
Admor Aguilar
Рет қаралды 11 М.
I Remade my Voxel Engine from Scratch...
10:32
MaxMakesGames
Рет қаралды 11 М.
Unity Social Sharing Tutorial in 10 Minutes (Android & IOS)
10:57
SAVE & LOAD SYSTEM in Unity
18:20
Brackeys
Рет қаралды 1,1 МЛН
How To Actually Publish your game to applab (correct way)
22:39
бабл ти гель для душа // Eva mash
01:00
EVA mash
Рет қаралды 8 МЛН