- Home /
How to change Textures after build the game?
Hello,
The idea is this . The game brings a default textures , but I want the user be able to change them if he/she wants. I dont know if it is possible to do this , and if so , how do I do?
I have two things in mind:
The user adds textures in a specific folder , using specific names and sizes , so that after, the game detect and load the textures.
Using an interface that allows the user to find, select and load the textures by object...
What do you recommend me ?
How do I load the textures ?
And if there is a better way, please tell me
Thank you very much.
Answer by Hellium · Jun 22, 2015 at 07:19 PM
The solutions are both possible, but implementing the second one is much more difficult than the first (no GUI, no scripting, etc)
If you really want the second solution, you will have to make a file browser (some are free over the web). For a custom one see the .NET File and Directory classes :
https://msdn.microsoft.com/en-us/library/system.io.file(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/system.io.directory(v=vs.110).aspx
Then, you could simply copy the selected file by the user with the appropriate .NET function :
https://msdn.microsoft.com/en-us/library/system.io.file.copy(v=vs.110).aspx
You won't have to "load" a texture, but simply copy it in the appropriate folder (inside the Resources folder : http://docs.unity3d.com/ScriptReference/Resources.html) with the appropriate name.
You might want to set the Filter$$anonymous$$ode etc. too.
Answer by TheXWolf · Jun 22, 2015 at 07:39 PM
I think #1 is a better solution, saves you from having to create different UI components in the game. Simply load and atlas textures when the game boots by checking a folder for files by name. If the file matches a name for each file, then it simply replaces it. There's a number of basic methods for doing that so I won't go into them; I would simply say the first one is the better option.
Your answer
Follow this Question
Related Questions
C# Error when trying to load Texture at runtime 1 Answer
Loadimage Texture at runtime 1 Answer
Export objects to a .3DS file at runtime 1 Answer
Is it possible to load an audio file at runtime? 2 Answers
load c# script from server 4 Answers