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

相关推荐
TomEval16 小时前
【Web UI 自动化】05 - KDT 模式原理与实现
前端·ui·自动化
简单Janeee20 小时前
[Vue 3 从零到上线]-第九篇:更美更强——引入 UI 库与网络请求 (Axios)
网络·vue.js·ui
中国软件测试质量协会1 天前
奇林测试平台(kylinTOP)UI自动化测试能力深度解析
ui
greasyfork2 天前
Mac Sketch v2026.3 矢量图设计工具
macos·ui·sketch
zhchyun20082 天前
# 【Unity UI 进阶】仿 Element UI 打造企业级 Unity UI 组件库(06)
ui·unity·游戏引擎
中国软件测试质量协会2 天前
国产UI自动化测试工具的“技术代际“演进与自主可控之路
测试工具·ui·自动化
深念Y2 天前
NativeScript 移动端开发踩坑记录
前端·ui·vue·安卓·移动端·native·原生
晴天162 天前
从生成式 UI 到 Agent 驱动界面-Day32
ui
淼澄研学2 天前
Photoshop集成Firefly Image 3模型解析与API实操指南
ui·photoshop
Behaviour2 天前
Unity游戏HybridCLR 热更新接入实战
游戏·unity·游戏引擎