Unity3d iOS build – where are the textures?

| | August 4, 2015

First time building and running my Unity3D app on my iPhone and it appears that all the textures are missing. Everything is just a solid block of whatever color I made it. When running in Unity I see everything correctly. See images below.

To complicate things I’m using custom shaders, and all the objects are custom procedural meshes. Quads that I build in script. If I switch the paper backplate shader to a built in shader I still only see white on the iPhone.

So I suspect that somehow the textures just aren’t making it to the iOS project. When I look in the iOS project I can’t find any textures. Where would they be in the iOS project? For example in Xcode under Build Phases > Copy Bundle Resources the only thing there is the Images.xcassets, which only contains the splash screens and icons.

Surely I’m missing something simple.

I tried renaming the folder where I keep my textures to “Textures”. Also my textures are not built in to the shader but added programmatically like this:

void Awake ()
{
    meshFilterComponent = GetComponent<MeshFilter>();
    Material material = GetComponent<MeshRenderer>().material;
    material.SetTexture(0, paperTexture);
    material.color = new Vector4(1f, 1f, 1f, 1f);
}

Where paperTexture is set up in the GameObject to point to the correct texture. Is there any way to force a texture to be part of a build? Let’s say that you swap out textures in code, like swapping themes, how would you make sure they’re all there to be loaded as needed?

Running On iPhone:

Running on Phone

Running In Unity3D:

Running in Unity

One Response to “Unity3d iOS build – where are the textures?”

  1. I fixed it by changing this:

    material.SetTexture(0, paperTexture);
    

    to this:

    material.SetTexture("_MainTex", paperTexture);
    

    I don’t know why the first one worked fine in the unity window but not on the phone. But that’s what fixed it. For some reason the more explicit assignment works better. But now everything is rendering properly on the device.

Leave a Reply