Mesh.CombineMeshes

  public void CombineMeshes(CombineInstance[] combine, bool mergeSubMeshes = true, bool useMatrices = true, boolhasLightmapData = false);

combine Descriptions of the Meshes to combine.
mergeSubMeshes Defines whether Meshes should be combined into a single sub-Mesh.
useMatrices Defines whether the transforms supplied in the CombineInstance array should be used or ignored.

  Combining Meshes is useful for performance optimization.

  If mergeSubMeshes is true, all the Meshes are combined to a single sub-Mesh. Otherwise, each Mesh goes into a different sub-Mesh. If all Meshes share the same Material, set this to true.

  If useMatrices is true, the transform matrices in CombineInstance structs are used. Otherwise, they are ignored.

  

using UnityEngine;
using System.Collections; [RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class ExampleClass : MonoBehaviour {
void Start() {
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
int i = ;
while (i < meshFilters.Length) {
combine[i].mesh = meshFilters[i].sharedMesh;
combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
meshFilters[i].gameObject.active = false;
i++;
}
transform.GetComponent<MeshFilter>().mesh = new Mesh();
transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);
transform.gameObject.active = true;
}
}

Mesh.CombineMeshes的更多相关文章

  1. Unity mesh 合并

    簡介: 基本上就是把 很多物體結合成一個物體 的作法,這種做法有很多優點,例如:1. 提高效能2. 統一材質 (只要建立一個材質,就能控制.分配給所有物體)3. 動畫控制方便 (像是你要在 Unity ...

  2. Unity性能优化(4)-官方教程Optimizing graphics rendering in Unity games翻译

    本文是Unity官方教程,性能优化系列的第四篇<Optimizing graphics rendering in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...

  3. 移植UE4的模型操作到Unity中

    最近在Unity上要写一个东东,功能差不多就是在Unity编辑器上的旋转,移动这些,在手机上也能比较容易操作最好,原来用Axiom3D写过一个类似的,有许多位置并不好用,刚好在研究UE4的源码,在模型 ...

  4. Unity渲染优化中文翻译(二)——CPU的优化策略

    紧接上一篇文章,继续渲染的优化问题,若有错误,请指出,让我也学习进步,谢谢. 如果游戏渲染问题来自CPU 概括的来说,CPU在一帧的渲染中的工作可以分为三个部分: . 决定谁需要被渲染 . 为GPU准 ...

  5. Unity 网格合并

    从优化角度,Mesh需要合并. 从换装的角度(这里指的是换形状.换组成部件的换装,而不是挂点型的换装),都需要网格合并.材质合并.如果是人物的换装,那么需要合并SkinnedMeshRenderer, ...

  6. Unity网格合并_材质合并

    [转]Unity网格合并_材质合并 原帖请戳:Unity网格合并_材质合并 写在前面: 从优化角度,Mesh需要合并. 从换装的角度(这里指的是换形状.换组成部件的换装,而不是挂点型的换装),都需要网 ...

  7. 【转】Unity网格合并_材质合并

    原帖请戳:Unity网格合并_材质合并 写在前面: 从优化角度,Mesh需要合并. 从换装的角度(这里指的是换形状.换组成部件的换装,而不是挂点型的换装),都需要网格合并.材质合并.如果是人物的换装, ...

  8. Unity优化方向——优化Unity游戏中的图形渲染(译)

    CPU bound:CPU性能边界,是指CPU计算时一直处于占用率很高的情况. GPU bound:GPU性能边界,同样的是指GPU计算时一直处于占用率很高的情况. 原文:https://unity3 ...

  9. Unity3d优化总结2

    优化: 1. 更新不透明贴图的压缩格式为ETC 4bit,因为android市场的手机中的GPU有多种, 每家的GPU支持不同的压缩格式,但他们都兼容ETC格式, 2. 对于透明贴图,我们只能选择RG ...

随机推荐

  1. Error building Player: UnityException: Bundle Identifier has not been set up correctly

    错误提示: Error building Player: UnityException: Bundle Identifier has not been set up correctlyPlease s ...

  2. spring security demo

    直接上代码. 这个类似于配置一个shiro.xml redis.xml boot 里面xml用注解取代. 启动类 验证启用: 退出: end. spring 官网 start.spring.io

  3. php 目录

    1.laravel pswd  oauth2 2.理解二叉树 3.IOC容器 4.微信支付 4.1 微信支付申请 5.DI 6.支付宝 支付H5 7.html 转 word 8.php-fpm 启动详 ...

  4. Node 操作 MySQL 数据库

    1, 下载 mysql 依赖 => npm -i mysql 2, 写一个核心工具类, 用于获取线程池连接 mysql-util.js // 引入 mysql 数据库连接依赖 const mys ...

  5. date命令的用法

    date +%F data +%w, date +%W cal date -d "-1 years" +%F date -d "-1 hour" +%T 时间与 ...

  6. Image Base64 Datasnap Image delphi与c#互相兼容识别

    delphi用,不能与java.c#互相识别. procedure TServerMethods.UpdateDoc(ItemID : integer; doc : TStream); delphi用 ...

  7. maven的环境变量配置

    一: 首先下载maven, 下载地址:http://maven.apache.org/download.html 打开这个连接:选择File下面的apache-maven-3.2.1-bin.zip链 ...

  8. C语言复习:内存模型1

    数据类型本质分析 数据类型概念 "类型"是对数据的抽象; 类型相同的数据有相同的表现形式/存储格式以及相关的操作; 程序中使用的所有数据都必定属于某一种数据类型; 数据类型本质思考 ...

  9. 3.有关于Python列表简述

    一..title() [让所选择的列表元素的第一个字母大写] test = ['no1','No2','No3','No4'] book = "This My " + test[0 ...

  10. Shoulda, Woulda, Coulda

    Shoulda, Woulda, Coulda Share Tweet Share Tagged With: Should-Would-Could, Words that Begin with H R ...