Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

367
Vistas
Get list from another script in unity

I would like to get a value from a serialized list that is on another script. How can I do that? This is my list:

[System.Serializable]
public class Level
{
    public string Name;
    public Sprite Icon;
    public bool Unlocked;
    public bool Interactable;
}

public List<Level> levelList = new List<Level>();
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

First you need to put your list inside the scope of the class like this:

using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class Level {

    public List<Level> levelList = new List<Level>(); //List inside the class

    public string Name;
    public Sprite Icon;
    public bool Unlocked;
    public bool Interactable;
}

On your accesor class you need to have a class variable so that you can access that level instance. Then somewhere get the list of that level instance, as in for exmaple in the Start of the code below.

using System.Collections.Generic;
using UnityEngine;

public class ListGetter : MonoBehaviour
{
    public Level level;
    private List<Level> levelList;
    
    void Start()
    {
        levelList = level.levelList; //get level list
    }
}

You would need to define how your Level instance is created, and the class that holds the instance of the class to provide a more accurate way of accessing the levelList of your Level instance, which I think is what you are asking

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda