assistive touch?easytouch怎么锁屏?Unity手游之路六游戏摇杆之Easy Touch 3教程

电脑杂谈  发布时间:2016-10-08 12:00:26  来源:网络整理

你是否正在寻找关于easy touch的内容?让我把最简洁的东西奉献给你:

之前已经介绍过Unity自带的摇杆Joystick,它用起来很简单。但是它也存在很多局限,不能全部满足普通mmo手游的一些需求,例如:要能方便地更好素材;能指定在某个区域显示,或者只有在该区域触摸时才出现等等。而这些功能,easy touch插件都已经帮你实现了。全部是可配置。大家可以从Asset Store上购买,或者使用free版。

(可随意分享,请注明原文出处)

  • 实例
  • 还是用上次例子来实现。控制角色的移动

  • 步骤
  • 1.import “easy touch 3”的资源包
    2.创建人物模型
    3.创建地形
    4.添加一个Joystick的实例 :Hedgehog Team->easy touch->Extensions->Add a new Joystick。这时我们可以看到它在左下角出来
    5.设置摇杆的相关的参数,详见下图

    assistive touch?easytouch怎么锁屏?Unity手游之路六游戏摇杆之Easy Touch 3教程



    6.新建一个脚本MoveController.cs 用来接收摇杆的事件,控制角色的移动。代码如下:
    using UnityEngine; using System.Collections; public class MoveController : MonoBehaviour { void OnEnable() { EasyJoystick.On_JoystickMove += OnJoystickMove; EasyJoystick.On_JoystickMoveEnd += OnJoystickMoveEnd; } //移动摇杆结束 void OnJoystickMoveEnd(MovingJoystick move) { //停止时,角色恢复idle if (move.joystickName == "MoveJoystick") { animation.CrossFade("idle"); } } //移动摇杆中 void OnJoystickMove(MovingJoystick move) { if (move.joystickName != "MoveJoystick") { return; } //获取摇杆中心偏移的坐标 float joyPositionX = move.joystickAxis.x; float joyPositionY = move.joystickAxis.y; if (joyPositionY != 0 || joyPositionX != 0) { //设置角色的朝向(朝向当前坐标+摇杆偏移量) transform.LookAt(new Vector3(transform.position.x + joyPositionX, transform.position.y, transform.position.z + joyPositionY)); //移动玩家的位置(按朝向位置移动) transform.Translate(Vector3.forward * Time.deltaTime * 5); //播放奔跑 animation.CrossFade("run"); } } }完成收工,具体的效果图

    assistive touch?easytouch怎么锁屏?Unity手游之路六游戏摇杆之Easy Touch 3教程



    最后我们来看看easy touch的参数

    assistive touch?easytouch怎么锁屏?Unity手游之路六游戏摇杆之Easy Touch 3教程

    assistive touch?easytouch怎么锁屏?Unity手游之路六游戏摇杆之Easy Touch 3教程


    assistive touch?easytouch怎么锁屏?Unity手游之路六游戏摇杆之Easy Touch 3教程


  • 总结
  • easy touch提供了虚拟摇杆的解决方案,基本能满足你的各种需求,。包括前面所说的,定制UI,隐藏,指定区域等。可以在你的项目中尝试使用

  • 源码

  • 以上就是关于easy touch的全部内容,相信你一定会非常满意。


    本文来自电脑杂谈,转载请注明本文网址:
    https://www.pc-fly.com/a/ruanjian/article-18330-1.html

      相关阅读
        发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

        • 卡马奇利
          卡马奇利

          索赔金额高

        • 孙雪
          孙雪

          从现在抓起一百年以后我看还是有希望的

        热点图片
        拼命载入中...