当前位置:网站首页>FairyGUI增益BUFF數值改變的顯示
FairyGUI增益BUFF數值改變的顯示
2022-07-06 12:42: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、運行效果

边栏推荐
- js 变量作用域和函数的学习笔记
- [leetcode19]删除链表中倒数第n个结点
- 燕山大学校园网自动登录问题解决方案
- 1041 be unique (20 points (s)) (hash: find the first number that occurs once)
- (5) Introduction to R language bioinformatics -- ORF and sequence analysis
- MySQL performance tuning - dirty page refresh
- Talking about the startup of Oracle Database
- Game 280 weekly
- By v$rman_ backup_ job_ Oracle "bug" caused by details
- ES6 grammar summary -- Part I (basic)
猜你喜欢

Whistle+switchyomega configure web proxy

Conditional probability
![[Red Treasure Book Notes simplified version] Chapter 12 BOM](/img/ff/0ad410b5b556c0e16a4076a2a0577b.jpg)
[Red Treasure Book Notes simplified version] Chapter 12 BOM

2021.11.10汇编考试

JS function promotion and declaration promotion of VaR variable

Basic operations of databases and tables ----- classification of data
![[Nodejs] 20. Koa2 onion ring model ----- code demonstration](/img/a8/a4390238685903b63bb036206f8dcb.jpg)
[Nodejs] 20. Koa2 onion ring model ----- code demonstration

dosbox第一次使用

(4) Data visualization of R language -- matrix chart, histogram, pie chart, scatter chart, linear regression and strip chart

CUDA C programming authoritative guide Grossman Chapter 4 global memory
随机推荐
Basic operations of databases and tables ----- modifying data tables
Teach you to release a DeNO module hand in hand
level16
如何给Arduino项目添加音乐播放功能
[Red Treasure Book Notes simplified version] Chapter 12 BOM
Talking about the startup of Oracle Database
FairyGUI简单背包的制作
Easy to use shortcut keys in idea
Esp8266 uses Arduino to connect Alibaba cloud Internet of things
NRF24L01 troubleshooting
(三)R语言的生物信息学入门——Function, data.frame, 简单DNA读取与分析
There is no red exclamation mark after SVN update
HCIP Day 12
JS regular expression basic knowledge learning
[offer9]用两个栈实现队列
Classification, understanding and application of common methods of JS array
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
Problèmes avec MySQL time, fuseau horaire, remplissage automatique 0
(一)R语言入门指南——数据分析的第一步
Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED