public static float value ;

描述

返回介于 0.0 [含] 与 1.0 [含] 之间的随机数(只读)。

此属性可能会返回 0.0 和 1.0。此行为与许多其他随机数生成器的行为不同,它们返回的值小于 1.0,但从不完全等于 1.0。

using UnityEngine;

public class Example : MonoBehaviour { void Start() { Color randomColor = RandomColor(); }

// Generate a random color value. Color RandomColor() { // A different random value is used for each color component (if // the same is used for R, G and B, a shade of grey is produced). return new Color(Random.value, Random.value, Random.value); } }