- Home /
Dynamic Cylinder Skydome
Hello, Is it possible to import a jpg at runtime and then import it in the project and also changing some of it's properties. For example, download a .jpg from the net with some form of curl or www class and import it as a cylindrical map ?
Alex.
What i'm trying to do is exactly the same as in this link http://forum.unity3d.com/threads/is-it-possible-to-generate-a-spheremap-from-a-texture2d-in-unity-at-run-time.328744/
and exactly like the last poster i'm trying to do it with a cylindermap.
Answer by tanoshimi · Jun 27, 2016 at 05:27 PM
Yes. Look at the example on the manual page: https://docs.unity3d.com/ScriptReference/WWW.html
The properties you're referring to are part of the asset importer and can't be accessed at runtime, but you don't need them. Having loaded your texture image from a remote server, you can assign it to one of the faces of the cubemap using SetPixels() - http://docs.unity3d.com/ScriptReference/Cubemap.SetPixels.html
Hello, Thanks for answering so what i need is to download a jpg from a server and set it as a skydome texture. Steps are: 1. Download images (they can be multiple) to a folder on the client. (from what i could find it's preferable i download them in Application.persistentDataPath, that's fine) 2. Create a texture. 3. Apply this image to the texture (which is of the same size as the original image widthxheight), currently this is still an unknown to me in how to achieve this, i see there's a setpixel thing i can do but isn't there some function to load the image into a texture ? 4. I need to change this texture settings (or maybe i can set the textures settings when i create it not sure how this is done either) from Texture Type = "Texture" to "Cubemap" and set it's mapping to Latitude-Longitude Layout(Cylindrical) . Also i understand there's a TextureImporter class i'm unsure whether this is something that can be used here, i would like not to have to do all these steps every time the user restarts his app. This will run on mobile btw.
I don't really need code samples i just want to know on a conceptual level if this thing is achievable, or if any of the steps i mentioned are wrong or unneeded .
Best Regards $$anonymous$$. @tanoshimi @Jessespike
Answer by Jessespike · Jun 27, 2016 at 05:28 PM
Loading textures at runtime is possible.
Importing it as a cylindrical map, er maybe not. You can have a cylindrical model with predetermined UVs. Just load the texture and slap it on the cylinder model.
Your answer
Follow this Question
Related Questions
Resources.Load dynamic path 2 Answers
load file from Xcode 1 Answer
Dynamically load AudioClip during runtime 1 Answer
non-dynamic asset load? 1 Answer