05-17 06:36
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

Script for an Object Clicked 본문

CG & Video Games/Unity 3D

Script for an Object Clicked

cinema4dr12 2013. 5. 26. 12:19
  • A designated command executed when an object is clicked
  • This example shows to let change an object's color when it is clicked

using UnityEngine;

using System.Collections;

 

public class ObjectClicked : MonoBehaviour {

public GUIText myText;

 

// Use this for initialization

void Start () {

}

 

// Update is called once per frame

void Update () {

}

 

void OnMouseDown()

{

Activate();

}

 

void OnMouseEnter()

{

}

 

void OnMouseUp()

{

Deactivate();

}

 

void Activate()

{

renderer.material.color = Color.red;

}

 

void Deactivate()

{

renderer.material.color = Color.blue;

}

}

Comments