Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Monobehaviour of type List using new keyword

Discussion in 'Editor & General Support' started by theo9743, Apr 19, 2020.

  1. theo9743

    theo9743

    Joined:
    Feb 18, 2020
    Posts:
    12
    Here's what I want to do
    Code (CSharp):
    1. private List<HighScore> highScores = new List<HighScore>();
    But I can't due to the fact the class inherits from mono behaviour.

    Does anyone know the correct syntax to do this? Driving me nuts
     
  2. Philip-Rowlands

    Philip-Rowlands

    Joined:
    May 13, 2013
    Posts:
    353
    Does your class include an import on System.Collections.Generic? If not, try adding one.
     
  3. theo9743

    theo9743

    Joined:
    Feb 18, 2020
    Posts:
    12
    yeah it does, I just get the errror "you are trying to create a monobehaviour using the 'new' keyword, this is not allowed..."