Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Change texture in real time from build

Discussion in 'Scripting' started by Gui205, Dec 6, 2018.

  1. Gui205

    Gui205

    Joined:
    Nov 3, 2014
    Posts:
    82
    Hi !

    Im asking myselft if it's possible on an build version to load from an external folder a news diffuse map from an model and swap this imported texture with the defaut one on the 3D model.

    Exemple :

    You launch your build exe, on your scene you have an red 3D cars, you click on an button that open your C folder, you select a news diffuse UV on your path disk, you clic on "import" button, and this diffuse texture remplace the Red diffuse by your news imported diffuse.

    If yes, how to do that ?

    Thanks you :)
     
  2. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    706
    Don't have experience doing this, but I think Asset Bundles is what you want.
     
  3. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    803
    You can 'download' the texture from disk using UnityWebRequest, or older WWW classes.
     
  4. Gui205

    Gui205

    Joined:
    Nov 3, 2014
    Posts:
    82
    It seem really complex for this kind of achievement no ? And it's not download an texture, it's just load an texture from your disk. I dont want to use http protocol
     
  5. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,230
    You can also do this by using System.IO. (DirectoryInfo, FileInfo, Stream.) Just read the file into an array of bytes and then convert it using ImageConversion.LoadImage.

    Some pitfalls:
    - Only supports JPG and PNG formats.
    - If you thought this was complex, wait until you find out that you can't just show a file open dialog in runtime. You have to build it yourself or call some platform dependent native file open dialog.
     
  6. Gui205

    Gui205

    Joined:
    Nov 3, 2014
    Posts:
    82
    Yes i looking for this, but i found nothing on internet for develop that