微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Unity Scroll Rect 在倒置蒙版下不起作用

如何解决Unity Scroll Rect 在倒置蒙版下不起作用

我试图在 this tutorial 的帮助下在我的主菜单中实现一种缩小效果

这带来了很多问题,因为其他 Unity 组件似乎不喜欢这个解决方案。但是大多数问题都可以通过一种或另一种方式解决,但是我在这个问题上遇到了严重的麻烦:我试图在蒙版外放置一个滚动矩形(因为它是倒置的)但是因为你不应该能够在遮罩外拖动项目我的项目在可见时不可拖动。

我尝试过使用普通图像而不是反转图像,只移除了蒙版,因此似乎没有任何面板或类似物阻挡光线投射。 我也试过删除滚动视图 - 视口蒙版,但仍然没有......

Heirarchy of gameobjects

My game view,the white circles are the contents of the scroll rect,and the fingerprint circle is the main-menu-mask that expands when you press play

这是反转蒙版图像的代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

public class CutoutMaskUI : Image
{
    public override Material materialForRendering
    {
        get
        {
            Material material = new Material(base.materialForRendering);
            material.SetInt("_StencilComp",(int)CompareFunction.NotEqual);
            return material;
        }
    }
}

(如果我提供的信息太少,请告诉我,我会尝试添加更多)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。