SkinnedCloth.SetEnabledFading 启用淡入淡出

function SetEnabledFading (enabled : bool, interpolationTime : float = 0.5f) : void

Description描述

Fade the cloth simulation in or out, and enabled or disable the SkinnedCloth.

淡入或淡出布料模拟,并启用或禁用SkinnedCloth。

This function lets you enable or disabe the SkinnedCloth component, by setting the enabled parameter. Unlike setting the Cloth.enabled property directly, this will delay the action, and smoothly interpolate the mesh between the normal skinned mesh and the cloth simulation over a time of interpolationTime seconds. This helps you to turn on and off clothing simulation on characters without letting users notice the transition. Turning on and off clothing simulation is useful for managing the performance of your game, as cloth simulation is rather expensive. Calling this function repeatedly with the same parameters has no additional effect.

通过设置enabled参数,这个函数可以让你启用或禁用SkinnedCloth组件。不像直接设置Cloth.enabled属性,这个将延迟动作,并且平滑插值网格,以interpolationTime秒,在蒙皮网格法线和布料模拟之间。这有助于你打开和关闭角色布料模拟,没有让用户注意到过渡。打开和关闭布料模拟用于管理游戏的性能,布料模拟相当耗费系统资源。用同样的参数多次调用这个函数没有额外的影响。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public bool simulateCloth = true;
	void Awake() {
		if (transform.position - Camera.main.transform.position.sqrMagnitude > 20.0F * 20.0F)
			simulateCloth = false;

		GetComponent<SkinnedCloth>().SetEnabledFading(simulateCloth);
	}
}
// Smoothly turn cloth simulation on or off depending on distance to camera.
//平滑开启或关闭布料模拟,根据与相机的距离。

var simulateCloth = true;
if ((transform.position -Camera.main.transform.position).sqrMagnitude > 20.0f * 20.0f)
	simulateCloth = false;
GetComponent(SkinnedCloth).SetEnabledFading (simulateCloth);
Page last updated: 2011-3-26