Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Material SphereMaterial;
  2.  
  3. // Use this for initialization
  4. void Start()
  5. {
  6. SphereMaterial = Resources.Load<Material>("Materials/man");
  7. if (SphereMaterial == null) Debug.Log("mat null");
  8. else Debug.Log("mat not null");
  9. Debug.Log("new Material: " + SphereMaterial.name);
  10. MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
  11.  
  12.  
  13. // Get the current material applied on the GameObject
  14. Material oldMaterial = meshRenderer.material;
  15. Debug.Log("Applied Material: " + oldMaterial.name);
  16. // Set the new material on the GameObject
  17. meshRenderer.material = SphereMaterial;
  18. }
  19.  
  20. public class ButtonHandler : MonoBehaviour {
  21.  
  22.  
  23. public void ButtonInteract()
  24. {
  25. Debug.Log("changing matriel ");
  26. // Change the material of the game object here
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement