返回介绍

LODGroup.SetLODs 设置细节列表

发布于 2019-12-18 15:37:57 字数 5408 浏览 834 评论 0 收藏 0

JavaScript => public function SetLODs(lods: LOD[]): void;
C# => public void SetLODs(LOD[] lods);

Parameters 参数

lodsThe LODs to use for this group.

Description 描述

Set the LODs for the LOD group. This will remove any existing LODs configured on the LODGroup.

为细节组设置细节。这将会从细节组中移除任何存在的细节配置。

JavaScript:

#pragma strict
public var group: LODGroup;
function Start() {
	// Create a GUI that allows for forcing a specific LOD level.
	group = gameObject.AddComponent.<LODGroup>();
	// Add 4 LOD levels
	var lods: LOD[] = new LOD[4];
	for (var i: int = 0; i < 4; i++) {
		var primType: PrimitiveType = PrimitiveType.Cube;
		switch (i) {
			case 1:
				primType = PrimitiveType.Capsule;
 
				break;
			case 2:
				primType = PrimitiveType.Sphere;
 
				break;
			case 3:
				primType = PrimitiveType.Cylinder;
 
				break;
		}
		var go: GameObject = GameObject.CreatePrimitive(primType);
		go.transform.parent = gameObject.transform;
		var renderers: Renderer[] = new Renderer[1];
		renderers[0] = go.GetComponent.<Renderer>();
		lods[i] = new LOD(1.0F / (i + 1), renderers);
	}
	group.SetLODs(lods);
	group.RecalculateBounds();
}
function OnGUI() {
	if (GUILayout.Button("Enable / Disable"))
		group.enabled = !group.enabled;
	if (GUILayout.Button("Default"))
		group.ForceLOD(-1);
	if (GUILayout.Button("Force 0"))
		group.ForceLOD(0);
	if (GUILayout.Button("Force 1"))
		group.ForceLOD(1);
	if (GUILayout.Button("Force 2"))
		group.ForceLOD(2);
	if (GUILayout.Button("Force 3"))
		group.ForceLOD(3);
	if (GUILayout.Button("Force 4"))
		group.ForceLOD(4);
	if (GUILayout.Button("Force 5"))
		group.ForceLOD(5);
	if (GUILayout.Button("Force 6"))
		group.ForceLOD(6);
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour
{
    public LODGroup group;
 
    void Start()
    {
        // Programmatically create a LOD group and add LOD levels. 
        // Create a GUI that allows for forcing a specific LOD level.
        group = gameObject.AddComponent<LODGroup>();
 
        // Add 4 LOD levels
        LOD[] lods = new LOD[4];
        for (int i=0; i<4; i++)
        {
            PrimitiveType primType = PrimitiveType.Cube;
            switch (i)
            {
                case 1:
                    primType = PrimitiveType.Capsule;
                    break;
                case 2:
                    primType = PrimitiveType.Sphere;
                    break;
                case 3:
                    primType = PrimitiveType.Cylinder;
                    break;
            }
            GameObject go = GameObject.CreatePrimitive(primType);
            go.transform.parent = gameObject.transform;
            Renderer[] renderers = new Renderer[1];
            renderers[0] = go.GetComponent<Renderer>();
            lods[i] = new LOD(1.0F / (i + 1), renderers);
        }
        group.SetLODs(lods);
        group.RecalculateBounds();
    }
 
    void OnGUI()
    {
        if (GUILayout.Button("Enable / Disable"))
            group.enabled = !group.enabled;
 
        if (GUILayout.Button("Default"))
            group.ForceLOD(-1);
 
        if (GUILayout.Button("Force 0"))
            group.ForceLOD(0);
 
        if (GUILayout.Button("Force 1"))
            group.ForceLOD(1);
 
        if (GUILayout.Button("Force 2"))
            group.ForceLOD(2);
 
        if (GUILayout.Button("Force 3"))
            group.ForceLOD(3);
 
        if (GUILayout.Button("Force 4"))
            group.ForceLOD(4);
 
        if (GUILayout.Button("Force 5"))
            group.ForceLOD(5);
 
        if (GUILayout.Button("Force 6"))
            group.ForceLOD(6);
    }
}

lodgroup

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文