Script error after upgrade
I got the following error in one of my scripts after upgrading from 5.1.2 to 5.2.1:
Assets/Blacksmith_Environment/Features/AtmosphericScattering/Code/AtmosphericScattering.cs(82,39): error CS0121: The call is ambiguous between the following methods or properties: `UnityEngine.Mesh.SetTriangles(System.Collections.Generic.List<int>, int)' and `UnityEngine.Mesh.SetTriangles(int[], int)'
Here is the line of script it is referring to:
mf.sharedMesh.SetTriangles(null, 0);
Answer by Mako-Infused · Sep 24, 2015 at 12:25 AM
The error message is telling you that the compiler cannot decide which method you're referring to. Then it has 2 methods listed, one which takes a list, and the other takes an array as the first parameter. Since you have a null for your first argument it cannot distinguish with method you're trying to call.
The easiest way to fix this would be to use an empty array (or list). So just replace your code with:
mf.sharedMesh.SetTriangles(new List<int>(), 0);
Or this:
mf.sharedMesh.SetTriangles(new int[] {}, 0);
Or, if you don't need that line of code you can always delete it.
Your answer
Follow this Question
Related Questions
Error upon rebooting Unity - "Associated script cannot be loaded" How can I resolve this? 2 Answers
An object reference is required for non-static field, method, or property 1 Answer
How do I create a Continuous Turn in XR for my VR Rig instead of Snap Turn Provider? 0 Answers
pressing/turning something in VR to do stuff 0 Answers
Editor crashes immediately 0 Answers