当前位置:网站首页>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
边栏推荐
- @Autowired 和 @Resource 的区别
- Liste des boucles de l'interface graphique de défaillance
- 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
- Teach you to release a DeNO module hand in hand
- 2021.11.10汇编考试
- Unity3d, Alibaba cloud server, platform configuration
- VLSM variable length subnet mask partition tips
- InnoDB dirty page refresh mechanism checkpoint in MySQL
- NRF24L01故障排查
- MySQL error warning: a long semaphore wait
猜你喜欢
The dolphin scheduler remotely executes shell scripts through the expect command
Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
FairyGUI循环列表
Unity3D制作注册登录界面,并实现场景跳转
地球围绕太阳转
C programming exercise
Lock wait timeout exceeded try restarting transaction
FairyGUI循環列錶
Idea problem record
Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)
随机推荐
ESP8266连接onenet(旧版MQTT方式)
Detailed explanation of truncate usage
JS regular expression basic knowledge learning
记一次云服务器被密码爆破的经历——关小黑屋、改密码、改端口
How to add music playback function to Arduino project
Pytorch: tensor operation (I) contiguous
[Red Treasure Book Notes simplified version] Chapter 12 BOM
Lock wait timeout exceeded try restarting transaction
Fabrication of fairygui simple Backpack
2022.2.12 resumption
FairyGUI按钮动效的混用
@The difference between Autowired and @resource
Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
2021.11.10汇编考试
idea问题记录
[Offer29] 排序的循环链表
Mysql database reports an error: row size too large (> 8126) Changing some columns to TEXT or BLOB or using ROW_ FORMAT=DY
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
[Leetcode15]三数之和
Mysqldump error1066 error solution