Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Material SphereMaterial;
- // Use this for initialization
- void Start()
- {
- SphereMaterial = Resources.Load<Material>("Materials/man");
- if (SphereMaterial == null) Debug.Log("mat null");
- else Debug.Log("mat not null");
- Debug.Log("new Material: " + SphereMaterial.name);
- MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
- // Get the current material applied on the GameObject
- Material oldMaterial = meshRenderer.material;
- Debug.Log("Applied Material: " + oldMaterial.name);
- // Set the new material on the GameObject
- meshRenderer.material = SphereMaterial;
- }
- public class ButtonHandler : MonoBehaviour {
- public void ButtonInteract()
- {
- Debug.Log("changing matriel ");
- // Change the material of the game object here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement