|
资源信息 Asset Information
资源名称: | VirtualJoystickRegion 虚拟摇杆插件 (发帖教程) |
版本: | 无 (版本) |
资源等级: | 1 |
资源格式: | .unitypackage (链接失效请点击帖子右下方举报通知管理员) |
资源大小: | 5KB (默认:MB) |
下载地址: | 无 (购买积分) |
It solves many problems you face when trying to code a joystick, so if you are learning about it you may want to take a look. Also it is somewhat resolution independant so you dont have to worry about adjusting its size neither position.
This sample works within a "region" of the screen where the joystick adjusts its position to the player's finger if he taps inside that region.
It also work inside a circular boundary instead of a square and it can detect double taps too.
It does not use OnGUI(), its GUItextures and it does not need collision detection to work; very simple to use:
1) Create an empty Game Object.
2) Add the VirtualJoystickRegion.cs script to that object.
3) Use square textures for the "Joytick 2D" and "Background 2D" fields.
4) Adjust the "Active Color" and "Inactive Color" values as you wish, and its ready to go.
Note:
The Joystick outputs two global variables for you to work with, VJRvector and VJRnormals.
To get real screen space values, you query "VirtualJoystickRegion.VJRvector".
To get normalized joystick values, ideal numbers to work with, you query "VirtualJoystickRegion.VJRnormals".
If you dont like big names you may want to rename the "VirtualJoystickRegion" class to just "VJR".
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
评分
-
查看全部评分
|