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

相关推荐
object not found10 小时前
从 Page Design 到 System Design:我对 UI/UX 的一次认知变化
ui·ux
wgslucky11 小时前
Godot GDScript初学者遇到的问题记录
游戏引擎·godot
xy345311 小时前
Axure9.0中继器遮罩实现方法
前端·ui·html·axure·原型·产品设计
晴天1613 小时前
Ant Design UI 库核心原理与应用
ui
点心的游戏开发世界13 小时前
GDScript 入门笔记(五):函数
笔记·游戏引擎·godot
谢斯16 小时前
[unity]如何在unity中添加newtonsoft-json
unity·json·游戏引擎
玫瑰互动GEO17 小时前
腾讯AnswerBit(GEO优化监测平台)技术拆解:UI自动化如何采集真实AI回答
大数据·人工智能·ui·ai·自动化·geo优化
天人合一peng17 小时前
Unity标记固定颜色及投影标记
unity
云雨巫山21 小时前
Unity 游戏开发性能优化全景手册
unity·智能手机·性能优化·游戏引擎
maybeyaluokenai21 小时前
unity build in渲染管线概述
unity·图形渲染