当前位置:网站首页>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
边栏推荐
- [golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
- idea中导包方法
- Lock wait timeout exceeded try restarting transaction
- Unity scene jump and exit
- NRF24L01故障排查
- 编译原理:源程序的预处理及词法分析程序的设计与实现(含代码)
- Problèmes avec MySQL time, fuseau horaire, remplissage automatique 0
- Walk into WPF's drawing Bing Dwen Dwen
- (5) Introduction to R language bioinformatics -- ORF and sequence analysis
- Database course design: college educational administration management system (including code)
猜你喜欢
Fabrication d'un sac à dos simple fairygui
Unity3d makes the registration login interface and realizes the scene jump
NRF24L01 troubleshooting
Single chip Bluetooth wireless burning
(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
Redis based distributed ID generator
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
(1) Introduction Guide to R language - the first step of data analysis
随机推荐
Halcon knowledge: gray_ Tophat transform and bottom cap transform
Gateway 根据服务名路由失败,报错 Service Unavailable, status=503
Gateway fails to route according to the service name, and reports an error service unavailable, status=503
The dolphin scheduler remotely executes shell scripts through the expect command
Database table splitting strategy
It has been solved by personal practice: MySQL row size too large (> 8126) Changing some columns to TEXT or BLOB or using ROW_ FORMAT
MySQL时间、时区、自动填充0的问题
[Red Treasure Book Notes simplified version] Chapter 12 BOM
Derivation of logistic regression theory
Symbolic representation of functions in deep learning papers
Remember an experience of ECS being blown up by passwords - closing a small black house, changing passwords, and changing ports
dosbox第一次使用
Programming homework: educational administration management system (C language)
[offer78] merge multiple ordered linked lists
2021.11.10 compilation examination
idea中好用的快捷键
Talking about the startup of Oracle Database
InnoDB dirty page refresh mechanism checkpoint in MySQL
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
Unity3D,阿里云服务器,平台配置