[34562-namespace+error.png|34562]the Scripting API isn’t very specific. im doing everything it says, but I get an error:
CS0246: The type or namespace name `T’ could not be found. Are you missing a using directive or an assembly reference?
[34562-namespace+error.png|34562]the Scripting API isn’t very specific. im doing everything it says, but I get an error:
CS0246: The type or namespace name `T’ could not be found. Are you missing a using directive or an assembly reference?
You can try out the implementation as follows:
using UnityEngine;
using System;
using System.Collections;
public class ExampleScript : MonoBehaviour
{
public string[] names;
public string user;
private void Start()
{
// Testing: Call the generic Contains function
Debug.Log(Contains<string>(names, user));
}
public static bool Contains<T>(T[] names, T user)
{
return Array.IndexOf(names, user) != -1;
}
}