[免费]触控UITouch的UE虚幻引擎插件

大家好!

我是: Aimo_皑墨

我来介绍一下这个插件!
描述: 插件一般用于触控设备的使用如(安卓手机,平板)等触控设备

GitHub 下载地址: https://github.com/AimoTvT/UITouch/archive/refs/heads/5.0.zip

虚幻商城: 后续可能上架

教程视频地址: 未完成

使用方法: 演示项目: 第三人称项目模版

手动安装插件
  • 1.选择好自己的版本
  • 2.点击 DownloadZip 下载(和网络地区可能影响下载速度)
    在这里插入图片描述

找到引擎文件夹里引擎\Engine\Plugins…路径下创建 Widgets 文件夹

在这里插入图片描述

下载的解压包内的 UITouch 文件解压/复制到 引擎\Engine\Plugins\Widgets 目录下

在这里插入图片描述

然后启动任意版本项目,找到在菜单栏->编辑->插件 1.搜索 UITouch 2.点击勾选(如果提示实验/测试点击 Yes 或是) 3.点击立即重启引擎

在这里插入图片描述

插件测试

电脑上测试选择,点击高级

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是一个使用 Objective-C 编写的手势解锁密码的示例代码: 首先,在你的项目中创建一个名为 "GestureLockView" 的 UIView 子类。这个类将用于绘制手势解锁的视图。 GestureLockView.h: ```objective-c #import <UIKit/UIKit.h> @protocol GestureLockViewDelegate <NSObject> - (void)gestureLockView:(UIView *)lockView didFinishWithPath:(NSString *)path; @end @interface GestureLockView : UIView @property (nonatomic, weak) id<GestureLockViewDelegate> delegate; @end ``` GestureLockView.m: ```objective-c #import "GestureLockView.h" @interface GestureLockView() @property (nonatomic, strong) NSMutableArray *selectedButtons; @end @implementation GestureLockView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor clearColor]; self.selectedButtons = [NSMutableArray array]; } return self; } - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); for (int i = 0; i < 9; i++) { CGFloat x = (i % 3) * 100 + 25; CGFloat y = (i / 3) * 100 + 25; CGRect frame = CGRectMake(x, y, 50, 50); UIButton *button = [[UIButton alloc] initWithFrame:frame]; button.tag = i + 1; button.layer.cornerRadius = 25.0; button.layer.borderWidth = 1.0; button.layer.borderColor = [UIColor blackColor].CGColor; [button setBackgroundImage:[self imageWithColor:[UIColor blueColor]] forState:UIControlStateSelected]; [button setBackgroundImage:[self imageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:button]; } if (self.selectedButtons.count > 0) { UIBezierPath *path = [UIBezierPath bezierPath]; for (int i = 0; i < self.selectedButtons.count; i++) { UIButton *button = self.selectedButtons[i]; CGPoint point = button.center; if (i == 0) { [path moveToPoint:point]; } else { [path addLineToPoint:point]; } } [path addLineToPoint:self.currentPoint]; [[UIColor blueColor] set]; path.lineWidth = 5.0; CGContextAddPath(context, path.CGPath); CGContextStrokePath(context); } } - (void)buttonTapped:(UIButton *)button { button.selected = YES; [self.selectedButtons addObject:button]; [self setNeedsDisplay]; } - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self handleTouches:touches]; } - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self handleTouches:touches]; } - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { NSMutableString *path = [NSMutableString string]; for (UIButton *button in self.selectedButtons) { [path appendFormat:@"%ld", button.tag]; } [self.delegate gestureLockView:self didFinishWithPath:path]; [self reset]; } - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { [self reset]; } - (void)handleTouches:(NSSet<UITouch *> *)touches { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; for (UIButton *button in self.subviews) { if (CGRectContainsPoint(button.frame, point)) { if (![self.selectedButtons containsObject:button]) { button.selected = YES; [self.selectedButtons addObject:button]; } break; } } self.currentPoint = point; [self setNeedsDisplay]; } - (void)reset { for (UIButton *button in self.selectedButtons) { button.selected = NO; } [self.selectedButtons removeAllObjects]; [self setNeedsDisplay]; } - (UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } @end ``` 在你的视图控制器中,你可以添加一个 GestureLockView 实例,并设置它的 delegate。当手势解锁完成时,GestureLockView 将调用代理方法 gestureLockView:didFinishWithPath:,你可以在这个方法中处理解锁的逻辑。 ViewController.h: ```objective-c #import <UIKit/UIKit.h> #import "GestureLockView.h" @interface ViewController : UIViewController <GestureLockViewDelegate> @end ``` ViewController.m: ```objective-c #import "ViewController.h" @interface ViewController () @property (nonatomic, strong) GestureLockView *lockView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.lockView = [[GestureLockView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)]; self.lockView.center = self.view.center; self.lockView.delegate = self; [self.view addSubview:self.lockView]; } - (void)gestureLockView:(UIView *)lockView didFinishWithPath:(NSString *)path { NSLog(@"Path: %@", path); if ([path isEqualToString:@"123"]) { NSLog(@"Unlock success!"); } else { NSLog(@"Unlock failed!"); } } @end ``` 这里的解锁密码是 "123"。你可以根据需要修改这个密码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值