当前位置:网站首页>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、运行效果
边栏推荐
- CUDA C programming authoritative guide Grossman Chapter 4 global memory
- level16
- JS變量類型以及常用類型轉換
- ORA-02030: can only select from fixed tables/views
- Esp8266 connect onenet (old mqtt mode)
- 记一次云服务器被密码爆破的经历——关小黑屋、改密码、改端口
- [offer78]合并多个有序链表
- 1041 be unique (20 points (s)) (hash: find the first number that occurs once)
- Gravure sans fil Bluetooth sur micro - ordinateur à puce unique
- [Clickhouse kernel principle graphic explanation] about the collaborative work of partitioning, indexing, marking and compressed data
猜你喜欢
随机推荐
FairyGUI人物状态弹窗
Who says that PT online schema change does not lock the table, or deadlock
ES6 grammar summary -- Part I (basic)
The dolphin scheduler remotely executes shell scripts through the expect command
Arduino JSON data information parsing
Arduino gets the length of the array
Basic operations of databases and tables ----- creating data tables
(五)R语言入门生物信息学——ORF和序列分析
Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
MySQL replacement field part content
Unity3d makes the registration login interface and realizes the scene jump
[offer9]用两个栈实现队列
2021.11.10 compilation examination
Detailed explanation of truncate usage
(课设第一套)1-4 消息传递接口 (100 分)(模拟:线程)
1041 be unique (20 points (s)) (hash: find the first number that occurs once)
(课设第一套)1-5 317号子任务 (100 分)(Dijkstra:重边自环)
Derivation of logistic regression theory
idea问题记录
FairyGUI复选框与进度条的组合使用