资源简介
本工程实例 为unity3D 对普通手柄支持的, 不需要外部映射这么麻烦, 轻轻松松就能实现对普通手柄的支持
代码片段和文件信息
using UnityEngine;
using System.Collections;
public class JoystickController : MonoBehaviour {
///
/// This is a joystick detect demo/project. Made by project Team Unity~ from the Entertainment Technology Center at Carnegie Mellon.
/// The purpose for this demo/project is to understand what is the mapping for you joystick.
///
private string currentButton;
private string currentAxis;
private float axisInput;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
getAxis();
getButton();
}
///
/// Get Axis data of the joysick
///
void getAxis()
{
if(Input.GetAxisRaw(“X axis“)> 0.3|| Input.GetAxisRaw(“X axis“) < -0.3)
{
currentAxis = “X axis“;
axisInput = Input.GetAxisRaw(“X axis“);
}
if(Input.GetAxisRaw(“Y axis“)> 0.3|| Input.GetAxisRaw(“Y axis“) < -0.3)
{
currentAxis = “Y axis“;
axisInput = Input.GetAxisRaw(“Y axis“);
}
if(Input.GetAxisRaw(“3rd axis“)> 0.3|| Input.GetAxisRaw(“3rd axis“) < -0.3)
{
currentAxis = “3rd axis“;
axisInput = Input.GetAxisRaw(“3rd axis“);
}
if(Input.GetAxisRaw(“4th axis“)> 0.3|| Input.GetAxisRaw(“4th axis“) < -0.3)
{
currentAxis = “4th axis“;
axisInput = Input.GetAxisRaw(“4th axis“);
}
if(Input.GetAxisRaw(“5th axis“)> 0.3|| Input.GetAxisRaw(“5th axis“) < -0.3)
{
currentAxis = “5th axis“;
axisInput = Input.GetAxisRaw(“5th axis“);
}
if(Input.GetAxisRaw(“6th axis“)> 0.3|| Input.GetAxisRaw(“6th axis“) < -0.3)
{
currentAxis = “6th axis“;
axisInput = Input.GetAxisRaw(“6th axis“);
}
if(Input.GetAxisRaw(“7th axis“)> 0.3|| Input.GetAxisRaw(“7th axis“) < -0.3)
{
currentAxis = “7th axis“;
axisInput = Input.GetAxisRaw(“7th axis“);
}
if(Input.GetAxisRaw(“8th axis“) > 0.3|| Input.GetAxisRaw(“8th axis“) < -0.3)
{
currentAxis = “8th axis“;
axisInput = Input.GetAxisRaw(“8th axis“);
}
}
///
/// get the button data of the joystick
///
void getButton()
{
if(Input.GetButton(“joystick button 0“))
currentButton = “joystick button 0“;
if(Input.GetButton(“joystick button 1“))
currentButton = “joystick button 1“;
if(Input.GetButton(“joystick button 2“))
currentButton = “joystick button 2“;
if(Input.GetButton(“joystick button 3“))
currentButton = “joystick button 3“;
if(Input.GetButton(“joystick button 4“))
currentButton = “joystick button 4“;
if(Input.GetButton(“joystick button 5“))
currentButton = “joystick button 5“;
if(Input.GetButton(“joystick button 6“))
currentButton = “joystick button 6“;
if(Input.GetButton(“joystick button 7“))
currentButton = “joystick button 7“;
if(Input.GetButton(“joystick button 8“))
currentButton = “joystick button 8“;
if(Input.GetButton(“joystick button 9“))
currentButton = “joystick button 9“;
if(Input.GetButton(“joystick button 10“))
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-05-05 17:49 Joysticks\
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Assets\
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Assets\scene\
文件 11600 2011-03-24 18:47 Joysticks\Joystick_TutorialDemo\Assets\scene\Joystick_TutorialDemo.unity
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Assets\sc
文件 4167 2011-04-08 13:56 Joysticks\Joystick_TutorialDemo\Assets\sc
文件 2764 2011-05-02 15:45 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo.csproj
文件 6817792 2011-03-02 05:44 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo.exe
文件 2314 2011-05-02 15:46 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo.pidb
文件 910 2011-05-02 15:45 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo.sln
文件 304 2011-05-02 15:46 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo.userprefs
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\
文件 7341 2011-05-02 15:45 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\mainData
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\
文件 5632 2011-05-02 15:45 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\Assembly-CSharp.dll
文件 113664 2011-03-01 08:58 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\Boo.Lang.dll
文件 292864 2011-03-01 08:58 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\Mono.Security.dll
文件 2495488 2011-03-01 08:58 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\mscorlib.dll
文件 1068544 2011-03-01 08:58 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\System.dll
文件 408576 2011-03-02 05:44 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\UnityEngine.dll
文件 131791 2011-03-02 05:44 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Managed\UnityEngine.dll.mdb
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\mono\
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\mono\1.0\
文件 58196 2011-03-02 05:44 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\mono\1.0\DefaultWsdlHelpGenerator.aspx
文件 17259 2011-03-02 05:44 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\mono\1.0\machine.config
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\mono\2.0\
目录 0 2011-05-05 17:49 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\mono\2.0\Browsers\
文件 1605 2011-03-02 05:44 Joysticks\Joystick_TutorialDemo\Joystick_TutorialDemo_Data\Mono\etc\mono\2.0\Browsers\Compat.browser
............此处省略84个文件信息
- 上一篇:Egret List嵌套
- 下一篇:全屏输入法
相关资源
- unity 3d实战核心技术详解电子书
- Unity3D特效 光圈特效 Effect 6 Type 资源包
- 2D Toolkit v2.5.8.6.unitypackage
- unity3d QuickRopes3.16 绳子创建插件
- Unity3D角色FBX模型带动作动画
- Unity3D创建简单漫游教程
- Unity3D汽车模型集合 Cars and Trucks Coll
- Unity3D开发的简单赛车游戏
- Unity3D上传图片以及解析二进制流
- UNITY3d人物模型+动作
- Unity3D官方赛车资源包
- Unity3D 之2d开发,飞机大战所有源代码
- Unity3D游戏开发流程与规范.ppt
- Unity3d适合移动端的景深DOF效果
- Unity3DPatch_5.6.x.zip
- unity3d游戏框架消息机制
- Pocket+RPG+Weapon+Trails+武器拖尾效果(
- Unity3D挥剑(剑痕特效)
- Unity3D 虚拟手DEMO
- unity3d武器拖尾特效
- 在Unity中整合LUA的DEMO
- NGUI版的虚拟摇杆
- Unity3d调色板
- Graph Maker1.3
- Unity3D期末
- SilverLining Skies 3D Clouds v1.9.unitypackage
- Unity3D 角色控制器CharacterController
- NavMesh 2D.unitypackage
- unity3d串口数据显示.docx
- Dynamic Bone V1.2.2
评论
共有 条评论