当前位置:网站首页>Fabrication d'un sac à dos simple fairygui
Fabrication d'un sac à dos simple fairygui
2022-07-06 12:38:00 【Sq Liu】
FairyGUIFabrication de sacs à dos simples
Aperçu des effets:
Un.、Créer un nouveau projet

Renommer
2.、 Faire des fenêtres de sac à dos
1、 Composant conteneur du nouveau sac à dos (BagWindow)


2、 Nouveau composant de cadre de fenêtre (WindowFrame)

3、 Importer des ressources matérielles
4、InWindowFrameOpération centrale
(1) Glissez dans l'arrière - plan du sac à dos

Et van0Renommer enBG( C'est l'arrière - plan du sac à dos )
(2) Nouveau bouton d'arrêt (ButtonClose)


(3) Nouveau dessin comme occupation (dragArea——Zone de traînée)

5、InBagWindowOpération centrale
(1)Oui.WindowFrameGlisser dansBagWindow, Et définir la taille de ses composants

(2) Glisser dans la liste pour transporter des objets de jeu

(3) Faire une grille dans la liste ——Nouveau boutonItem

(4)ÉditionItem
Glisser dans la carte de fond 
Glisser dansTitle

Glisser dans le chargeur 
6、InMainOpération centrale
(1) Créer un bouton d'affichage d'image ItemView

(2)C'est exact.ItemView Faites quelques améliorations

(3) Nouveau bouton pop - up du sac à dos BagButton

(4)Double - clicBagButton Bouton pour l'éditer

7、RetourBagWindow,Assigner une valeur à


Renommer, Faites quelques petits changements .
Trois、 Package Export Publishing



Quatre、UnityAffichage en
1、NouveauUnityProjets

2、 Télécharger le FairyGUI
Lors de l'importation après téléchargement ,Il faut faire attention,- Oui.ExamplesEn bas.BagSupprimer. Parce qu'il n'a pas été supprimé lors de l'importation précédente , Ce qui a conduit à des phénomènes étranges .

3、UnityAffichage en

Cinq、Contrôle du Code
1、 Créer deux nouveaux scripts
L'un est un script de fenêtre de sac à dos BagWindow, L'un est le script principal Bag.

2、Modifier le script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class BagWindow : Window
{
public BagWindow()
{
}
protected override void OnInit()
{
this.contentPane = UIPackage.CreateObject("Bag", "BagWindow").asCom;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class Bag : MonoBehaviour
{
private GComponent mainUI;
private GButton playerView;
private BagWindow bagWindow;
void Start()
{
mainUI = GetComponent<UIPanel>().ui;
playerView = mainUI.GetChild("playerView").asButton;
playerView.onClick.Add(UseItem);
bagWindow = new BagWindow();
mainUI.GetChild("bagButton").onClick.Add(() => {
bagWindow.Show(); });
}
// Update is called once per frame
void Update()
{
}
private void UseItem()
{
}
}
3、Effets de fonctionnement

4、 Charger le contenu du sac à dos
(1)Changez.BagWindow Nom de la liste dans :itemList,EtItemViewÀ l'intérieur.title, Et republié


(2) Continuer à coder les fonctions de mise en oeuvre
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class BagWindow : Window
{
private GList list;
private GButton playerView;
public BagWindow(GButton targetButton)
{
playerView = targetButton;
}
protected override void OnInit()
{
this.contentPane = UIPackage.CreateObject("Bag", "BagWindow").asCom;
list = this.contentPane.GetChild("itemList").asList;
list.itemRenderer = RenderListItem;
list.numItems = 20;
for (int i = 0; i < list.numItems - 10; i++)
{
GButton button = list.GetChildAt(i).asButton;
button.onClick.Add(() => {
ClickItem(button); });
}
}
private void RenderListItem(int index, GObject obj)
{
GButton button = obj.asButton;
button.icon = UIPackage.GetItemURL("Bag", "i" + index);
button.title = index.ToString();
}
private void ClickItem(GButton button)
{
playerView.title = button.title;
playerView.icon = button.icon;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class Bag : MonoBehaviour
{
private GComponent mainUI;
private GButton playerView;
private BagWindow bagWindow;
void Start()
{
mainUI = GetComponent<UIPanel>().ui;
playerView = mainUI.GetChild("playerView").asButton;
playerView.onClick.Add(UseItem);
bagWindow = new BagWindow(playerView);
bagWindow.SetXY(121, 63); // Définir la position initiale de la fenêtre contextuelle du sac à dos
mainUI.GetChild("bagButton").onClick.Add(() => {
bagWindow.Show(); });
}
private void UseItem()
{
playerView.icon = null;
playerView.title = "Blanc";
}
}
Six、Résultats finaux


边栏推荐
- level16
- [golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
- Gateway fails to route according to the service name, and reports an error service unavailable, status=503
- [leetcode622] design circular queue
- SSD technical features
- (四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
- About using @controller in gateway
- JS function promotion and declaration promotion of VaR variable
- The dolphin scheduler remotely executes shell scripts through the expect command
- idea中好用的快捷键
猜你喜欢

單片機藍牙無線燒錄

Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)

MySQL占用内存过大解决方案

Latex learning

MySQL time, time zone, auto fill 0

Basic operations of databases and tables ----- view data tables

FairyGUI摇杆

FairyGUI简单背包的制作

程序设计大作业:教务管理系统(C语言)

ES6 grammar summary -- Part 2 (advanced part es6~es11)
随机推荐
FairyGUI人物状态弹窗
C programming exercise
History object
Redis based distributed locks and ultra detailed improvement ideas
[899]有序队列
Detailed explanation of truncate usage
Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
(5) Introduction to R language bioinformatics -- ORF and sequence analysis
[leetcode15] sum of three numbers
MySQL时间、时区、自动填充0的问题
What is the maximum length of MySQL varchar field
HCIP Day 12
JUC forkjoin and completable future
Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
Naive Bayesian theory derivation
idea问题记录
程序设计大作业:教务管理系统(C语言)
Types de variables JS et transformations de type communes
[leetcode19] delete the penultimate node in the linked list
Talking about the startup of Oracle Database