资源简介
配套的博文: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个文件信息
相关资源
- Unity3D登录界面工程
- unity3d反编译工具
-
UnityWebPla
yerFull - Unity纪念碑谷.rar
- Unity3d实现扭动挤压浏览效果
- unity案例入门坦克大战源码
- Unity3D游戏开发.pdf 宣雨松著完整高清
- Unity3D版水果忍者
- unity3d爆炸特效包
- unity3d_见缝插针源码及报告.zip
- Unity3d车库场景模型
- unity3d 警察动画模型
- unity3D 新手引导遮罩,支持圆形和矩形
- unity3d枪支武器包FPS第一人称射击游戏
- unity3d制作贪吃蛇
- unity3D暴力街区射击大战游戏源码
- Unity3D 实战视频教程 保卫萝卜 2D 游戏
- unity3d调用中央气象局城市天气数据,
- Unity 3D Paint in 3D (1.7.3)
- 2014年最新最好的Unity3d圣典之中文脚本
- Molecular identification polymorphism and asso
- Unity3D搓牌效果支持4个方向
- Unity3D课程设计 模拟火焰效果
- 贝塞尔曲线的unity3d实现
- [资源插件]Unity3D_UGUI HUD Text v1.4.1.zip
- ShaderlabVSCode 1.1.6.unitypackage
- Camera Path Animator unity3d 插件
- Unity录屏模块封装清晰的可调AVPro Mo
- FBX格式人物模型,资源齐全,带动画
- Unity3D 3D炸弹超人Demo
评论
共有 条评论