Private Texture array

Hi,

Does anyone know how to call textures into script through an array privately.

for example I have this.

private Texture[ ] numtex = new Texture[10];

void Start(){
numtex = Resource.LoadAll(“Sequence”) as Texture;
//I get an error, cannot convert type unityengine.Object[ ] to unityengine.Texture via reference conversion

// The next code snippet I have also done this and it works
numtex = Resources.FindObjectsOfTypeAll();
//but I have no idea where unity is drawing from since I am getting images ranging from the ones I want located in the Resource folder, to prefab screenshots to material screenshots so forth which are not.
}

also this second way scares me that it would be very processor intensive.

Any thoughts on how I could correctly call a series of textures into script privateley so I dont have to drag and drop through a public access modifer?

numTex = Resources.LoadAll<Texture>("Sequence");

Your code also would have worked, but you were trying to cast to Texture instead of Texture[ ]

1 Like

you need to cast it as a texture, as “Resources.LoadAll” returns an array of Type “Object”.

To load privately you are pretty limited, resources, or getting a reference from elsewhere, can I ask why you want to load the same sequence at runtime each time?

1 Like

Thanks for the quick reply’s!

Daniel thanks for helping me with that syntax. It works great.

Matt thanks for the insight. I am making an image sequence that is triggered based on an object vector coordinates. I just didn’t want to have to call a bunch of textures to save me some time. I am very new to unity so I hoped that answered your question.