N
N
NeoLight32020-07-13 20:57:57
C++ / C#
NeoLight3, 2020-07-13 20:57:57

How to change the texture of a Unity object in C#?

How can I change the texture of all Zombie objects in C#?

Zombie[] array = UnityEngine.Object.FindObjectsOfType(typeof(Zombie)) as Zombie[];
Zombie[] array2 = array;
foreach (Zombie zombie in array)
{
 zombie.gameObject.GetComponent<Renderer>().material.mainTexture =   args.sender.player.gameObject.GetComponent<Renderer>().material.mainTexture;
}

Есть ли здесь ошибка ?

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