0
私はUnityにプレハブキューブを持っています。私はすでにそれを配置するためにいくつかのスクリプトを実行し、いくつかの頂点を移動してその形状を変更します。さて、私はそれをテクスチャすることを知っている、私はのような何かをする必要があります:Unity - C#スクリプトを使用してキューブの1面をテクスチャ化
Texture2D myTexture = Resources.Load("sample") as Texture2D;
cube.GetComponent<Renderer>().material.mainTexture = (Texture)myTexture;
それは非常にうまく動作します。しかし今、UVマッピングを使用して2つの異なるテクスチャをキューブに割り当てる方法を理解したいと思います(上部に1つ、側面に1つ)。
Texture2D topTexture = Resources.Load("topTex") as Texture2D;
Texture2D sideTexture = Resources.Load("sideTex") as Texture2D;
//And now, how do I say to only apply to which side?
cube.GetComponent<Renderer>().material.mainTexture = (Texture)topTexture;
cube.GetComponent<Renderer>().material.mainTexture = (Texture)sideTexture;
Renderer.material.maintextureコマンドでどのようにマッピングするのですか? – P4ndaH3ro