"Lan Unity Development Fundamentals Three" lesson 13 mouse Events
Recommended Video Lecturer Blog: http://11165165.blog.51cto.com/
One, mouse events
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/C3/wKiom1fg3pXSskJTAAsFJWZczbE197.png-wh_500x0-wm_3 -wmp_4-s_230421741.png "style=" Float:none "title=" Unity engine Lesson 13 mouse event 205.png "alt=" Wkiom1fg3pxsskjtaasfjwzczbe197.png-wh_50 "/>
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/87/BF/wKioL1fg3p6jfT7bABG8w53gVwA817.png-wh_500x0-wm_3 -wmp_4-s_2124331128.png "style=" Float:none "title=" Unity engine Lesson 13 mouse event 746.png "alt=" Wkiol1fg3p6jft7babg8w53gvwa817.png-wh_50 "/>
Let's take a look at how mouse events are implemented in the scene.
First, we create a Cube,then align the camera with the cubeandthen adjust the viewing angle.
then, we are Create a script Teston the Cube, and then practice the mouse events.
1. Mouse events: OnMouseDown () , OnMouseUp ()
usingUnityengine;
usingSystem.Collections;
Public class Test : Monobehaviour {
// mouse events
//1, called when the mouse clicks down
voidOnMouseDown () {
Print ("Down");
}
//2, called when the mouse is canceled
voidOnMouseUp () {
Print ("Up");
}
}
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/87/BF/wKioL1fg3reiXcCUABG8w53gVwA054.png-wh_500x0-wm_3 -wmp_4-s_2625571747.png "title=" Unity engine Lesson 13 mouse event 746.png "alt=" Wkiol1fg3reixccuabg8w53gvwa054.png-wh_50 "/>
2. Mouse Events: Onmousedrag () , onmouseexit () , onmouseexit () , Onmouseupasbutton ()
usingUnityengine;
usingSystem.Collections;
Public class Test : Monobehaviour {
// mouse events
//1, called when the mouse clicks down
voidOnMouseDown () {
Print ("Down");
}
//2, called when the mouse is canceled
voidOnMouseUp () {
Print ("Up");
}
//3, called when the left mouse button is pressed continuously
voidOnmousedrag () {
Print ("Drag");
}
//4, called when the mouse enters the interior
voidOnmouseenter () {
Print ("Enter");
}
//5, called when the mouse is left to the inside
voidOnmouseexit () {
Print ("Exit");
}
//6, when the mouse continues to stay on the object of the game call
voidOnMouseOver () {
Print ("Over");
}
//7, when we click on the game object like a button click
voidOnmouseupasbutton () {
Print ("Upasbutton");
}
}
"Lan Unity Development Fundamentals Three" lesson 13 mouse Events