- Home /
Better way to assign texture2D & use shader
I have a gameobject with script to store Texture2D[] frames. Now I have Texture2D [] AUS, RUS, and 30 other countries. Each country need to store 48 frames. And I have 5 of this gameobject. Other than drag and drop each of the images into the AUS[47], are there ways to assign using something like this way AUS[0] = "image_name" in the script?
I will reuse the script for gameobjects in different scenes. Drag and drop 48 frames (each country) for 32 countries for a multiple times is really time consuiming.
Another question about shader. How to use a certain shader in script, such as Refractive?
Answer by poncho · Jan 24, 2014 at 02:04 PM
well, this is just a shorter form of your code
List<int> tackleFramesList = new List<int>() {3, 7, 11, 15, 19, 23, 27, 31};
int imageUserCount=0;
int tacleFramesCount=0;
for(int i=0;i<element.Count();i++)
{
if (i = tackleFramesList[tacleFramesCount])
{
tackle_User[0].tackleFrames[tacleFramesCount] = AUS[i];
tacleFramesCount += 1;
}
else
{
image_User[0].frames[imageUserCount] = AUS[i];
imageUserCount += 1;
}
}
you could replace tackle_User[0] and image_User[0], for a tackle_User[PlayerNumber], image_User[PlayerNumber] or something similar which will be tracking each of your 3 players, also all of the code in your "AUS" statement could be in a method that receives AUS as a parameter, then assing everything as you had already did, and send an other AUS kind element and a new list of elements to assing to the tackle_User, the same as the number of the User.
Good luck and happy coding
Your answer
Follow this Question
Related Questions
Texture2D to Texture3D 2 Answers
Distribute terrain in zones 3 Answers
Color specific sections of a texture 1 Answer
Applying decals / textures to uneven surfaces runtime 1 Answer
Texture2D.Resize and Shader 0 Answers