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

593
Vistas
Loading Texture list with Texture2D dynamically from file at RunTime in Unity

I have strings for the path to the Texture2D element I want to load from the List string that is filled dynamically from an XML file into the List Texture.

public List commands; public List icons = new List(); void Awake() { int i = 0; foreach (string element in commands) { icons.Insert(i, icons[i].Resources.Load(element, Texture2D)); //error line i++; }

}

Here is what I have so far but I'm generating the following compiler errors in Unity:

error CS1061: Type UnityEngine.Texture' does not contain a definition for Resources' and no extension method Resources of type `UnityEngine.Texture could be found (are you missing a using directive or an assembly reference?)

error CS1502: The best overloaded method match for `System.Collections.Generic.List.Insert(int, UnityEngine.Texture)' has some invalid arguments

error CS1503: Argument #2' cannot convert object' expression to type `UnityEngine.Texture'

It seems I cannot use Resources.Load directly with the icons elements as I am attempting to do but I'm at a loss for how else to go about it.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

foreach (string element in commands)
        {
         tex = (Texture2D) Resources.Load(element);
         icons.Add(tex);
        }

So I figured it out; above modifications are the changes.

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