我在unity 2D:中使用了此代码
float nilaiRandom;
void Start()
{
nilaiRandom = Random.Range(1.11f, -1.88f);
transform.position = new Vector2(transform.position.x, nilaiRandom);
}
Unity计数错误:AssetsGo.cs(14,23): error CS0104: 'Random' is an ambiguous reference between 'UnityEngine.Random' and 'System.Random'
我的团结到底发生了什么?解决办法是什么?请帮我
.Net附带System.Random
,Unity附带UnityEngine.Random
。如果同时具有using System
和using UnityEngine
,则它们之间存在歧义。限定名称以消除歧义:
UnityEngine.Random.Range(1.11f, -1.88f);