Runtime model importer (from storage/URL + download and save model)in unity

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 we want to learn how we can download store and import a 3d model or avatar to our scene in runtime in unity okay that we should have a plug in which called tree leap which is you can find out this plugin on the as the store dot unity.com it is truly two model loading package it is very powerful uh plugin to import a 3d model with a range of formats as you can see fbx obj gltf2 stl play and 3mf and also the pac model with the textures as a zip file and it is cross platform which is works in on windows mac linux uwp uh android webgl ios and also i tested on oculus quest and it worked well remember your unity version has to be 2019.3.0 or higher after you buy this powerful plugin from asset store and import it to your package in into your project uh you should come here trilib and as you can see it has several folders which is and maybe the best one is for example three lip samples as you can see it is has acid viewer avatar loader load extra animations so we can import a 3d model even which has the animation such as fbx animated models all load model from file which is you can give the address of the 3d model as a script of it or in here you have from file picker and let me to do something like this okay for example i click on load model and in here i click uh this model and that's it it is a pillow and it works well and this is my 3d model okay it is perfect as a one 3d model and it is the material of this 3d model okay or even you can give you can upload that zip file or that 3d model and storage and you can give the link after 3d model then after that uh it tries to download the 3d model and show it in runtime for example i use this website file bin.net in this website you can upload a tree an object and it gives you the direct link and also it can export it can store your 3d model or your file for maximum six days and for example i uploaded this 3d model right click copy link address and in here i gave this a link as a disc format the hdfs and filebeam.net and this one a model.zip the name model the name of model and the format of it is really important and finally i will downloading as you can see it's downloading a 3d model and after finish yes it's created a 3d pillow which is exactly what's similar with my original model uh i want to talk about another feature which is doesn't exist in this plugin so for example in the url site and the url sample all the time you need to download the 3d model you can't cache this 3d model on your storage and in the next time you have to download this 3d model but with caching the 3d model under storage you don't need to download just load it from storage okay let's to create a simple c sharp script i called this one model downloader let's take a look at this model downloaded model downloader as you can see in here we have two parts first download the 3d model and the file and store it and save it as a zip file on your storage and the next part is how to do how to load the 3d model from the storage from that address we have saved that zip file okay now we have these libraries system dot io unit engine.networking 3lip core and system.collectiongeneric and treeleycore.sfb in here we have public string url that url we uploaded the 3d model there and in here we have private i list item with a stream the items it's for as you can see for loading the 3d model from local storage and in here first let's let's to download the zip file and save it as a zip file on our storage in the void to start we have start curtain download zip file and this is zip file in here we have two checkers if we already have the zip file on our storage okay just load the 3d model we don't need to download look at this file that exists this is the address of our application storage on our pc it will be on windows it will be like this drive windows c users your profile app data local law company name folder and project name folder as you can see we don't have anything here so in this if we will say if the file with this address from this address and this name and this format is already exist okay we already have target zip file exists so load the 3d model from storage if it is not exist file that exists application and persistence data path it is the address and zip file name dot zip is in doesn't exist okay target zip file doesn't exist try to download it and here unity request www equal unitywebrequest.get.url that url we have uploaded there and in here yell return www www.send and in here if we have any error okay let's print that error if we don't have any error okay it will be the format of the save path and in here we have address file name and the format okay we have save path and now file dot write all bytes save path and in here www.downloadhandler.data as a zip file so we have checker we already have the law and the zip file now okay let's to download it if we download is successful let's to save the zip file on our storage okay we already have our target zip file and target zip wire downloaded let's download the let's load the model from local storage it is the next part in here we have void load model start loading zip file in here we have uh these parts are really similar to the standard template of the asset downloader of the treelip library but let's take a look at it's very fast we have our has files it is the items which we want to load and stream there and here assets loader options asset loader dot create default loader options and in here assets loader zip dots load model from zip file this is the address this is the name and this is the format of our zip file unload unmessed on materials load on progress on error and other options of the loading model from zip file and that's it with this mechanism we can download a zip file and and save it as a zip file on our storage after that we can load the 3d model from our local storage okay let's test this technique with together for example in this scene from url i say let's create an empty object say model downloader okay and let's turn off this standard method and add the model downloader here as you can see it is model downloader and it has just a url variable this is string i want to copy this url from here and paste it here perfect and remember in this address we don't have any zip file okay now i want to play start target zip file doesn't exist start downloading zip file it is downloading okay as you can see target zip file downloaded start loading zip file and it is the loading from local storage materials loaded model loaded fully loaded and it is it it is our 3d model has been downloaded and stored from url and that's it it is our zip file name which is here contains gltf and the bin and also the textures okay now in the next time i want to stop the game and i don't want to delete this one now when i play the scene as you can see it's loaded very fast because target zip file exists okay let's so load the 3d model from storage that's it okay i will share this script on my in github and you can see this the link of this in github page on the wiki page and as it did in the description of this video i hope this video this video will be helpful for you don't forget to subscribe and like this video if you like it and feel free to ask any question on the comments have a great time bye bye
Info
Channel: Abolfazl Tanha - Game & XR maker
Views: 8,889
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, game designer, Save, Load, Save data, Load data, Save file, Load file, Zip, Zip file, Compressed file, download zip, save zip, import model, add model, import runtime, save model, import 3dobject, import object, add object, save object, runtime save
Id: vtsjs1rBDSE
Channel Id: undefined
Length: 13min 21sec (801 seconds)
Published: Sun Sep 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.