unity 粒子组件_爆发粒子效果按钮组件

本文介绍了一个基于Vue的粒子效果按钮组件,灵感来源于Codrops文章。该组件提供安装、使用方法,并详细说明了如何通过道具和插槽自定义按钮内容和动画效果。
摘要由CSDN通过智能技术生成

unity 粒子组件

VUE粒子效果按钮 (vue-particle-effect-buttons)

This library is a Vue portal of an awesome Codrops Article by Luis Manuel (original source).

该库是Luis Manuel的一篇很棒的Codrops文章的Vue门户(原始资料)。

安装 (Install)

npm install --save vue-particle-effect-buttons

用法 (Usage)

<template>
    <ParticleBtn
      :visible.sync="btnOps.visible"
      :animating.sync="btnOps.animating"
      :options="btnOps"
      cls="btn-cls"
    >
    hello eveybody!
    </ParticleBtn>
    <h2>animating:{{btnOps.animating}}</h2>
    <h2>visible:{{btnOps.visible}}</h2>
    <button @click="btnOps.visible=!btnOps.visible">toggle</button>
  </div>
</template>

<script>
import ParticleEffectButton from "vue-particle-effect-buttons"

export default {
  data() {
    return {
      btnOps: {
        type: "triangle",
        easing: "easeOutQuart",
        size: 6,
        particlesAmountCoefficient: 4,
        oscillationCoefficient: 2,
        color: function () {
          return Math.random() < 0.5 ? "#000000" : "#ffffff";
        },
        onComplete: () => {
          console.log("complete");
        },
        onBegin: () => {
          console.log("begin");
        },
        visible: true,
        animating: false
      },
    }
  },
  components: {
    ParticleEffectButton
  }
};
</script>

Note that children can be anything, The children should represent the button's contents.

请注意, children可以是任何东西, children应代表按钮的内容。

You change the visible boolean prop to kick-off an animation, typically as a result of a click on the button's contents. If visible changes to false, the button will perform a disintegrating animation. If visible changes to true, it will reverse and reintegrate the original content.

您可以更改visible布尔属性来启动动画,这通常是由于单击按钮内容导致的。 如果visible更改为false ,则该按钮将执行分解动画。 如果visible更改为true ,它将反转并重新整合原始内容。

道具 (Props)

PropertyTypeDefaultDescription
visiblebooleantrueWhether button should be hidden or visible. Changing this prop starts an animation. support .sync modifier
animatingbooleanfalseGet the current status of animating or end of the animation. support .sync modifier
clsstring/Object/ArrarnoopThe class to change the default button styles
durationnumber1000Animation duration in milliseconds.
easingstring'easeInOutCubic'Animation easing.
typestringcircle'circle' or 'rectangle' or 'triangle'
stylestringfill'fill' or 'stroke'
directionstring'left''left' or 'right' or 'top' or 'bottom'
canvasPaddingnumber150Amount of extra padding to add to the canvas since the animation will overflow the content's bounds
sizenumberfuncrandom(4)
speednumberfuncrandom(4)
particlesAmountCoefficientnumber3Increases or decreases the relative number of particles
oscillationCoefficientnumber20Increases or decreases the relative curvature of particles
onBeginfuncnoopCallback to be notified once an animation starts.
onCompletefuncnoopCallback to be notified once an animation completes.
属性 类型 默认 描述
visible 布尔值 真正 按钮是隐藏还是可见。 更改此道具将启动动画。 支持.sync修饰符
animating 布尔值 获取动画或动画的当前状态。 支持.sync修饰符
cls 字符串/对象/ Arrar 没有 更改默认按钮样式的类
duration 1000 动画持续时间(以毫秒为单位)。
easing 'easeInOutCubic' 动画轻松。
type “圆”或“矩形”或“三角形”
style “填充”或“中风”
direction '剩下' “左”或“右”或“上”或“下”
canvasPadding 150 要添加到画布上的额外填充量,因为动画将溢出内容的边界
size 功能 随机的(4)
speed 功能 随机的(4)
particlesAmountCoefficient 3 增加或减少粒子的相对数量
oscillationCoefficient 20 增加或减少粒子的相对曲率
onBegin 功能 没有 动画开始后将通知回调。
onComplete 功能 没有 动画完成后将通知回调。

I tried to keep the properties exactly the same as in the original codrops version.

我试图使属性与原始codrops版本中的属性完全相同。

插槽 (Slots)

PropertyTypeDefaultDescription
defaultslotthe string of 'content'the content of the button
属性 类型 默认 描述
default 插槽 内容字符串 按钮的内容

翻译自: https://vuejsexamples.com/a-bursting-particles-effects-buttons-component/

unity 粒子组件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Unity中实现爆炸粒子效果可以通过使用粒子系统来实现。以下是一个简单的步骤: 1. 创建一个新的空物体,命名为"Explosion"或者其他你喜欢的名字。 2. 在Inspector面板中,点击"Add Component"按钮并选择"Particle System"来添加一个新的粒子系统组件。 3. 调整粒子系统的属性来获得期望的爆炸效果。你可以通过修改以下一些常用属性来实现: - Duration(持续时间):设置为粒子发射的总时间长度。 - Start Lifetime(起始寿命):设置粒子的寿命。 - Start Speed(起始速度):设置粒子发射时的速度。 - Start Size(起始大小):设置粒子发射时的大小。 - Emission(发射):设置粒子发射的速率和数量。 - Shape(形状):设置粒子发射的形状,可以为球体、圆锥体等等。 - Color Over Lifetime(随寿命变化的颜色):设置粒子在寿命过程中的颜色变化。 4. 添加纹理和材质以增加粒子效果的视觉效果。你可以在Renderer组件中选择一个合适的纹理和材质来渲染粒子。 5. 在代码中,你可以通过调用`Play()`函数来触发爆炸效果。例如,可以在爆炸发生的位置实例化一个Explosion对象,并在适当的时机调用`GetComponent<ParticleSystem>().Play()`来开始播放粒子效果。 这只是一个简单的示例,你可以根据自己的需求进一步调整和定制粒子系统的属性和效果。希望对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值