M
M
mygazztop2020-05-17 18:31:01
C++ / C#
mygazztop, 2020-05-17 18:31:01

Why don't prefab properties change?

Hello. Such a problem: from a script, I change the sprite image of the SpriteRenderer component (like another skin) in a certain prefab, having a link to the SpriteRenderer. And the problem is that when I run the game in unity, everything works, i.e. skin changes. And when I run this in the build (apk file), the skin does not change. Why is that?

The code is elementary, I will give an excerpt:

[SerializeField] SpriteRenderer player; //в инспекторе на это поле я перетаскиваю префаб игрока
[SerializeField] Sprite[] skins; // сюда перетаскиваю картинки игрока (скины)
int i = Random.Range(0, skins.Length);
player.sprite = skins[i]; // так я назначаю скин игроку

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question