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

相关推荐
玖玥拾4 小时前
Unity Shader 基础与图形学(一)
unity·图形渲染·图形学·shader
WiChP12 小时前
【V0.1B16】从零开始的2D游戏引擎开发之路
开发语言·算法·游戏引擎
百里香酚兰13 小时前
【Unity学习笔记】如何把粉色Prefab还原
笔记·学习·unity
xcLeigh15 小时前
Unity基础:使用Transform控制物体旋转——Rotate与LookAt详解
unity·教程·transform·rotate·lookat
xy345316 小时前
Axure 9.0 中继器创建与设置步骤
前端·ui·html·axure·原型·产品设计
平行云17 小时前
3D应用推流太贵太慢?ImmerShare Lite:利用本地算力实现极简一键分享
unity·ue5·实时云渲染·云桌面·像素流·云游戏·串流
淡海水18 小时前
11-04-Unity-Span-foreach-LINQ的分配与热路径边界
unity·c#·linq·foreach·span
狂人开飞机1 天前
23、实战平台跳跃游戏
游戏·游戏引擎·godot
大蓝头1 天前
安装包UI美化之路-借助AI快速使用nsNiuniuSkin制作安装包
ui·安装包·nsis·安装包美化·nsniuniuskin
兰亭妙微UI设计公司1 天前
兰亭妙微APP界面设计公司分享: iPhone Duo 登场|3 大核心要点,拆解折叠屏 UI 适配设计思路
ui·交互