- Home /
Is performance relevant how assign sprites in inspector ?
I have a question regarding for example how sprites are assigned in the inspector . (sorry for my english is a bit basic) If I have many GUI elements that need to reuse the same images. Is it less efficient if I assign to those elements the sprites that have to change directly to that object? Or it is better for example to have an object out of scene or a controller that already has those assigned images and load them from there. I like to put some example to show what im trying to ask
What is better to do it this way? (this a example code of a custom button)
public Image button;
public Image icon;
public Text text;
//normal
public sprite buttonNormal;
public sprite iconNormal;
//over
public sprite buttonOver;
public sprite iconOver;
or this way ?
public ImagesGUI images;
public Image button;
public Image icon;
void Start()
{
button.sprite = images.buttonNormal;
icon.sprite = images.iconNormal;
}
Once Unity loads an image does not interfere in memory the times we assign that image in the inspector? I know that in a small project or with few elements should not notice any problem but my game uses many elements of this type and it is necessary to be reusing the same images again and again
Your answer
Follow this Question
Related Questions
Unity UI Slowing Down Android Phone 0 Answers
Resources loading vs public linking in inspector 1 Answer
Multiple classes inside each other 1 Answer
InspectorWindow.DrawEditors high CPU in Editor. 1 Answer
How to fix UI healthbar 1 Answer