当前位置:网站首页>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的分布式ID生成器
- [leetcode19]删除链表中倒数第n个结点
- CUDA C programming authoritative guide Grossman Chapter 4 global memory
- SSD technical features
- ORA-02030: can only select from fixed tables/views
- JS變量類型以及常用類型轉換
- [offer78]合并多个有序链表
- Générateur d'identification distribué basé sur redis
- Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
- 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
猜你喜欢
Whistle+switchyomega configure web proxy
js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
First use of dosbox
Latex learning
[Clickhouse kernel principle graphic explanation] about the collaborative work of partitioning, indexing, marking and compressed data
2021.11.10 compilation examination
Vscode basic configuration
ES6 grammar summary -- Part 2 (advanced part es6~es11)
Unity场景跳转及退出
MySQL占用内存过大解决方案
随机推荐
MySQL占用内存过大解决方案
Basic operations of databases and tables ----- view data tables
MySQL时间、时区、自动填充0的问题
1041 be unique (20 points (s)) (hash: find the first number that occurs once)
Database course design: college educational administration management system (including code)
[leetcode622] design circular queue
Important methods of array and string
Unity3d, Alibaba cloud server, platform configuration
Special palindromes of daily practice of Blue Bridge Cup
Arduino gets the length of the array
PT OSC deadlock analysis
FairyGUI复选框与进度条的组合使用
Servlet
MySQL replacement field part content
[Offer18]删除链表的节点
基於Redis的分布式ID生成器
Acwing-116 pilot brother
(三)R语言的生物信息学入门——Function, data.frame, 简单DNA读取与分析
ORA-02030: can only select from fixed tables/views
InnoDB dirty page refresh mechanism checkpoint in MySQL