資源簡介
配套的博文:http://blog.csdn.net/anyuanlzh/article/details/40107577

代碼片段和文件信息
using?UnityEngine;
using?System.Collections;
using?System.Collections.Generic;
[ExecuteInEditMode]
public?class?Joystick?:?MonoBehaviour
{????
????#region?Delegate?&?Event
????public?delegate?void?JoystickEventHandler(Joystick?joystick);
????///?
????///?開如
????///?
????public?static?event?JoystickEventHandler?On_JoystickMoveStart;
????///?
????///?Occurs?when?the?joystick?move.
????///?
????public?static?event?JoystickEventHandler?On_JoystickMove;
????///?
????///?thumb偏離中心位置,并牌按住時,每幀的回調
????///?
????public?static?event?JoystickEventHandler?On_JoystickHolding;
????///?
????///?Occurs?when?the?joystick?stops?move
????///?
????public?static?event?JoystickEventHandler?On_JoystickMoveEnd;
????
????#endregion????
????#region???property
????[SerializeField]?bool?isRunInEditor?=?false;
????[SerializeField]private?string?joystickName?=?“NguiJoystick“;
????public?string?JoystickName?{?get?{?return?this.joystickName;?}?}
????[HideInInspector]private?bool?isLimitInCircle?=?true;
????public?bool?IsLimitInCircle?{?get?{?return?this.isLimitInCircle;?}?}
????[SerializeField]private?int?radius?=?100;
????public?int?Radius?{?get{?return?this.radius;?}?}
????[SerializeField]
????private?float?minAlpha?=?0.3f;
????public?float?MinAlpha?{?get?{?return?this.minAlpha;?}?}
????private?Vector2?joystickAxis?=?Vector2.zero;
????///?
????///?Gets?the?joystick?axis?value?between?-1?&?1...
????///?
????///?
????///?The?joystick?axis.
????///?
????public?Vector2?JoystickAxis?{?get?{?return?this.joystickAxis;?}?}
????private?Vector2?lastJoystickAxis?=?Vector2.zero;
????public?Vector2?LastJoystickAxis?{?get?{?return?this.lastJoystickAxis;?}?}
????
????bool?isForBid?=?false;
????///?
????///?判斷joystick是否被禁用
????///?
????public?bool?IsForBid?{?get?{?return?this.isForBid;?}?}
????bool?isHolding?=?false;
????public?bool?IsHolding?{?get?{?return?this.isHolding;?}?}
????#endregion
????UIWidget?root;
[SerializeField]UISprite?bg;
[SerializeField]UISprite?thumb;
????void?Awake()
????{
????????this.name?=?this.JoystickName;
????????root?=?this.GetComponent();
????????Init();
????}
//?Update?is?called?once?per?frame???
void?Update?()
????{
????????if?(isRunInEditor?&&?Application.isEditor?&&?!Application.isPlaying)
????????{
????????????SetJoystickSize(radius);
????????}
????????if?(!isForBid?&&?isHolding)
????????{
????????????Debug.Log(“111111“);
????????????if?(On_JoystickHolding?!=?null)
????????????{
????????????????On_JoystickHolding(this);
????????????}
????????}
}
????void?Init()
????{
????????bg.transform.localPosition?=?Vector3.zero;
????????thumb.transform.localPosition?=?Vector3.zero;
????????SetJoystickSize(radius);
????????Lighting(minAlpha);
????}
#region?ngui?event
????/////?
????/////?test
????/////?
????//void?onclick?()
????//{
????//????Debug.Log(“mouse?pos?:“?+?Input.mousePosition?+?“?--?tou
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4933??2014-10-15?12:05??Assembly-CSharp-firstpass-vs.csproj
?????文件??????12700??2014-10-15?12:05??Assembly-CSharp-vs.csproj
?????文件???????2399??2014-10-15?12:24??NGUIJoystick.sln
?????文件????????456??2014-10-15?12:24??NGUIJoystick.userprefs
?????文件???????2409??2014-10-15?12:24??NGUIJoystick-csharp.sln
?????文件??????27068??2014-10-11?11:18??Assets\demo.unity
????..A..H.????????90??2014-10-08?17:41??Assets\demo.unity.me
?????文件????????865??2014-10-15?14:10??Assets\Joystick\example\JoystickTest.cs
????..A..H.???????178??2014-10-14?15:46??Assets\Joystick\example\JoystickTest.cs.me
????I.A....?????38708??2014-10-15?12:06??Assets\Joystick\example\test_Joystick.unity
????..A..H.????????90??2014-10-11?11:19??Assets\Joystick\example\test_Joystick.unity.me
????..A..H.???????107??2014-10-14?15:46??Assets\Joystick\example.me
?????文件???????4200??2014-10-11?11:51??Assets\Joystick\Joystick?Atlas.mat
????..A..H.????????95??2014-10-11?11:51??Assets\Joystick\Joystick?Atlas.mat.me
?????文件?????144396??2014-10-11?11:51??Assets\Joystick\Joystick?Atlas.png
????..A..H.???????953??2014-10-11?11:51??Assets\Joystick\Joystick?Atlas.png.me
?????文件???????7768??2014-10-11?12:01??Assets\Joystick\Joystick?Atlas.prefab
????..A..H.????????95??2014-10-11?11:51??Assets\Joystick\Joystick?Atlas.prefab.me
?????文件???????9021??2014-10-15?12:05??Assets\Joystick\Joystick.cs
????..A..H.???????178??2014-10-11?11:46??Assets\Joystick\Joystick.cs.me
?????文件??????48095??2013-10-09?01:02??Assets\Joystick\RadialJoy_Area.png
????..A..H.???????955??2014-10-11?11:51??Assets\Joystick\RadialJoy_Area.png.me
?????文件??????27727??2013-10-09?01:01??Assets\Joystick\RadialJoy_Touch.png
????..A..H.???????955??2014-10-11?11:51??Assets\Joystick\RadialJoy_Touch.png.me
????..A..H.???????107??2014-10-11?11:46??Assets\Joystick.me
?????文件?????392712??2011-08-15?07:17??Assets\MonoPosixHelper.dll
????..A..H.????????90??2014-10-13?11:06??Assets\MonoPosixHelper.dll.me
?????文件?????522240??2014-09-28?14:39??Assets\NGUI\Editor\FreeType.dll
????..A..H.????????90??2014-10-11?11:04??Assets\NGUI\Editor\FreeType.dll.me
?????文件????1089968??2014-09-28?14:39??Assets\NGUI\Editor\FreeType.dylib
............此處省略1148個文件信息
評論
共有 條評論