当前位置:网站首页>FairyGUI增益BUFF数值改变的显示
FairyGUI增益BUFF数值改变的显示
2022-07-06 09:18:00 【SQ刘】
FairyGUI增益BUFF数值改变的显示
一、FGUI中的操作
1、导入资源

2、新建两个位图字体和一个动画
(1)addValue位图字体



(2)attackValue位图字体



(3)Fire动画



3、新建一个字体和背景

紧接着可以在右边添加一个序列帧动画,当战斗力增加的时候,让火焰闪现。如下图所示:
4、添加动效
(1)添加动效之前,先添加组,这样对后续的一些处理会比较方便。
全选,按住Ctrl+G,打组,并选择高级组

(2)添加动效


还可添加一些小细节,就是火焰也需要添加特效。我们希望当玩家的数值改变的时候,也就是战斗力增大的时候,让火焰显现出来,表示变强了。
(1)首先对火焰的轴心重新设置一下,再将它的不透明度改为0
(2)再次进入动效编辑,自己随便尝试做一些特效,无具体要求
(3)做一些小小的改动
5、制作按钮
通过点击按钮来增加数值的值。
(1)导入素材

(2)新建组件,用来控制按钮显示,也就是主场景(主面板)

(3)新建按钮

(4)将按钮拖入到Component1组件中
6、打包发布



二、Unity中的操作
1、显示按钮


2、编写脚本

注意:需要引入DOTween.dll库,首先需要在Unity的资源商店里搜索“dotween”,进行下载后导入,方可在C#脚本中引入using DG.Tweening;的命名空间。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using DG.Tweening;
public class ZengYiBUFF : MonoBehaviour
{
private GComponent mainUI; //主UI
private GComponent addValueCom; //增加值的组件
private float startValue; //结束值
private float endValue; //开始值
void Start()
{
mainUI = GetComponent<UIPanel>().ui; //获取主UI
addValueCom = UIPackage.CreateObject("Package1", "AddValue").asCom;
//.asCom把它转成GComponent类型
addValueCom.GetTransition("t0").SetHook("AddValue", AddAttackValue); //设置FGUI中所添加标签对应关键帧的事件
mainUI.GetChild("n0").onClick.Add(() => {
PlayUI(addValueCom); }); //给按钮注册一下监听事件
//设置一下它的标签状态
}
// Update is called once per frame
void Update()
{
}
private void PlayUI(GComponent targetCom)
{
mainUI.GetChild("n0").visible = false;
GRoot.inst.AddChild(targetCom);
Transition t = targetCom.GetTransition("t0");//设置动效关联
startValue = 10000;
int add = Random.Range(1000, 3000);
endValue = startValue + add;
addValueCom.GetChild("n2").text = startValue.ToString();
addValueCom.GetChild("n4").text = add.ToString();
t.Play(() =>
{
mainUI.GetChild("n0").visible = true;
GRoot.inst.RemoveChild(targetCom);
}
);
}
/// <summary>
///该方法是将当前战斗力从10000增加到12000,
///需要引入using DG.Tweening命名空间(Unity资源商店中下载)
/// </summary>
private void AddAttackValue()
{
DOTween.To(() => startValue, x => {
addValueCom.GetChild("n2").text = Mathf.Floor(x).ToString(); }, endValue, 0.3f).SetEase(Ease.Linear).SetUpdate(true);
}
}
3、运行效果

边栏推荐
- Redis based distributed ID generator
- Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
- Who says that PT online schema change does not lock the table, or deadlock
- Gravure sans fil Bluetooth sur micro - ordinateur à puce unique
- 2022.2.12 resumption
- ES6 grammar summary -- Part 2 (advanced part es6~es11)
- Working principle of genius telephone watch Z3
- Arduino uno R3 register writing method (1) -- pin level state change
- Theoretical derivation of support vector machine
- Unity3d camera, the keyboard controls the front and rear left and right up and down movement, and the mouse controls the rotation, zoom in and out
猜你喜欢

Symbolic representation of functions in deep learning papers

Whistle+switchyomega configure web proxy
![[Red Treasure Book Notes simplified version] Chapter 12 BOM](/img/ff/0ad410b5b556c0e16a4076a2a0577b.jpg)
[Red Treasure Book Notes simplified version] Chapter 12 BOM

ESP8266连接onenet(旧版MQTT方式)

MySQL takes up too much memory solution

2021.11.10 compilation examination

FairyGUI摇杆

Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)

Remember an experience of ECS being blown up by passwords - closing a small black house, changing passwords, and changing ports

NRF24L01故障排查
随机推荐
Who says that PT online schema change does not lock the table, or deadlock
ORA-02030: can only select from fixed tables/views
Unity场景跳转及退出
Flink late data processing (3)
[offer18] delete the node of the linked list
Redis based distributed locks and ultra detailed improvement ideas
MySQL time, time zone, auto fill 0
JS数组常用方法的分类、理解和运用
JS 函数提升和var变量的声明提升
MySQL占用内存过大解决方案
ES6 grammar summary -- Part I (basic)
Particle system for introduction to unity3d Foundation (attribute introduction + case production of flame particle system)
idea中导包方法
[leetcode622]设计循环队列
MySQL takes up too much memory solution
Vulnhub target: hacknos_ PLAYER V1.1
Symbolic representation of functions in deep learning papers
About using @controller in gateway
JS function promotion and declaration promotion of VaR variable
Générateur d'identification distribué basé sur redis