- Home /
Question by
buildman99 · Feb 04, 2012 at 06:08 PM ·
javascripttexturecubeprimitive
Primitive Cube Texturing Help
I cannot find out how to add a texture to a primitive cube. i have tried but every other way doesent work
Code:
for (var y = -30; y < 5; ++y)
for (var x = -30; x < 5; ++x) {
var cube : GameObject = GameObject.CreatePrimitive (PrimitiveType.Cube);
cube.transform.position = transform.position + Vector3(x, 0, y);
cube.renderer.material.mainTexture ("dirt.png");
}
Comment
Answer by Berenger · Feb 04, 2012 at 06:27 PM
I'm not sure what shader CreatePrimitive gives to your object, does it have a _MainTexture parameter ?
Also, is your dirt.png in the Resources folder ?
Answer by Kryptos · Feb 04, 2012 at 09:46 PM
I might be wrong but I think that the default material assigned to a primitve is read-only. You you try creating your own material with a proper shader.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to make a Cube with a texture in a JavaScript? 0 Answers
How do I put a texture on my Cube using code (JavaScript) 1 Answer
How do I make a texture? 2 Answers
What is wrong with my code? 1 Answer