level generated by code

Hi,

When i generate my level geometry through code, the textures look bad.
Is there a difference between generating through code or creating in the editor ?
The material i created is exactly the same as in the editor. Has the Diffuse shader on it.

Sounds like your UV coordinates are just worse or you only generated 1 UV set when you used lightmaps for example, or you forgot to general normals so lighting is wrong / not present

Must be the UV coordinates since i don’t have a lightmap. So i should correct the UV’s when i create a primitive ?

this is my code to generate the objects :

		GameObject Geometry = GameObject.Find("Geometry");
		GameObject tmp = GameObject.CreatePrimitive(PrimitiveType.Cube);
		tmp.transform.position = new Vector3(posX, posY, posZ);
		tmp.transform.Rotate(rotX, rotY, rotZ);
		tmp.transform.localScale = new Vector3(scaleX, scaleY, scaleZ);
		tmp.name = "tmp";
		Material tmpMat = new Material (Shader.Find(" Diffuse"));
		tmp.renderer.material = tmpMat;
		tmpMat.mainTexture = myTexture;
		tmpMat.SetTextureScale("_MainTex", new Vector2(textureScaleX, textureScaleY));
		tmp.transform.parent = Geometry.transform;

sure you wanted to use the SetTextureScale?

That might be your major difference in the end

yes, just like in the editor. The texture shows but it’s like a quality issue.
The lines look wierd in the distance.
I will take some screenshots later to show the problem.

stuff like mipmap settings etc are controlled by the texture import settings not this code though and would cause a code as well as an editor generated cube to look the same.

you can see it here :
WebPlayer.html

one side is generated by code and the other in the editor.
you can see it if you walk around or just rotate the controller.

solved the issue when i do this :

WWW myTextureWWW = new WWW(textureURL);
yield return myTextureWWW;
Texture2D tmpText = myTextureWWW.texture;
Texture2D myTexture = new Texture2D(tmpText.width, tmpText.height);
myTexture.SetPixels(tmpText.GetPixels());
myTexture.Apply(true);

Can someone explain why i need to do this and what this actualy does ?