UE4 摇杆JoyStick-Touch Interface Setup

举报
Dummy 发表于 2021/11/19 02:17:38 2021/11/19
【摘要】 1.创建 2、属性   USTRUCT()struct FTouchInputControl{ GENERATED_USTRUCT_BODY() //自由活动图片 // basically mirroring SVirtualJoystick::FControlInfo but as an edita...

1.创建

2、属性

 


  
  1. USTRUCT()
  2. struct FTouchInputControl
  3. {
  4. GENERATED_USTRUCT_BODY()
  5. //自由活动图片
  6. // basically mirroring SVirtualJoystick::FControlInfo but as an editable class
  7. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, this is the Thumb"))
  8. UTexture2D* Image1;
  9. //底图
  10. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, this is the Background"))
  11. UTexture2D* Image2;
  12. //中心位置
  13. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The center point of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
  14. FVector2D Center;
  15. //可见范围
  16. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The size of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
  17. FVector2D VisualSize;
  18. //自由活动图片的尺寸
  19. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, the size of the thumb (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
  20. FVector2D ThumbSize;
  21. //触摸响应范围
  22. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The interactive size of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
  23. FVector2D InteractionSize;
  24. //输入力度/强度
  25. UPROPERTY(EditAnywhere, Category = "Control", meta = (ToolTip = "The scale for control input"))
  26. FVector2D InputScale;
  27. //按键:触发与ProjectSetting中对应按键相同的输入事件
  28. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The main input to send from this control (for sticks, this is the horizontal axis)"))
  29. FKey MainInputKey;
  30. //按键:触发与ProjectSetting中对应ALT+按键相同的输入事件
  31. UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The alternate input to send from this control (for sticks, this is the vertical axis)"))
  32. FKey AltInputKey;
  33. FTouchInputControl()
  34. : Image1(nullptr)
  35. , Image2(nullptr)
  36. , Center(ForceInitToZero)
  37. , VisualSize(ForceInitToZero)
  38. , ThumbSize(ForceInitToZero)
  39. , InteractionSize(ForceInitToZero)
  40. , InputScale(1.f, 1.f)
  41. {
  42. }
  43. };
  44. UCLASS(Blueprintable, BlueprintType)
  45. class ENGINE_API UTouchInterface : public UObject
  46. {
  47. GENERATED_UCLASS_BODY()
  48. //控制的元素列表
  49. UPROPERTY(EditAnywhere, Category="TouchInterface")
  50. TArray<FTouchInputControl> Controls;
  51. //激活状态的透明度
  52. UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Opacity (0.0 - 1.0) of all controls while any control is active"))
  53. float ActiveOpacity;
  54. //非激活状态的透明度
  55. UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Opacity (0.0 - 1.0) of all controls while no controls are active"))
  56. float InactiveOpacity;
  57. //进去非激活状态的时间,一旦没有输入就开始计时
  58. UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after user interaction will all controls fade out to Inactive Opacity"))
  59. float TimeUntilDeactive;
  60. //复位的时间
  61. UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after going inactive will controls reset/recenter themselves (0.0 will disable this feature)"))
  62. float TimeUntilReset;
  63. //延迟激活
  64. UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after joystick enabled for touch (0.0 will disable this feature)"))
  65. float ActivationDelay;
  66. //不准复位
  67. UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Whether to prevent joystick re-center"))
  68. bool bPreventRecenter;
  69. //
  70. UPROPERTY(EditAnywhere, Category = "TouchInterface", meta = (ToolTip = "Delay at startup before virtual joystick is drawn"))
  71. float StartupDelay;
  72. //与JoyStick耦合的接口
  73. /** Make this the active set of touch controls */
  74. void Activate(TSharedPtr<SVirtualJoystick> VirtualJoystick);
  75. };

  

文章来源: blog.csdn.net,作者:呦呦鹿鸣.,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/zhang1461376499/article/details/118970208

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。