I'm getting error CS0104 due to ambiguous reference lines from the SceneManager.cs Getting Started

Include the following details while filing a bug report (edit as applicable):

  • Issue category: ARDK Virtual Studio Tools
  • Device type & OS version: Iphone 12 on iOS 16.0.2
  • Host machine & OS version: Mac M1 Pro on Monterey
  • Issue Environment : Unity Remote/Visual Studio
  • ARDK version: 2.3.0
  • Unity version: 3.3.0

Bug reproduction steps:

I’ve copied and pasted from the website, tried from scratch twice, i’m stuck. I’ve looked online and i’m not getting a grasp of the solution here.

Assets/Scripts/SceneManager.cs(58,38): error CS0104: ‘Quaternion’ is an ambiguous reference between ‘UnityEngine.Quaternion’ and ‘System.Numerics.Quaternion’

Assets/Scripts/SceneManager.cs(58,59): error CS0104: ‘Vector3’ is an ambiguous reference between ‘UnityEngine.Vector3’ and ‘System.Numerics.Vector3’

Assets/Scripts/SceneManager.cs(63,31): error CS0104: ‘Vector3’ is an ambiguous reference between ‘UnityEngine.Vector3’ and ‘System.Numerics.Vector3’

Thanks

Doesn’t seem like an ARDK issue to me. The problem you have is basically as the error suggests: in this script you included 2 namespaces: UnityEngine and System.Numerics. Both of these define a Quaternion and Vector3 so if you don’t specify from which namespace you want to use, the compiler can’t decide on either one.

The solution:
Make a decision on which you want to use, in your case i assume it’s the Unity version so you can put these lines on top of the script:

using Vector3 = UnityEngine.Vector3;
using Quaternion = UnityEngine.Quaternion;

If that breaks things than you could also specify the namespace for each variable by prepending the namespace.

2 Likes

Worked directly, i’m new to coding in general. Big thank you from Quebec city

Hello Francois,

I also wanted to add that if you’re attempting to use specific data types within the System.Numerics namespace, you can also import that specific type or types and nothing more

For example, let’s say that all you need from System.Numerics is their BigInteger type and the Imaginary type, you can do the following:

using System.Numerics.BigInteger;
using System.Numerics.Imaginary;

This will ONLY import BigInteger and Imaginary from the Numerics namespace and nothing else.

If you are trying to use data types in System.Numerics that also exist in Unity like Quaternion and Vector3 then Merijn’s suggestion to create an alias for one of the types would be the best approach.

I would recommend that if you’re stuck between using a data type that exists in both Unity and the Numerics namespace (or any other namespace that causes a conflict with Unity) to stick to the Unity type. This would also greatly decrease the possibility of issues when using ARDK.

Since I see you’re new to coding, I also recommend learn.unity.com which is a resource to learn both Unity and C# as it pertains to Unity.

I am going to weigh in on this as I am at the same spot. I want to make an important point that this is a direct copy from the 1st tutorial called “The basics - Getting started with Lightship”.
The first lightship pages I saw had this quote " For a step-by-step getting started guide and video, see the Getting Started Basics Guide"
These errors prevent any movement forward. Additionally this tutorial mentions at the top and has used strikethrough to indicate that you don’t have to create an empty game object named SceneMaster but references it many times in the following steps. The above errors were keeping me from moving forward! I could take your advice and make the types called out with USING but I think fixing the tutorial should come at a bigger priority. But I have questions about all the references to the non-existent SceneManager object.
Realize at this point I have not done any coding in lightship other than the single copy of the example script found in the tutorial.