- Home /
This question was
closed May 10 at 05:29 AM by
cavachie.
Question by
cavachie · May 08 at 11:27 PM ·
gameobjectmaterialplayerchange
Player Material Change works on shop preview menu, does not change Player material on other scenes.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class MaterialChanger : MonoBehaviour { public GameObject Player; public GameObject Player2; public GameObject Player3; public Material skinMaterial;
public void OnMouseDown()
{
Player.GetComponent<MeshRenderer>().material = skinMaterial;
Player2.GetComponent<MeshRenderer>().material = skinMaterial;
Player3.GetComponent<MeshRenderer>().material = skinMaterial;
}
void Awake()
{
GameObject.FindGameObjectsWithTag("Player");
if (gameObject.tag == "Player")
{
DontDestroyOnLoad(this.gameObject);
}
}
}
Comment