Unity Image组件无法阻挡手势的解决办法
问题:Iamge组件勾选了Raycast Target,却接收了手势,触发了视角旋转。
手势插件使用的是DigitalRubyShared的FingersScript,
找到FingersScript中的ComponentTypesToDenyPassThrough字段
private readonly HashSet<System.Type> componentTypesToDenyPassThrough = new HashSet<System.Type>();
添加如下配置
private void SetupDefaultPassThroughComponents(){componentTypesToDenyPassThrough.Add(typeof(Scrollbar));componentTypesToDenyPassThrough.Add(typeof(Button));componentTypesToDenyPassThrough.Add(typeof(Dropdown));componentTypesToDenyPassThrough.Add(typeof(Toggle));componentTypesToDenyPassThrough.Add(typeof(Slider));componentTypesToDenyPassThrough.Add(typeof(InputField));//添加ImageComponentTypesToDenyPassThrough.Add(typeof(Image));}
这样就可以禁止Image组件接收手势。