- Home /
Help, getting ambiguous reference error
using "using System;" causes error
"Object is an ambiguous reference between Unity.Object and object"
for spriteArray
I need to use "using System;" for "TimeSpan" and "DateTime" calculations
e.g.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
public class arrayAndDateTimeTest : MonoBehaviour
{
public Object [] spriteArray;
private DateTime myDateTime;
private TimeSpan myTimeSpan;
// Use this for initialization
void Start ()
{
spriteArray = Resources.LoadAll ("EnergyBarSprites/Energy Bars"); //EnergyBarSprites
myDateTime = System.DateTime.Now;
myTimeSpan = TimeSpan.FromMinutes(10);
}
}
Comment
Best Answer
Answer by Dave-Carlile · Jan 04, 2016 at 09:21 PM
There are a couple of things you can do for this situation.
Fully qualify the class name. You can do that on Object..
UnityEngine.Object[] spriteArray...
or the System classes (while removing using System - it's not needed if you fully qualify the types)...
private System.TimeSpan myTimeSpan...
Another option is to use the using
keyword to declare an alias.
using UnityObject = UnityEngine.Object;
UnityObject[] spriteArray...
or do it on the System classes (again, remove using System)...
using TimeSpan = System.TimeSpan;
using DateTime = System.DateTime;
Or various combinations of those sorts of things.