![](/img/trans.png)
[英]Random.Range in Unity3D is not giving numbers in the range given
[英]Why I cant use Random.Range code system on Unity 2D
我在 unity 2D 中使用此代码:
float nilaiRandom;
void Start()
{
nilaiRandom = Random.Range(1.11f, -1.88f);
transform.position = new Vector2(transform.position.x, nilaiRandom);
}
Unity count Error 它说: Assets\\Go.cs(14,23): error CS0104: 'Random' is an ambiguous reference between 'UnityEngine.Random' and 'System.Random'
我的 unity 实际发生了什么以及解决方案是什么? 请帮我
.Net 带有System.Random
,Unity 带有UnityEngine.Random
。 如果您同时using System
和using UnityEngine
则它们之间存在歧义。 限定名称以消除歧义:
UnityEngine.Random.Range(1.11f, -1.88f);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.