言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Mesh.CombineMeshes

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public function CombineMeshes(combine: CombineInstance[], mergeSubMeshes: bool = true, useMatrices: bool = true): void;
public void CombineMeshes(CombineInstance[] combine, bool mergeSubMeshes = true, bool useMatrices = true);
public def CombineMeshes(combine as CombineInstance[], mergeSubMeshes as bool = true, useMatrices as bool = true) as void

Parameters

combine 結合するメッシュの説明
mergeSubMeshes 全てのメッシュをひとつのサブメッシュに結合するか
useMatrices CombineInstance で提供された変換行列を使用するか、無視するか

Description

メッシュに複数のメッシュを組み合わせます

メッシュを結合することで、最適化につながります。 useMatrices が true である場合、全てのメッシュはひとつのサブメッシュに結合されます。そうでない場合、 各々のメッシュは別のサブメッシュに結合されます。もし全てのメッシュが同じマテリアルを共有している場合は true を設定して下さい。 もし useMatrices が false である場合 CombineInstance 構造体の変換行列は無視されます。

	@script RequireComponent(MeshFilter)
	@script RequireComponent(MeshRenderer)
	function Start () {
		var meshFilters: MeshFilter[] = GetComponentsInChildren(MeshFilter);
		var combine : CombineInstance[] = new CombineInstance[meshFilters.Length];
		for (var i = 0; i < meshFilters.Length; i++){
			combine[i].mesh = meshFilters[i].sharedMesh;
			combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
			meshFilters[i].gameObject.active = false;
		}
		transform.GetComponent(MeshFilter).mesh = new Mesh();
		transform.GetComponent(MeshFilter).mesh.CombineMeshes(combine);
		transform.gameObject.active = true;
	}
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 = 0;
        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;
    }
}
import UnityEngine
import System.Collections

[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class ExampleClass(MonoBehaviour):

	def Start() as void:
		meshFilters as (MeshFilter) = GetComponentsInChildren[of MeshFilter]()
		combine as (CombineInstance) = array[of CombineInstance](meshFilters.Length)
		i as int = 0
		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[of MeshFilter]().mesh = Mesh()
		transform.GetComponent[of MeshFilter]().mesh.CombineMeshes(combine)
		transform.gameObject.active = true