Hi folk. I need your help. Can you explain script behaviour?
There is a test project with one button and one script.
script:
using UnityEngine;
using System;
public class TestScript : MonoBehaviour {
private void TestFunc(object value, Action action = null) {
Debug.Log("Single");
}
private void TestFunc(object[] value, Action action = null) {
Debug.Log("Array");
}
public void OnClick() {
object single = new object();
this.TestFunc(single); // <-- All good
object[] array = new object[] { };
this.TestFunc(array); // <-- Error is here
}
}
MS VS 2016 doesn’t show any errors.
But I received error in Unity:
Assets/TestScript.cs(18,10): error CS0121: The call is ambiguous between the following methods or properties: ‘TestScript.TestFunc(object, System.Action)’ and ‘TestScript.TestFunc(object, System.Action)’
PS: sorry for my English
PPS: this is compiler bug
I’m glad to inform that we have fixed this and will be released with the new version of our compiler (on Unity 5.5)