当前位置:网站首页>Fairygui character status Popup
Fairygui character status Popup
2022-07-06 12:42:00 【SQ Liu】
FairyGUI Character status popup
One 、 New packages and components




Two 、 Import material
Click here to download the material
3、 ... and 、 Making the main interface
The main interface is a simple avatar button
1、 The new button


2、 Double click in Button Components , Set a zoom for it , Let it zoom when it is pressed , Then drag the sound material in , It works better .


3、 Drag the button into Main Components

4、 Making pop-up windows
(1) First of all, there should be a container assembly with pop-up windows 

(2) Set window background (408×436), take PlayerWindow The size is also set to 408×436.
5、 Make a window frame
(1) New component Windowframe


(2) to Windowframe Add background
You can make the background directly in the framework , So you can delete the following background picture .


(3) New close button



(4) Make frame drag area
The window frame also needs a drag and drop area , That is, when players click on this area , The whole window will move according to the player's mouse .

Rename the drawing to dragArea, This is the official name !!!
Rename the close button , Convenient for later operation .
(5) Add background image , Make it look less monotonous

The window frame is finished !
6、 go back to PlayerWindow, Drag into the window frame

7、 Set graphic placeholder
The player is a 3D object , So we should put 3D The object shines on a UI On , Then take this UI Displayed on our window . Then we need to use Texture, Load the content illuminated by the camera . So there needs to be a placeholder , So we drag a graph here .

8、 The new button
After the characters are loaded , It also needs to have a rotation and other dynamics , So you need to add buttons to make the characters twist .



Four 、Unity Preparatory work
1、 First, import. player.unitypackage Resource Pack

2、 take npc Drag into the scene
We don't want the characters to show , That is, we don't want the characters to have any connection with the game scene interface . So set his position far away , We just want him to make a rendered picture dynamically , This model is not needed .


3、 Create a new camera to render people

Choose Camera Focus 
Because only one layer of the game object is rendered , So treat him as UI Layer to render , So you need to add a label .


4、 establish Render Texture
Rename it to PlayerRT


5、 Create a shader
(1) Rename it to PlayerMat
(2) Assign the material to Material
(3) Set its Shader
Later, you only need to load PlayerMat and PlayerRT You can render ! Come here , All the preparations are almost done , Then just put in FairyGUI Make a package of resources in .
5、 ... and 、 Packaging releases


*****FairyGUI Strange phenomenon of release failure *****
At this time, you will be prompted that publishing failed , As shown in the figure above . What's the reason ? This problem has been perplexed for a long time , How did I solve it ? I created a new project again , When importing qtm01d.swf When it comes to resources , Found the problem . Turned out to be qtm01d.swf In the way . So we can take two approaches : One 、 Directly remove the click sound effect ; Two 、 Find another click sound resource by yourself , No material given , Toxic , ha-ha . I am lazy , Delete it directly .

Republish again , Problem solved .

6、 ... and 、Unity It shows that

