Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class mouse_control : MonoBehaviour
- {
- RaycastHit hit;
- private Color startcolor;
- int i = 0;
- void Update()
- {
- if (Input.GetMouseButtonDown(0))
- {
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- if (Physics.Raycast(ray, out hit) && i<1)
- {
- startcolor = hit.collider.GetComponent<Renderer>().material.color;
- hit.collider.GetComponent<Renderer>().material.color = Color.yellow;
- i++;
- }
- if (i > 1)
- {
- hit.collider.GetComponent<Renderer>().material.color = startcolor;
- i = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement