- Home /
Grab Image/texture from MTL file and apply to a game object
Hello,
I have an obj and mtl file. When I add both files to my project, I am able to drag the obj in as a game object. I believe that the mtl also applies to the obj because the obj will come with a certain color if the mtl file specifies it. How can I get an image that is contained as a link within the mtl file applied to the obj game object?
Here is what is contained inside the mtl file:
newmtl body1
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.5000 0.5000 0.5000
Kd 1.000 1.000 1.000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
map_Kd -o 0 -22.843 0 -s 20.26 22.843 1 https://machinecore.farmcp.com/Ziing3Server/Ziing3.aspx?req=image&maharam&fmt=jpg&qlty=80&mat=466194-005&raw=true&dpi=100
The link at the end is what is the image is. If I were to copy and paste this into a browser, it would download the image. I'm wondering if there's a way to grab this image and apply it to a game object (ideally its corresponding obj). Any help or guidance is appreciated.
Thank you
Answer by Nebukam · Apr 11, 2018 at 08:16 PM
Check this : https://docs.unity3d.com/ScriptReference/WWW.LoadImageIntoTexture.html You will need to manually extract the url from the mtl file yourself tho.
Thanks! I'll give this a try and let you know if it works for me.
Your answer
Follow this Question
Related Questions
Assigning textures in project panel to materials dynamically or via editor scripts 1 Answer
(Unity Serializer) Materials doesn't load when loading a prefab at runtime. 1 Answer
How to Properly create & apply a normalmap and specular? (Hard Surface Shader Free) 2 Answers
Zbrush materials and textures in Unity 1 Answer
How to download game content (DLC) for storage and use later 1 Answer