1.修改Mesh UV

九张小图合并到一张大图上,然后修改Quad的UV分别取出九张小图。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class MeshTest : MonoBehaviour
{
// Start is called before the first frame update
public GameObject quadGO;
void Start()
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
Vector2 leftBottom = new Vector2(0 + i * 1 / 3f, 0 + j * 1 / 3f);
Vector2 rightBottom = leftBottom + new Vector2(1 / 3f, 0);
Vector2 leftTop = leftBottom + new Vector2(0, 1 / 3f);
Vector2 rightTop = leftBottom + new Vector2(1 / 3f, 1 / 3f);
Vector2[] uv = { leftBottom, rightBottom, leftTop, rightTop };
GameObject go = Instantiate(quadG

本文介绍了两种在Unity中减少DrawCall的方法:一是通过修改Mesh UV将九张小图合并到一张大图,调整UV坐标显示不同小图;二是使用GPU Instancing结合MaterialPropertyBlock设置uv缩放偏移,实现小图的显示。提供了相应的工程下载链接。
最低0.47元/天 解锁文章
7120

被折叠的 条评论
为什么被折叠?



