- Home /
cannot set texture
Hi,
Simply, I am creating instances from my 3d model and I want to set different textures to my clones in script.
These are the steps which I followed;
I downloaded a simple 3d model (.3ds) and I converted it to fbx by using 3DS Max
I dropped the fbx model in Unity editor. And, by using "Build AssetBundle FRom Selection" script, I exported the model as .unity3d model.
I tried previous step by creating a PreFab which contains fbx model, then export it to assetbundle, but the nothing changed.
I put the .unity3d model to my webserver. I used the following codes "to load assetbundle", "to create some instances", "to load textures" and "to set textures"
WWW conn=new WWW("http://www.blabla.com/testAsset.unity3d"); yield return conn; AssetBundle testAsset = conn.assetBundle;
WWW connTex=new WWW("http://www.blabla.com/testTex1.png"); yield return connTex; Texture2D testTex1 = connTex.texture;
GameObject obj = Instantiate(testAsset) as GameObject; obj.transform.position = new Vector3(2.0f, 1.0f, 2.0f); obj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); obj.renderer.material.mainTexture = testTex1;
But as a result, I am not seeing the texture over the model. Instead of texture, the model seems as painted to black!
What can I do? What should I check? Or, what is the problem? I am going crazy..
Your answer