前提・実現したいこと
Graphics.DrawMeshで描画しているメッシュの描画順序を変えたい
該当のソースコード
C#
1using UnityEngine; 2using System.Collections; 3 4public class PlayerControlScript : MonoBehaviour 5{ 6 Mesh mesh; 7 public Material material; 8 9 public static PlayerControlScript instance { get; private set; } 10 11 public float x { get; private set; } 12 public float y { get; private set; } 13 14 private void Start() 15 { 16 instance = this; 17 } 18 19 private void Update() 20 { 21 Vector3 vector = new Vector3(x, y, 0); 22 Graphics.DrawMesh(mesh, vector, Quaternion.AngleAxis(0.0f, new Vector3(1.0f, 0.0f, 0.0f)), material, 0); 23 } 24 25 public void PlayerGenerate() 26 { 27 mesh = new Mesh(); 28 Vector2 watercoo = World.instance.WaterCoordinates[0]; 29 x = watercoo.x; 30 y = watercoo.y; 31 32 mesh.vertices = new Vector3[] 33 { 34 new Vector3 (0, 0, 0), 35 new Vector3 (0, 1f, 0), 36 new Vector3 (1f, 0, 0), 37 new Vector3 (1f, 1f, 0), 38 }; 39 40 mesh.uv = new Vector2[] 41 { 42 new Vector2 (0, 0), 43 new Vector2 (0, 1), 44 new Vector2 (1, 0), 45 new Vector2 (1, 1), 46 }; 47 48 mesh.triangles = new int[] 49 { 50 0, 1, 2, 51 1, 3, 2, 52 }; 53 54 mesh.RecalculateNormals(); 55 mesh.RecalculateBounds(); 56 } 57}
試したこと
PlayerControlScriptで生成するメッシュは、予め生成していたメッシュの上に生成したいのですが、メッシュのZ位置を変えてもなにも変わりませんでした。
どのようにすれば、Graphics.DrawMeshで描画順序を変えることが出来るのでしょうか?
回答お願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。