アプリ鬼嫁3:ボタンの挙動について
今日の進捗
・ボタンサイズ調整
・ボタンの挙動を作成
以下がボタンに実装したスクリプトのサンプルです。
Test_Button.js
#pragma strict private var incX : float = 0.5; private var incY : float = -0.5; var OffTexture : Texture2D; var OnTexture : Texture2D; function OnMouseDown() { transform.position = Vector3(this.transform.position.x + incX, this.transform.position.y + incY, this.transform.position.z); renderer.material.mainTexture = OnTexture; Debug.Log("Button Down"); } function OnMouseUp() { transform.position = Vector3(this.transform.position.x - incX, this.transform.position.y - incY, this.transform.position.z); renderer.material.mainTexture = OffTexture; Debug.Log("Button Up!"); } function OnMouseUpAsButton() { Debug.Log("OnMouse Button Up!!"); }
ボタンを押した時にOnTextureを呼び出し、右下に少しずれる。Debug.Log("Button Down");
ボタンを話した時にOffTextureを呼び出し、元の位置に戻る。Debug.Log("Button Up!");
ボタンを押している状態で、ボタンのエリア内でボタンを離すとDebug.Log("OnMouse Button Up!!");。
サンプルTest_Button.unitypackageのダウンロード
再生プレビューは、以下の続きを読むからお願いします。
さぁ、今日も一日ガンバロー!