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

相关推荐
没事写写笔记16 小时前
Unity HDRP14.0.12 Volume 配置参数
unity
红黑色的圣西罗18 小时前
手游手动异形屏适配方案,类“明日方舟”
unity
muddjsv1 天前
从用户需求到产品体验:UI/UX 设计核心方法论与实战指南
ui
一起养小猫1 天前
Axure day2 基础教程完整指南
ui·axure·photoshop
syker1 天前
3D游戏引擎Bluely Engine 开发手册
开发语言·3d·游戏引擎
AI_零食1 天前
红蓝之辨:基于 Flutter 的动静脉血动力学可视化系统开发
flutter·ui·华为·harmonyos·鸿蒙
灵感菇_1 天前
深入解析 Android事件分发机制
android·ui
Longyugxq2 天前
Untiy的Webgl端网页端视频播放,又不想直接mp4格式等格式的。
unity·音视频·webgl
avi91112 天前
Unity毛玻璃渲染模糊渲染Shader数学入门
unity·aigc·图形学·shader·hlsl
尤老师FPGA2 天前
使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第四十五讲)
android·java·ui