[Unity3d] Continuing exploration of Unity3d game development Ngui

Source: Internet
Author: User

Hello, I am Qin Yuanpei. You are welcome to follow my blog. My blog address is Blog.csdn.net/qinyuanpei.

Bo Master recently began to study Ngui, but to tell the truth, Bo Lord feel Ngui things seem to be scattered, because most of the information on the Internet is simply to explain how to use the Ngui, and not from the substantive principles to explain the meaning of Ngui, this and we learn. NET is just the same as dragging a control. and cannot grasp what is inside of things. Therefore, bloggers recommend you from the official samples to study Ngui. Bloggers these days are basically looking at Ngui Demonstration sample program, self-feeling content is more miscellaneous bar. In today's article, the blogger tells the following questions:

1, Ngui Anchor Point control

2. Mixed use of Unity3d scene and Ngui

3, Unity3d model map loss Problem resolution method


Here's what we'll start with today:

First, Ngui anchor point control

In the Ngui, the interface is divided into 9 regions according to the following diagram, which are the upper, lower, left, right, upper left, left, right, lower right and middle. It is called an anchor point in the Ngui.

What are the advantages of controlling the interface layout through an anchor point? The advantage is that we can manage controls in the same area in a way that simplifies our management.

Imagine how complicated it would be to assume that each control was controlled using absolute coordinates, through the Ngui provided by the anchor point function. We are able to use relative coordinates within each anchor point to determine the position of the control within that area. Okay, so here's an example of how to use the Ngui anchor function for this image.


First we use the interface tools provided by Ngui to create a 2D interface. We renamed the camera to 2DUICamera, then renamed the following default panel to 2DUiPanel and removed the default anchor node. Next, we create an empty game body under that node and use the rest method to set its position, rotation settings (0,0,0), which is important, even if you need to change its location later.

Then we add a uianchor to it by Ngui->attach->anchor to make it an anchor point. and renamed Bottom_anchor, which means we're going to lay out what we want to show at the bottom of the screen, so we need to set the side in the Uianchor script bound to the node object to bottom,


We set the coordinates of Anchor_bottom to (0,-240,0), and the values here are dependent on the project.

Next, we add an empty object below it. Renamed to Anchor_offset, can be seen from the name. This is an object that controls the offset of the control in the area, and we set its position to (0,40,0) so that it offsets 40 from the origin of the region. Next, we add a button under the node. Set the label value to bottom.

In a similar way. We set up anchor points for the remaining 8 regions, respectively. The method established is the same as above and is symmetrical. There's no more talking here. This example is meant to tell you when using Ngui. Anchor points should be used to properly manage the interface elements in the game. This allows us to better manage the interface. Finally, the effect is the picture that starts to show. There is no longer a show here.

second, Unity3d scene and Ngui mixed use

Unity3d game scenes are divided into 3D and three, we come to separate them and Ngui mixed use. First, for the 2D interface. We need to make a change to the default 2DUi structure, we need to put anchor and camera on the same level, that is, both belong to the sub-nodes of 2DUI.

Second, you want to set the camera depth of the 2D interface. The value is greater than the depth of field of the main camera in the scene, and the other parameters remain the default.

What we see is that bloggers use Ngui to show the number of coins and the running distance of the players in the "Unity3d]unity3d Game Development Game Project Commentary" This article:


Then for the 3D interface is very simple, because there is only one camera in the scene, so we can directly according to the usual method to do, but the Ngui unit seems to be different from unity units, in the setting position. For objects in the Ngui, there is usually a very large value to move to the target position, there is no clear internal reasons, such as Bo Master research clear will be added later in the article, just according to Xuanhusung's blog here does need a numerical conversion, but Bo Master did not study clearly. Here are the results of the mixed use of Ngui and Unity3d's scenes to find that both can be executed perfectly in the same scenario:



three, Unity3d model map loss Problem Solving method

Blogger is a research code, design software only Photoshop and CAD, so for the model and so on, basically do not. Bo master-Slave Download the 3DMAX model, the results are exported to FBX format after the model map is lost in Unity3d. The model surface material is the default gray material in Unity3d. Bloggers studied for a long time never found the reason. It was not until last night that the bloggers found a way to solve the problem, hoping to help them.

First of all. We open the 3DMax. Select our model-Paladin four Willow Dream Glass,


Next, we choose Render-and-view image files, which are located in the new Open dialog box in the map directory, typically in the textures directory with the same sibling of the model file. The map format is DDS, and this format is not supported in unity. Ok, next, we'll select the decal file individually:


Click View to open the map image. Click the first button to save the map.


Finally, we go back to the Unity3d. Create a textures directory under the file where the model resides, and copy the map file you just saved to that directory. After importing the model in unity, a materials directory is generated under the model catalog, where we can see the corresponding material of the model and select a material:


When we set the whole material to a map, in the scene we will see the familiar figure, but how to feel and the characters in the game is so big gap?




All right. Thank you for your interest in my blog. Today, at 12 o ' Night, I was able to finish it. Do not learn me, I was forced by the roommates have no way to this.


Daily motto: Your life will never fail you.

Those who turn the wrong way, those who go wrong. The tears that shed. Those drops of sweat, the scars left behind. All make you a unique self.

--Hsueh




Like my blog Please remember my name: Qin Yuanpei, my blog address is Blog.csdn.net/qinyuanpei
Reprint please indicate the source, this article Qin Yuanpei. The source of this article: http://blog.csdn.net/qinyuanpei/article/details/25654647


[Unity3d] Continuing exploration of Unity3d game development Ngui

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.