当前位置:网站首页>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
边栏推荐
- JS regular expression basic knowledge learning
- Get the position of the nth occurrence of the string
- Générateur d'identification distribué basé sur redis
- 程序设计大作业:教务管理系统(C语言)
- JS function promotion and declaration promotion of VaR variable
- NRF24L01 troubleshooting
- Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
- It has been solved by personal practice: MySQL row size too large (> 8126) Changing some columns to TEXT or BLOB or using ROW_ FORMAT
- idea问题记录
- Fairygui joystick
猜你喜欢
[Red Treasure Book Notes simplified version] Chapter 12 BOM
JS regular expression basic knowledge learning
First use of dosbox
FairyGUI循环列表
[Clickhouse kernel principle graphic explanation] about the collaborative work of partitioning, indexing, marking and compressed data
Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)
Force buckle 1189 Maximum number of "balloons"
Derivation of logistic regression theory
Office prompts that your license is not genuine pop-up box solution
Pytorch: tensor operation (I) contiguous
随机推荐
Agile development helps me
MySQL takes up too much memory solution
Affichage du changement de valeur du Buff de gain de l'interface graphique de défaillance
Redis cache update strategy, cache penetration, avalanche, breakdown problems
FairyGUI简单背包的制作
Mysql database index
Mysqldump error1066 error solution
Teach you to release a DeNO module hand in hand
JS regular expression basic knowledge learning
Fairygui joystick
Liste des boucles de l'interface graphique de défaillance
Esp8266 connect onenet (old mqtt mode)
Common DOS commands
Solution to the problem of automatic login in Yanshan University Campus Network
(一)R语言入门指南——数据分析的第一步
idea问题记录
FairyGUI簡單背包的制作
It has been solved by personal practice: MySQL row size too large (> 8126) Changing some columns to TEXT or BLOB or using ROW_ FORMAT
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
FairyGUI循环列表