Answer the question
In order to leave comments, you need to log in
How to set prefab images correctly?
In my prefab (of which there are many), the appearance (pictures) will change during the game, I asked the prebuff a script of this kind
public Image ImageTest;
private Sprite Image1, Image2, Image3, Image4, Image5;
private void Awake(){
Image1 = Resources.Load <Sprite>("Images/Image1");
Image2 = Resources.Load <Sprite>("Images/Image2");
Image3 = Resources.Load <Sprite>("Images/Image3");
Image4 = Resources.Load <Sprite>("Images/Image4");
Image5 = Resources.Load <Sprite>("Images/Image5");
}
public void ReplacePrefab(int t){
switch(t){
case 1: ImageTest.GetComponent<Image>().sprite = Image1; break;
case 2: ImageTest.GetComponent<Image>().sprite = Image2; break;
case 3: ImageTest.GetComponent<Image>().sprite = Image3; break;
case 4: ImageTest.GetComponent<Image>().sprite = Image4; break;
case 5: ImageTest.GetComponent<Image>().sprite = Image5; break;
}
}
Answer the question
In order to leave comments, you need to log in
You think correctly. And even if you add LINKS to already loaded pictures into another object, nothing will change.
But maybe there is nothing wrong with that. We must proceed from how quickly the pictures should change. If we allow a lag and loading there, then what prevents them from loading them only if a change is necessary?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question