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

相关推荐
公爵爱学习21 小时前
无人机多点巡航
游戏引擎·无人机·cocos2d
公爵爱学习1 天前
关于无人机定点飞行的一些解释和Matlab程序绘制
游戏引擎·无人机·cocos2d
object not found1 天前
从 Page Design 到 System Design:我对 UI/UX 的一次认知变化
ui·ux
wgslucky1 天前
Godot GDScript初学者遇到的问题记录
游戏引擎·godot
xy34532 天前
Axure9.0中继器遮罩实现方法
前端·ui·html·axure·原型·产品设计
晴天162 天前
Ant Design UI 库核心原理与应用
ui
点心的游戏开发世界2 天前
GDScript 入门笔记(五):函数
笔记·游戏引擎·godot
谢斯2 天前
[unity]如何在unity中添加newtonsoft-json
unity·json·游戏引擎
玫瑰互动GEO2 天前
腾讯AnswerBit(GEO优化监测平台)技术拆解:UI自动化如何采集真实AI回答
大数据·人工智能·ui·ai·自动化·geo优化
天人合一peng2 天前
Unity标记固定颜色及投影标记
unity