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

相关推荐
犹若故人归15 小时前
Android开发应用--高级UI界面设计
android·ui
一个学Java小白1 天前
TUI的王者——ncurses.md
linux·ui
归真仙人1 天前
【UE】UMG安卓相关问题
android·ue5·游戏引擎·ue4·虚幻·unreal engine
BuHuaX1 天前
Unity项目怎么接入抖音小游戏?
unity·c#·游戏引擎·wasm·游戏策划
Sator11 天前
unity Rayfire破碎插件的踩坑点
unity·游戏引擎
极客先躯1 天前
基于 EasyUI 和 jQuery 封装的企业级日期时间选择器组件库,采用标准的 jQuery 插件开发规范,实现了高度模块化和可复用的 UI 组件
ui·jquery·日期选择器·时间选择器·easyui
kk哥88991 天前
Android UI 优化指南:流畅度与体验双提升
android·ui
鱼蛋-Felix1 天前
C#浮点数在部分国家解析失效问题
开发语言·unity·c#
_风华ts1 天前
虚幻引擎碰撞相关的属性
游戏引擎·虚幻·collision
小雨下雨的雨1 天前
Flutter鸿蒙共赢——像素的解构:沃罗诺伊点描与权重平衡的艺术
flutter·ui·华为·harmonyos·鸿蒙系统