当前位置:网站首页>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
边栏推荐
- Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
- (五)R语言入门生物信息学——ORF和序列分析
- Acwing-116 pilot brother
- (5) Introduction to R language bioinformatics -- ORF and sequence analysis
- 如何给Arduino项目添加音乐播放功能
- 單片機藍牙無線燒錄
- Whistle+switchyomega configure web proxy
- Unity3D制作注册登录界面,并实现场景跳转
- 燕山大学校园网自动登录问题解决方案
- JUC forkjoin and completable future
猜你喜欢
341. Flatten nested list iterator
FairyGUI簡單背包的制作
Unity3D,阿里云服务器,平台配置
Programming homework: educational administration management system (C language)
Single chip Bluetooth wireless burning
Database course design: college educational administration management system (including code)
Mysql database index
FairyGUI条子家族(滚动条,滑动条,进度条)
Pytorch: tensor operation (I) contiguous
MySQL takes up too much memory solution
随机推荐
Halcon knowledge: gray_ Tophat transform and bottom cap transform
Agile development helps me
数据库课程设计:高校教务管理系统(含代码)
Acwing-116 pilot brother
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
Single chip Bluetooth wireless burning
Page performance optimization of video scene
Unity scene jump and exit
FairyGUI增益BUFF数值改变的显示
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
There is no red exclamation mark after SVN update
Servlet
Who says that PT online schema change does not lock the table, or deadlock
Gateway fails to route according to the service name, and reports an error service unavailable, status=503
MySQL performance tuning - dirty page refresh
The service robots that have been hyped by capital and the Winter Olympics are not just a flash in the pan
Special palindromes of daily practice of Blue Bridge Cup
Walk into WPF's drawing Bing Dwen Dwen
Office prompts that your license is not genuine pop-up box solution
Database course design: college educational administration management system (including code)