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

相关推荐
Behaviour4 小时前
Unity UI循环列表UIScrollViewContent实现
ui·unity·c#·游戏引擎
小小龙学IT11 小时前
Dear ImGui 开源即时模式 GUI 库深度解析
c++·ui·开源
xy345312 小时前
Axure9.0让条形图实现动态交互(鼠标悬停高亮 + 显示详情卡片)
ui·产品经理·原型·axure9.0
_ZHOURUI_H_15 小时前
Unity EasyECS:并不是所有字段都适合 SoA,Unity 项目中应该怎样拆数据
游戏·unity·性能优化·架构·游戏引擎
TO_ZRG17 小时前
Unity 编辑器之 SettingsProvider、Hierarchy、Project、SearchField
java·unity·编辑器
yj爆裂鼓手1 天前
spine绑定骨骼运动工具&spine纹理压缩自动设置工具
游戏·unity
mqiqe1 天前
AgentScope Java 2.0 协议集成全景解析:A2A、AG-UI、Agent Protocol 三大开放协议实战指南
java·开发语言·ui
qq_426003961 天前
【UI自动化测试】UI自动化报错解决方案
运维·ui·自动化
Oll Correct1 天前
Adobe illustrator 案例九:百宝箱图标绘制
笔记·ui·adobe·illustrator
惊鸿醉1 天前
Unity 实战:用讯飞 WebAPI 做一个“说普通话、播方言“的语音程序
unity·c#·游戏引擎·语音识别