- Home /
type or namespace name `List`1' could not be found
using UnityEngine;
using System.Collections;
public class ListTest : MonoBehaviour {
// Use this for initialization
void Start () {
List<float> test1 = new List<float> ();
}
// Update is called once per frame
void Update () {
}
}
Ideally I want the List to be a member variable but it isn't even working as a local variable.
It gives the following error:
Assets/ListTest.cs(8,17): error CS0246: The type or namespace name List
1' could not be found. Are you missing a using directive or an assembly reference?
BTW when I used autocomplete, "List" doesn't show up... but IList does but it doesn't seem to work either.
In the code "List" is in red in both places. The same problem happens if I use a class for the list such as Vector3.
Answer by Bunny83 · Jun 22, 2014 at 02:22 AM
You have to add:
using System.Collections.Generic;
ps: If you right-click on the type (in your case List< float >
) the top point in the menu is "resolve". There it usually offers different ways to resolve the type problem. Either by adding using System.Collections.Generic; at the top or by adding the full classname:
System.Collections.Generic.List<float>
If the type exists in multiple namespaces they should be listed there and you have to pick the one you actually want.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Grab a specific item from a list 3 Answers
Start function on a listed non mono script? 2 Answers
Public list are not reflecting in inspector. 1 Answer
Why does list.Last() not exist? 1 Answer