当前位置:网站首页>Mixed use of fairygui button dynamics
Mixed use of fairygui button dynamics
2022-07-06 12:46:00 【SQ Liu】
FairyGUI Mixed use of button dynamic effect
One 、FGUI In the design
( One ) Import material resources




There was originally a music material , Can't lead in , You can find a similar background music online and import it by yourself .
( Two ) Detailed design
1、 Create a new button and fine tune it

The purpose of fine-tuning is to give buttons some special effects , For example, there is a zoom effect when clicking , And there is a sound effect .
2、 Button drag in Component1 And create a new text
Associate the text with the button , Prevent some problems in the subsequent operation .

3、 Make special effects
(1) New component 

(2) Special effects production 


4、 Package import Unity



Two 、Unity Code implementation in
1、 Manual display button




2、 Script code control

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class ButtonEffects : MonoBehaviour
{
private GComponent mainUI;
private GComponent bossCom;
void Start()
{
mainUI = GetComponent<UIPanel>().ui;
bossCom = UIPackage.CreateObject("Package1", "Boss").asCom;
mainUI.GetChild("n0").onClick.Add(() => {
PlayUI(bossCom); }); //n0 yes FGUI Medium Button1.Add() Inside is λ expression
}
// 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"); //t0 yes Boss The dynamic effect of
t.Play(()=>
{
mainUI.GetChild("n0").visible = true;
GRoot.inst.RemoveChild(targetCom);
});
}
}

Running effect :
There is a fly in the ointment : After clicking , The font “Boss” It can't disappear . It needs to be used FairyGUI The group inside .
3、 Create a group to republish



4、 Make some changes to the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class ButtonEffects : MonoBehaviour
{
private GComponent mainUI;
private GComponent bossCom;
private GGroup group;
void Start()
{
mainUI = GetComponent<UIPanel>().ui;
group = mainUI.GetChild("n2").asGroup;
bossCom = UIPackage.CreateObject("Package1", "Boss").asCom;
mainUI.GetChild("n0").onClick.Add(() => {
PlayUI(bossCom); });
//n0 yes FGUI Medium Button1.Add() Inside is λ expression
}
// Update is called once per frame
void Update()
{
}
private void PlayUI(GComponent targetCom)
{
//mainUI.GetChild("n0").visible = false;
group.visible = false;
GRoot.inst.AddChild(targetCom);
Transition t = targetCom.GetTransition("t0"); //t0 yes Boss The dynamic effect of
t.Play(()=>
{
//mainUI.GetChild("n0").visible = true;
group.visible = true;
GRoot.inst.RemoveChild(targetCom);
});
}
}
3、 ... and 、 The final operation effect

边栏推荐
- Design and implementation of general interface open platform - (39) simple and crude implementation of API services
- How to improve the deletion speed of sequential class containers?
- [leetcode622]设计循环队列
- dosbox第一次使用
- Guided package method in idea
- Minio文件下载问题——inputstream:closed
- Programming homework: educational administration management system (C language)
- 燕山大学校园网自动登录问题解决方案
- Vulnhub target: hacknos_ PLAYER V1.1
- Prove the time complexity of heap sorting
猜你喜欢

Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights

(五)R语言入门生物信息学——ORF和序列分析

Classification, understanding and application of common methods of JS array

SVN更新后不出现红色感叹号

(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图

Unity3D基础入门之粒子系统(属性介绍+火焰粒子系统案例制作)

Conditional probability

First use of dosbox

Mysql database index

FairyGUI循环列表
随机推荐
Minio文件下载问题——inputstream:closed
The master of double non planning left the real estate company and became a programmer with an annual salary of 25W. There are too many life choices at the age of 25
(课设第一套)1-5 317号子任务 (100 分)(Dijkstra:重边自环)
First use of dosbox
如何给Arduino项目添加音乐播放功能
燕山大学校园网自动登录问题解决方案
Office prompts that your license is not genuine pop-up box solution
[899]有序队列
[offer29] sorted circular linked list
[Nodejs] 20. Koa2 onion ring model ----- code demonstration
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
idea中导包方法
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
(5) Introduction to R language bioinformatics -- ORF and sequence analysis
[Leetcode15]三数之和
Fabrication d'un sac à dos simple fairygui
Derivation of logistic regression theory
Mysqldump error1066 error solution
Meanings and differences of PV, UV, IP, VV, CV
[offer9]用两个栈实现队列