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. 【Selenium-WebDriver自学】Selenium-IDE测试创建(三)

    ==================================================================================================== ...

  2. Eclipse properties.config.yml 配置文件中文编码问题。Eclipse 配置文件插件解决方案

    写了中文默认转成unicode. 正常应该是这样子的 其实不是什么大问题只需要装一个插件就行了,插件有很多.推荐使用,Properties Editor 安装方式如下 .这里使用的是离线安装.即本地文 ...

  3. 通俗理解caller和callee

    caller 返回一个调用当前函数的引用: callee 返回一个正在被执行函数的引用: 举个例子: 当前有函数 a() 直接使用了caller 方法: b() 直接使用了callee方法: ca() ...

  4. val和var和Java

    object Hello { def main(args :Array[String]) { val k = i } } jvm代码 public final class Hello$ { publi ...

  5. [Writeup]百度一下,你就知道

    [Writeup]百度一下,你就知道 谢邀@宋雨田 人在607,刚下床 育才上网,信号不好 实名diss,能人宋雷 ---------------------- 以下是原答案 ------------ ...

  6. Flex学习笔记-自定义菜单的显示细节

    icon <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx=&qu ...

  7. FDLocalSQL

    FDLocalSQL http://docwiki.embarcadero.com/Libraries/Berlin/en/FireDAC.Phys.SQLiteVDataSet.TFDLocalSQ ...

  8. AS3 - 对文件和目录的操作

    1,写入到文件 1 2 3 4 5 var fileObj:File = File.documentsDirectory.resolvePath("hangge.txt"); va ...

  9. vue 监听state 任意值变化、监听mutations actions

    // store.watch((state) => state.count + 1, (newCount) => { // console.log(' 监听') // }) // stor ...

  10. YCSB性能测试工具使用(转)

    在网上查In-Memory NoSQL性能测试的资料时,偶然间发现了这个性能测试工具YCSB,全称为“Yahoo! Cloud Serving Benchmark”.它内置了对常见NoSQL数据库和数 ...