Unity学习路程10
16.GetButton 和 GetKey
本教程演示如何在 Unity 项目中获取用于输入的按钮或键,以及这些轴的行为或如何通过 Unity Input Manager 进行修改。
KeyInput
using UnityEngine;
using System.Collections;
public class KeyInput : MonoBehaviour
{
public GUITexture graphic;
public Texture2D standard;
public Texture2D downgfx;
public Texture2D upgfx;
public Texture2D heldgfx;
void Start()
{
graphic.texture = standard;
}
void Update ()
{
bool down = Input.GetKeyDown(KeyCode.Space);
bool held = Input.GetKey(KeyCode.Space);
bool up = Input.GetKeyUp(KeyCode.Space);
if(down)
{
graphic.texture = downgfx;
}
else if(held)
{
graphic.texture = heldgfx;
}
else if(up)
{
graphic.texture = upgfx;
}
else
{
graphic.texture = standard;
}
guiText.text = " " + down + "\n " + held + "\n " + up;
}
}
...全文
相关推荐
Unity学习资料.7z
本资源是个人整理的Unity学习资料,包含C#学习思维导图和视频教程和Unity学习教程。我写了一篇Unity系统学习路线的文章,也可以来看一下https://blog.csdn.net/zhangay1998/article/details/118298538
unity学习资料
Unity shader学习资料
unity_ECS学习
unity_ECS学习
Learn Unity for Windows 10 Game Development 无水印pdf
Learn Unity for Windows 10 Game Development 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
unity学习包
unity学习的初级教程,算是带领着学习一下刚开始的界面之类的。介绍还是很详细的,虽然版本更新有些已经更改了,不过还是有用的。


