S
S
Surface-ketch2016-03-31 21:30:48
C++ / C#
Surface-ketch, 2016-03-31 21:30:48

How to randomly change graphics in Unity?

How can I change the color of the game objects every time the level is restarted?
That is, let's say there is a red square, a red platform, etc. with configured physics, scripts, etc., is it possible to make sprites (namely sprites, not prefabs) with a green square and platform be loaded instead of red ones when restarting the level?
PS Another question: can inspector be copied from one object to another?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Basmanov, 2016-04-01
@Surface-ketch

There are several implementation options:
If your objects are difficult to set up, and differ only in color, then it is better to go the second way. You can change the color in many ways: replace the sprite or color in the SpriteRenderer , hang different materials, twist the color in the shader, etc. The task is to get a reference to the object being changed in the control script and replace the desired variable.
PS Right click on the head of the component, copy
Click on the component on another object, paste
RDk5g

E
Egor Sh, 2016-04-01
. @EgorkZe

Here you can read this thread, here is the answer to your question Link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question