I am fairly new at unity and coding in general. I have a script I have been putting together and it keeps having this error:
BCE0023: No appropriate version of ‘UnityEngine.Object.Instantiate’ for the argument list ‘(System.Collections.Generic.List., UnityEngine.Vector3, UnityEngine.Quaternion)’ was found.
Here is my script:
The error is on line 39. I have tried to find an answer everywhere, but with no success.
Any help would be appreciated.
The error is exactly what it says on the tin.
If you go to the manual, you can see the different versions of every method available in Unity. Looking at the [Instantiate] page, it lists two versions at the top of the page:
public static Object Instantiate(Object original, Vector3 position, Quaternion rotation);
public static Object Instantiate(Object original);
On Line 39, you’re calling:
Instantiate (blocksList, spawnPosition, spawnRotation);
blocksList is a List (you declare it as such on Line 25). spawnPosition is a Vector3. And spawnRotation is a Quaternion. So which of the two versions of the Instantiate method fit that set of parameters? Neither. That’s why Unity is telling you “No appropriate version of ‘UnityEngine.Object.Instantiate’ for the argument list ‘(System.Collections.Generic.List., UnityEngine.Vector3, UnityEngine.Quaternion)’ was found”
Considering the context of the rest of your code, I imagine you wanted to instantiate a single element from blocksList. i.e. Line 39 should read:
Instantiate(blocksList*, spawnPosition, spawnRotation);*
: Unity - Scripting API: Object.Instantiate
(p.s. in the future please post code as a codeblock, not a screenshot)
blocksList is of type List. You need to fetch one element of that list.
MSDN Generic List Reference