Unity lists not working while using collection generic
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class lists : MonoBehaviour {
public List<int> cps = new List<int>();
public void Start()
{
}
public void Update()
{
if (Input.GetKeyDown (KeyCode.Space)) {
cps.Add (Random.Range (1, 100));
}
}
}
I have included System.Collections; and System.Collections.Generic; yet It says there is no name "List" in the context
Answer by OWL7seven · Feb 15, 2017 at 06:39 PM
thats weird. i copied your code and its working by me . which version of unity are you using?
just try
public List<int> cps;
Answer by mehrzadb · Sep 28, 2017 at 04:33 AM
Having the exact same issue here. Apparently, Unity engine for version 2017 b1.1 does not include a List implementation for their System.Collection.Generics. Oddly enough as far as I can search there should be an existing class library List which handles List creations. But can only find Linked List.
I have been working on Unity built for Linux Debian stable version of 2017 1.1xf for the past few days as well, no luck.
If unity has forgotten to update these libraries that's just a downer :'D.
I am including a screenshot of my code here:
Answer by protopop · Dec 08, 2018 at 02:02 AM
My LIST and array keywords like Count and Length were suddenly all showing up red. I closed and restarted MonoDevelop and that fixed the issue.
Your answer
Follow this Question
Related Questions
If statement not working correctly 1 Answer
m_size < k_reference_bit error 0 Answers
GameObject has undefined tag! 0 Answers
Cloud build with google play games give me an error 0 Answers
Unable to list target platforms when building for Android on Mac 0 Answers