Hello, I ran into an error while following the instructions in this course that rendered an ambiguous reference error. Attached is a screenshot. I’m curious how to navigate this as well as what went wrong along the way so that I can avoid it in future work. Thank you!
1 Like
Just remove this using
and it will be fine.
Both UnityEngine
and System.Diagnostics
have a Debug
type. You have a using
that references both these namespaces, so the compiler doesn’t know which one you want to use, hence the ‘ambiguous reference’ error. You don’t need the System.Diagnostics
one, so you can remove the using
that references it.
A tangent for the future you
In the future, you will get this problem again because you will want to create a serialisable object and do something random. But both UnityEngine
and System
have a Random
type. When that happens, you will need both using
clauses and this will become a problem. To solve this you can;
- Use the full namespace to use the type
using System;
using UnityEngine;
float randomValue = UnityEngine.Random.value;
- Or alias the type in the
using
section
using System;
using UnityEngine;
using Random = UnityEngine.Random
float randomValue = Random.value;
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.