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

相关推荐
松树戈17 小时前
godot项目【宝石捕手】04~添加音效、记分
游戏引擎·godot
love530love20 小时前
Photoshop 2026 AI 功能排障复盘:Camera Raw 卡死 / Neural Filters 灰 / 皮肤平滑下载失败 全定位
人工智能·ui·photoshop
LONGZETECH20 小时前
无人机实训高成本痛点解法:虚拟仿真实现 70% 耗材损耗下降
大数据·算法·unity·架构·无人机
农村小镇哥21 小时前
怎么把HTM格式转化成WORD
ui·c#·word
五仁烧饼1 天前
Unity Addressables 静默资源策略
游戏·unity·addressables
天天进步20152 天前
UI-TARS 源码解析 #22:二次开发实战:用 UI-TARS 做一个简单的 Windows 自动操作 Agent
windows·ui
ue星空2 天前
【Godot】更换编辑器外观主题
编辑器·游戏引擎·godot
fanfan_hongyun2 天前
unity 与cad 坐标系映射
unity·游戏引擎
神码编程2 天前
【Unity】 HTFramework框架(七十)MultiChoiceDropdown可多选的下拉菜单
unity·游戏引擎·ugui·dropdown·下拉菜单
ue星空2 天前
Godot 2D像素游戏移动抖动、模糊问题解决方案
游戏·游戏引擎·godot