Home>

I want to correct the displacement of Graphics.DrawMesh coordinates

Applicable source code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Drawmesh: MonoBehaviour
{
    Mesh planeMesh;
    public Material material;
    Mesh NewPlaneMesh ()
    {
        Vector3 [] array = new Vector3 [4];
        Vector2 [] array2 = new Vector2 [4];
        int [] array3 = new int [6];
        array [0] = new Vector3 (0, 0, 1);
        array [1] = new Vector3 (0, 1, 1);
        array [2] = new Vector3 (1, 0, 1);
        array [3] = new Vector3 (1, 1, 1);
        array2 [0] = new Vector2 (0, 0);
        array2 [1] = new Vector2 (0, 1);
        array2 [2] = new Vector2 (1, 0);
        array2 [3] = new Vector2 (1, 1);
        array3 [0] = 0;
        array3 [1] = 1;
        array3 [2] = 2;
        array3 [3] = 1;
        array3 [4] = 3;
        array3 [5] = 2;
        Mesh mesh = new Mesh ();
        mesh.name = "NewPlaneMesh ()";
        mesh.vertices = array;
        mesh.uv = array2;
        mesh.SetTriangles (array3, 0);
        mesh.RecalculateNormals ();
        mesh.RecalculateBounds ();
        return mesh;
    }
    Mesh PlaneMesh
    {
        get
        {
            if (planeMesh == null)
            {
                planeMesh = NewPlaneMesh ();
            }
            return planeMesh;
        }
    }
    Quaternion quaternion = Quaternion.Euler (0, 0, 180);
    private void Update ()
    {
        Graphics.DrawMesh (PlaneMesh, Vector3.one, Quaternion.identity, material, 0);
        Graphics.DrawMesh (PlaneMesh, Vector3.one, quaternion, material, 0);
    }
}

The Quaternion.identity and Quaternion are specified and drawn twice, but the coordinates specifying the Quaternion are misaligned even though the coordinates are the same for some reason. . Why is this? I asked a question because I didn't understand it. Answer please.

  • Answer # 1

    If rotating, rotate around (0,0) coordinates
    The tree picture is in the area (0,0)-(1,1), so I think it just rotates around the bottom left