Google drive in Unity (Upload + Download photo)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys I hope you are doing well welcome to my channel in this clip I want to talk about a solution which we can have a bridge directly between Google Drive and a project in unity for example we can download an image or upload an image into the Google draw okay let's take a look at the first step the first step is we should come over here building range uh Unity Google drive it is inside the GitHub I will share the link of this page inside the description of my video first of all you should copy this link here inside the installation you should copy this link and come back to your Unity however I already downloaded this card but I will explain what I have done I should come over to package manager inside this plus button you should come over to add package from get URL and after that you should paste that link here and press add whenever you have done this step you will see it will be like this a Unity Google Drive uh it's downloaded and installed on my Unity you can see the same result like me however the version for me it is 0.27 maybe for your time it will be higher but uh yeah after you download this uh plugin uh we should go to the next step the next step is we should come over to the edit project settings and at this part we have Google Drive and this the overall settings for configuration uh product your Google Drive account and your project and unity okay first we should come over here and press this button uh create Google Drive API app okay and after that in this page if you have a project it's something else but if you don't have any project just click on create project here let's make a let's select yeah yeah the name which you want for example I say my work my Works no my work okay an organization can be empty or any organization you want and let's create okay after you create you will see these steps here okay then the project my work has been set up successfully here you just need to press next and enable you are about a to enable Google Drive API okay okay The Next Step will be here for API services and at this part we should come over to did the API services at this point okay correct okay in the left panel we should click on auto consent screen at this port and create something it can be internal it depends on your position if if you wanna uh you know just share the content between your organization's member or for public for example external for public and I create something and here I again need to add my application name I just say my work and my support email is my email and here can be email address writing my my here okay excellent just need to add save and continue at this point no need to add anything else for desktops I just need to press cancel okay it is fine and because this project is in the publishing status in testing we should consider uh one important point is we should Define uh who is gonna be tester of this project okay or who are gonna be and for example I'm adding my email okay so 1000. upload 571 gmail.com is my tester okay we have we have test users here and it is fine okay the next step is we should go to the credentials at this part all right and create credentials and at this part Oh I thought client ID excellent I propose to select web application because we want to have a multi-platform cross-platform here and web client can be anything but I say my work clients okay and no need to add any URI or after a JavaScript however if you have project which is related to the webgl you should you know consider these points at here for example your JavaScript system or Uris here but for now it is fine I press create excellent now I have my client ID and client secret and anything and I should at this part a status is enabled okay just download Json okay after I download my Json I come back to the editor and here we have parse generic credential Json file present here and come back to downloads and I have this guy this guy didn't use one just silhouette my my time okay look at this the client ID is correct project ID my work and everything is fine okay now the step of the project configuration has been done uh at this scene I made a simple scene which is contains just a canvas and raw image to showing the perceived image and and the mind camera in the main camera I've added this test script let's take a look at the test script here at this part you should know that first you should you need to have using Unity Google Drive in your using list and after I have added a public texture 2D for image that thing I want to upload that image I want to upload and these guys are related for that image are already uploaded and downloaded sorry and this is whenever I want to upload I said I I press button U for upload uh call this function is going and whenever I want to download call this function at this guy okay first it is file creates uh we have our content uh it is the an array it's gonna be the array of bytes of that image we will input that image here and encoding to the PNG and make the array of the points here after that we will call this function Unity Google drive.data.file okay the name of that file or that image we're gonna upload it for example let's say my work image okay and the content of this image is that image we already parted and you know uh converted to the bytes here and after that we will say okay that our request is gonna be googledrive files.create which file this file the image was with this name and the content of that all right okay and we will wait because it is enumerator and we will wait until this request is sent uh at this point we will check do we have any error and at this point we will say okay do we have any content for that one and at this point we will get the ID of that image this is the process of uploading file from Unity to the Google Drive and in this function we will find out how we can download an image from Google Drive but first uh let's test this uh this mechanism okay the image which I want to upload to the Google Drive is this image it can be any image but the important point is this image has to be read and write first and second point is and no need to have compression the compression of that image has to be none okay and just press and just check right and right and set the compression equal now after apply you will have your image ready for upload and if I drag and drop that image to this field and now I play the scene all right before press U and upload the image request to upload the image we should consider come back to the uh project management the credentials click on my work clients at this point we should consider if you if we don't want to use webgl another platform for example Windows Android or whatever we should consider https that a local host for Ur eyes Okay and after that we should come back to the edit project settings at this point URI sham credentials just duplicate this client ID and paste here copy this part and paste it here okay let's play the scene excellent and I press U okay it says choose an icon to continue my work my working my project okay I selected this one I said do you want to verify this one I can continue and I want to have all of this and continue again okay it says please return to the app okay and look at this the upload has been done there is no error and a problem and this is the ID of that image which you already uploaded okay let's come back to the Google Drive here look at this this is my image which already uploaded my work image and if you take a look at it this image is fine and if I for example get the link and copy link here look at this this is the image ID of this and the file ID of this image uh 1355 and J and 99. look at this 1355 J and 99. it helps us to understand um how can we how we can get the file ID to be able to download it from Google Drive okay for example if I'm here and let me okay okay sorry upload the file for example this one okay this is the image okay and I click on get link and copy link here and come back here as you can see this is the the file ID of this image I copy between this slash and this one okay copy this part and come back here I need to paste at this part okay here the function of file download will have a request for Google Drive files.download this is the file ID and in here we will wait until the request is sent if we have any error it shows here if we have any problem and content is fine over now it's here and in here we will have I made a an array of points for downloaded content here I said request.response data dot content as a an array of points and put it inside here and create a texture with the resolution 10 24 10 24 I called it text okay text low dot load image the array of points of that image which we already downloaded make the texture of it apply it as a texture and that image raw image here I said okay the texture of that raw image is equal that texture we already are downloaded okay let's come back to the scene and I press play let's clear the console and press d excellent this is it there's no error no problem and as you can see it is our image that's it excellent if you want to learn about more functionalities about uh interaction with the Google Drive you can come over here Internet it's inside assets folder and a Scripts as you can see there is a lot of functions for here text file create and delete and download audio and texture or whatever you can take a look at them and they are easy they're just using and the important part is whenever you want to upload it's having the right name Android contact content sorry and whenever you want to download what matter is let's have a file ID and also um the next part is going this okay convert them to array after that uh if it is image just make an image put on here if it is audio let's make an idea from this app okay I hope this tutorial will be helpful for you don't hesitate to ask any question related to Unity a or VR and XR subscribe my channel and like this video if you like it have a great time bye bye
Info
Channel: Abolfazl Tanha - Game & XR maker
Views: 5,898
Rating: undefined out of 5
Keywords: unity, unity3d, unity dev, unity developer, unity programmer, unity game, unity scene, gameobject, unity object, runtime, editor, unityeditor, c#, gamedevelopment, simulator, simulation, simdev, developer, level designer
Id: uT6xgap5ETI
Channel Id: undefined
Length: 18min 15sec (1095 seconds)
Published: Thu Apr 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.