unity UI特效遮罩

cs 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/**
 UI特效遮罩
1.需要将ScrollRect 的遮罩Mask 换为 2D Mask
 2.将特效的Render里面的   Masking  设置为
 */
public class UIParticleMaskControll : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    public void SetParticeMasking(GameObject go)
    {
        var pers = go.GetComponentsInChildren<ParticleSystemRenderer>();
        foreach (ParticleSystemRenderer item in pers)
        {
            item.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
        }
    }

    /// <summary>
    /// 设置遮罩范围
    /// </summary>
    public void SetMaskRect(float width,float height)
    {

        var xScale = width / 4 * 100;//像素转换  4指的是sprite的width
        var yScale = height / 4 * 100;//像素转换  4指的是sprite的height
        transform.localScale = new Vector3(xScale, yScale, 1);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

ParticleSystemRenderer-maskInteraction - Unity 脚本 API

相关推荐
qq_452396231 小时前
第二十篇:《UI自动化测试的未来:AI驱动的智能测试与低代码平台》
人工智能·低代码·ui
小白学鸿蒙3 小时前
Unity 3D 2023解压安装,配置安卓运行环境后打包安卓应用(踩坑无数之差点放弃)
android·unity·游戏引擎
__water12 小时前
【关于unity打包Android失败问题】
android·unity
木风未来12 小时前
四川 UI 与数字视觉设计机构排名:政企定制服务实力榜单
ui·小程序·可视化大屏
mascon14 小时前
Unity 编辑器扩展
unity·编辑器·游戏引擎
ZC跨境爬虫14 小时前
跟着 MDN 学 HTML day_25:(数字音频概念完全解析)
前端·ui·html·edge浏览器·媒体
LNN202215 小时前
半导体设备 UI 开发工程师:完整工作执行手册
开发语言·python·ui
程序员正茂1 天前
Unity3d使用MQTT异步连接服务端
mqtt·unity·异步
mxwin1 天前
在unity shader中,通过pass产生阴影,通过主pass的光照 接收阴影!那么问题来了,是先产生阴影吗?还是先接收阴影,执行顺序是啥呢
数码相机·unity·游戏引擎·shader