Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

594
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda