https://docs.unity3d.com/ScriptReference/Graphics.html
第一个方法:Graphics.DrawMesh
Description
draw a mesh.
DrawMesh draws a mesh for one frame. The mesh will be affected by the lights, can cast and receive shadows and be affected by Projectors - just like it was part of some game object. It can be drawn for all cameras or just for some specific camera.
Use DrawMesh in situations where you want to draw large amount of meshes, but don’t want the overhead of creating and managing game objects. Note that DrawMesh does not draw the mesh immediately; it merely “submits” it for rendering. The mesh will be rendered as part of normal rendering process. If you want to draw a mesh immediately, use Graphics.DrawMeshNow.
because DrawMesh does not draw mesh immediately, modifying material properties between calls to this function will not make the meshes pick up them. if u want to draw series of meshes with the same material, but slightly different properties (e.g. cange color of each mesh), use MaterialPropertyBlock parameter.
Note that this call will create some internal resources while the mesh is queued up for rendering. The allocation happens immediately and will be kept around until the end of frame (if the object was queued for all cameras) or until the specified camera renders itself.
举例:
using UnityEngine;
public class GraphicsDrawMeshDemo : MonoBehaviour
{
public Camera camera1;
public Camera camera2;
public Mesh mesh;
public Material material1;
public Material material2;
private int scale = 2;
public void Update()
{
Matrix4x4 m = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one * scale);
Graphics.DrawMesh(mesh, m, material1, 0, camera1);
Graphics.DrawMesh(mesh, m, material2, 0, camera2);
}
}