找回密码
 立即注册
查看: 3646|回复: 74

[脚本] VirtualJoystickRegion 虚拟摇杆插件

[复制链接]
发表于 2013-1-25 02:05 | 显示全部楼层 |阅读模式
资源信息 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".



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 3鲜花 +1 +2 收起 理由
yugo215 + 1
graywolfx21 + 1 很给力!
rightear + 1 赞一个!

查看全部评分

发表于 2013-1-25 10:54 | 显示全部楼层
哇 好厉害噢{:5_397:}
发表于 2013-1-27 17:29 | 显示全部楼层
是啊,好厉害
发表于 2013-7-26 18:36 | 显示全部楼层
谢谢分享了{:5_404:}
发表于 2013-7-29 10:07 | 显示全部楼层

也不能一竿子打死呀!{:soso__11174995096617402082_3:}
发表于 2017-2-21 17:08 | 显示全部楼层
真心顶
发表于 2017-2-21 17:15 | 显示全部楼层
说的非常好
发表于 2017-2-21 17:05 | 显示全部楼层
很好哦
发表于 2017-2-21 16:53 | 显示全部楼层
不错不错
发表于 2017-2-21 17:03 | 显示全部楼层
LZ真是人才
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-12-23 17:12 , Processed in 1.327055 second(s), 35 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表