Unity3D性能优化之合并网格
来源:互联网 发布:杨振宁 国籍 知乎 编辑:程序博客网 时间:2024/04/28 04:25
结合网格有利于性能最优化,如果mergeSubMeshes为true,所有的网格会被结合成一个单个子网格。否则每一个网格都将变成单个不同的子网格。如果所有的网格共享同一种材质,设定它为真。如果useMatrices为false,在CombineInstance结构中的变换矩阵将被忽略。以下是合并当前物体下所有网格的代码:
01
using UnityEngine;
02
03
using System.Collections;
04
05
public class CombineMeshes : MonoBehaviour {
06
07
void Start() {
08
09
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
10
11
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
12
13
int i = 0;
14
15
while (i < meshFilters.Length) {
16
17
combine[i].mesh = meshFilters[i].sharedMesh;
18
19
combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
20
21
meshFilters[i].gameObject.active = false;
22
23
i++;
24
25
} Unity3D教程手册
26
27
transform.GetComponent<MeshFilter>().mesh = new Mesh();
28
29
transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);
30
31
transform.gameObject.active = true;
32
33
}
34
35
}
声明: 本文由( zqcyou )原创编译,链接: Unity3D性能优化之合并网格
- Unity3D性能优化之合并网格
- Unity3D优化之合并网格
- Unity3D优化之合并网格 整理
- Unity3d网格合并
- Unity3d网格合并
- Unity3d网格合并
- Unity3d之性能优化
- Unity3D性能优化之开发性能优化
- unity3d 性能优化之prafab
- Unity3D开发之性能优化
- unity3d 研究之 性能优化
- Unity3D开发之Unity3D性能优化总结
- Unity3D教程:Unity3D中网格合并示例
- Unity3D中网格合并示例研究
- Unity3D中网格合并示例研究
- Unity3D 多个网格模型合并 插件
- unity3d 性能优化之角色建模
- Unity3D性能优化之角色建模
- (step3.2.2)hdu 1087(Super Jumping! Jumping! Jumping!——简单DP)
- MongoDB自学笔记8--- 3.3 MongoDB Shell简介及简单使用
- timus 1572. Yekaterinozavodsk Great Well URAL 解题报告
- SQL 2005 完全卸载
- HDU 3047 并查集
- Unity3D性能优化之合并网格
- 题目1522:包含min函数的栈-九度
- 数据绑定时出现"这将导致集合中的两个绑定绑定到同一个属性"错误.
- LeetCode-Same Tree
- ids for this class must be manually assigned before calling save()
- IP数据报格式(网络层简介)
- SQL 2005 完全卸载
- POJ 2926 Requirements【最远曼哈顿距离】
- Android NDK学习与环境搭建