Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class mouse_control : MonoBehaviour
  5. {
  6. RaycastHit hit;
  7.  
  8. private Color startcolor;
  9.  
  10. int i = 0;
  11.  
  12. void Update()
  13. {
  14. if (Input.GetMouseButtonDown(0))
  15. {
  16. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  17. if (Physics.Raycast(ray, out hit) && i<1)
  18. {
  19. startcolor = hit.collider.GetComponent<Renderer>().material.color;
  20. hit.collider.GetComponent<Renderer>().material.color = Color.yellow;
  21. i++;
  22. }
  23.  
  24. if (i > 1)
  25. {
  26. hit.collider.GetComponent<Renderer>().material.color = startcolor;
  27. i = 0;
  28. }
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement