zoukankan      html  css  js  c++  java
  • Unity3D优化之合并网格

    [csharp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
     
    using UnityEngine;  
    using System.Collections;  
      
    public class CombineMeshes : MonoBehaviour  
    {  
        void Start()  
        {  
            MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();  
            CombineInstance[] combine = new CombineInstance[meshFilters.Length];  
            int i = 0;  
            while (i < meshFilters.Length)  
            {  
                combine[i].mesh = meshFilters[i].sharedMesh;  
                combine[i].transform = meshFilters[i].transform.localToWorldMatrix;  
                meshFilters[i].gameObject.SetActive(false);  
                i++;  
            }  
      
            transform.GetComponent<MeshFilter>().mesh = new Mesh();  
            transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);  
            transform.gameObject.SetActive(true);  
        }  
    }   
     
    
     
    
    [csharp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
     
    using UnityEngine;  
    using System.Collections;  
    using UnityEditor;  
      
    public class EditorTools : MonoBehaviour  
    {  
      
        [MenuItem("Tools/Save Combine Mesh")]  
        public static void SaveMesh()  
        {  
            Mesh m = Selection.activeGameObject.GetComponent<MeshFilter>().sharedMesh;  
            AssetDatabase.CreateAsset(m, "Assets/tmp/cmbMesh.asset");  
            AssetDatabase.SaveAssets();  
        }  
    }  


    原文地址点击这里

  • 相关阅读:
    Debian ABC --- 1st time ---7
    django基础操作
    http协议
    css3种引入方式,样式与长度颜色,常用样式,css选择器
    前端3剑客
    视图,sql注入问题,事物,存储过程
    用户权限,pymysql
    表查询
    约束
    mysql数据类型
  • 原文地址:https://www.cnblogs.com/123ing/p/3722339.html
Copyright © 2011-2022 走看看