资源简介
配套的博文: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调色板
- Graph Maker1.3
- Unity3D期末
- SilverLining Skies 3D Clouds v1.9.unitypackage
- Unity3D 角色控制器CharacterController
- NavMesh 2D.unitypackage
- unity3d串口数据显示.docx
- Dynamic Bone V1.2.2
- NGUI常用3500中文字体
- Unity3d常用中文字体
- 鱼游动逻辑算法
- Unity 3D小游戏
- Unity3d传送门模型
- Unity3d UGUI
- 虚拟摇杆图像素材.unitypackage
- unity3d 美食游戏模板
- Unity刮刮乐效果、绘制透明工程
- unity3d答题系统
- unity3d 一个简单的足球demo
- SimplePath 1.11(最新完整版)
- leapmotion拼图
- unity3d rain 下雨 效果 特效 package
- unity3d分屏效果
- 帽子接球-Unity3D-源码及详细文档
- Water+2D+Kit+v1.1
- unity传送门特效粒子
- Unity3D 旋转相机视角 镜头缩放 拖动相
- Graph Maker.zip
- 基于Unity3D多人斗地主毕设论文
- 水面效果插件TasharenWater.zip
评论
共有 条评论