Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

38 行
906 B

using UnityEngine;
namespace BoatAttack
{
/// <summary>
/// Simple scripts sets a random HUE on a shader with the property '_Hue'
/// </summary>
public class RandomHue : MonoBehaviour
{
public MeshRenderer[] renderers;
private static readonly int Hue = Shader.PropertyToID("_Hue");
private void OnEnable()
{
RandomizeHue();
}
void RandomizeHue()
{
#if STATIC_EVERYTHING
var hue = 0f;
#else
var hue = Random.Range(0f, 1f);
#endif
if (renderers == null || renderers.Length <= 0) return;
foreach (var t in renderers)
{
if (t == null) continue;
var mat = new Material(t.sharedMaterial);
mat.SetFloat(Hue, hue);
t.material = mat;
}
}
}
}