UI Panel Rename it to PlayerView
7、 ... and 、 Coding control
1、 Create two new scripts
The first is the main script that controls the display PlayerView;
The second is the pop-up script PlayerWindow.
2、 Edit script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class PlayerView : MonoBehaviour
{
private GComponent mainUI;
private PlayerWindow playerWindow;
public GameObject player;
void Start()
{
mainUI = GetComponent<UIPanel>().ui;
playerWindow = new PlayerWindow(player);
mainUI.GetChild("n0").onClick.Add(() => {
playerWindow.Show(); });
}
// Update is called once per frame
void Update()
{
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class PlayerWindow : Window
{
private GameObject player;
public PlayerWindow(GameObject player)
{
this.player = player;
}
protected override void OnInit()
{
this.contentPane = UIPackage.CreateObject("PlayerView", "PlayerWindow").asCom;
GGraph holder = contentPane.GetChild("n2").asGraph;
RenderTexture renderTexture = Resources.Load<RenderTexture>("FGUI/PlayerView/PlayerRT");
Material mat = Resources.Load<Material>("FGUI/PlayerView/PlayerMat");
Image img = new Image();
img.texture = new NTexture(renderTexture);
img.material = mat;
holder.SetNativeObject(img);
}
}

3、 Running effect

But found , Click on the × There is no response , Explain that there are still some problems .
go back to FairyGUI, Return to the window frame PlayerWindow in , Find out ButtonClose Displayed at the top , Because of our UI The display of has strict requirements on this depth . So we put this × The button of is rendered at the bottom .
4、 Re release , There is no problem after running

5、 Rotate the character left and right
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
public class PlayerWindow : Window
{
private GameObject player;
public PlayerWindow(GameObject player)
{
this.player = player;
}
protected override void OnInit()
{
this.contentPane = UIPackage.CreateObject("PlayerView", "PlayerWindow").asCom;
GGraph holder = contentPane.GetChild("n2").asGraph;
RenderTexture renderTexture = Resources.Load<RenderTexture>("FGUI/PlayerView/PlayerRT");
Material mat = Resources.Load<Material>("FGUI/PlayerView/PlayerMat");
Image img = new Image();
img.texture = new NTexture(renderTexture);
img.material = mat;
holder.SetNativeObject(img);
this.contentPane.GetChild("n3").onClick.Add(() => {
RotateLeft(); });
this.contentPane.GetChild("n4").onClick.Add(() => {
RotateRight(); });
}
private void RotateLeft()
{
player.transform.Rotate(Vector3.up * 30, Space.World);
}
private void RotateRight()
{
player.transform.Rotate(Vector3.up * (-30), Space.World);
}
}

8、 ... and 、 Final effect

边栏推荐
- The dolphin scheduler remotely executes shell scripts through the expect command
- Remember an experience of ECS being blown up by passwords - closing a small black house, changing passwords, and changing ports
- Theoretical derivation of support vector machine
- Derivation of logistic regression theory
- (the first set of course design) sub task 1-5 317 (100 points) (dijkstra: heavy edge self loop)
- [Offer18]删除链表的节点
- Office prompts that your license is not genuine pop-up box solution
- Unity3d makes the registration login interface and realizes the scene jump
- By v$rman_ backup_ job_ Oracle "bug" caused by details
- MySQL time, time zone, auto fill 0
猜你喜欢
![[Nodejs] 20. Koa2 onion ring model ----- code demonstration](/img/a8/a4390238685903b63bb036206f8dcb.jpg)
[Nodejs] 20. Koa2 onion ring model ----- code demonstration

Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect

Walk into WPF's drawing Bing Dwen Dwen

NRF24L01故障排查

Expected value (EV)

History object

Naive Bayesian theory derivation

Derivation of logistic regression theory

JS變量類型以及常用類型轉換

Unity3D基础入门之粒子系统(属性介绍+火焰粒子系统案例制作)
随机推荐
[899] ordered queue
FairyGUI簡單背包的制作
Vscode basic configuration
ORA-02030: can only select from fixed tables/views
History object
[Leetcode15]三数之和
Unity3d, Alibaba cloud server, platform configuration
记一次云服务器被密码爆破的经历——关小黑屋、改密码、改端口
Gravure sans fil Bluetooth sur micro - ordinateur à puce unique
js 变量作用域和函数的学习笔记
Gateway 根据服务名路由失败,报错 Service Unavailable, status=503
Basic operations of databases and tables ----- view data tables
1041 be unique (20 points (s)) (hash: find the first number that occurs once)
ES6 grammar summary -- Part 2 (advanced part es6~es11)
First use of dosbox
[Red Treasure Book Notes simplified version] Chapter 12 BOM
JS regular expression basic knowledge learning
Game 280 weekly
(一)R语言入门指南——数据分析的第一步
2022.2.12 resumption