- Home /
my textures aren't working (bmp files issue)
I know there are a number of similar questions but I have read all the ones I could find and none of the answers have helped. I am trying to load objects from a .x file and then load a texture from a .bmp file (the texture format is not important I can easily change if .bmps don't work). The models are loading correctly and I am adding some texture coords from the file. The models weren't textured in the 3d program I made them in though so the problem could be here. Anyway the end result that the models are all just white. The texture isn't showing up. Here is what I am doing:
var image = new WWW(imagePath);
yield image;
image.LoadImageIntoTexture(currentObject.renderer.material.mainTexture);
As you can probably see the code is pretty standard and basically just copied from the docs. I get no errors at any point during the process of loading object and texture. I am out of ideas.
This might sound stupid. But is it necessary to load the texture through scripting? why not just import it in editor?
Some people like having the ability of uploading your own textures in game, maybe a car color/graphic... However, it is possible.
as I mentioned above I am loading entire user objects at runtime. The main concept of my game relies on users being able to load their own content just by dropping files in certain game folders.
Answer by Justin Warner · Jan 17, 2011 at 02:20 AM
// Get the latest webcam shot from outside "Friday's" in Times Square var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg"; function Start () { // Start a download of the given URL var www : WWW = new WWW (url);
// Wait for download to complete
yield www;
// assign texture
renderer.material.mainTexture = www.texture;
}
This is fromt he API, it takes the image at that URL, and downloads, and makes it a texture...
I'd suggest doing it after this example.
http://unity3d.com/support/documentation/ScriptReference/WWW.html
That was the first code I copied, the one I posted was the second method I tried. Both return blank white objects.
Do you at least get an image by using this? Like, does one appear in the hierarchy?
actually yes, the object appears to have a texture with a red question mark (?) on a white background this explains why the colour was white and means that the texture coordinates aren't set very well. I assume this is a some default error texture from unity. Anyone know what causes it to show up?
Default texture in Unity is bright pink I believe... Are you downloading a small texture or a large texture, because maybe question mark is like, just it hasn't downloaded, so it displays that, I seriously don't know... Sorry.
I am opening the image from my own hard disk, it is fairly large, 256x256 pixels, but hard disk reading that should only take milliseconds
Answer by Dunkhan · Apr 11, 2012 at 06:18 AM
I just noticed that this has 1000 views and the answer is not really even here. the answer was .BMP is not a valid file type for www images. If you are having troubles that do not involve .bmp files then I apologise for wording the questions so generally. I have added a note to the title so that people with a million different problems don't all end clicking on this and being disappointed that it doesn't help.