[Unity3D] Unity3D game development makes my NGUI messy, unity3dngui

Source: Internet
Author: User

[Unity3D] Unity3D game development makes my NGUI messy, unity3dngui

Certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If you like my blog, please remember my name: Qin Yuanpei. My blog address is blog.csdn.net/qinyuanpei.

Reprinted please indicate the source, Author: Qin Yuanpei, the source of this article: http://blog.csdn.net/qinyuanpei/article/details/40947551

Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Dear friends, I'm Qin Yuanpei. Welcome to follow my blog. My blog address is blog.csdn.net/qinyuanpei.

Last week, the five bloggers ended the last course of this semester and were the only one at the same time. This meant that I had no exam in my career. During the exam that day, a person sat quietly in his seat until the bell rang. I began to constantly ask myself, has the past four years been wasted? In my impression, my college life may be no different from others. The only difference is that I stayed in a favorite major for four years and stood firm against reality, while striving for the dream. I don't know if I have another four years, will I still choose this? Because four years later, I may be the ignorant and persistent teenager four years ago, or I may become a self who I don't know at all. Growth is really a cruel thing. When I was a child, happiness was a simple thing. When I grew up, simplicity was a happy thing. That afternoon, I went to the library alone to return the borrowed books. I told the library teacher that I may not borrow any books in the future. The teacher asked me if I was about to graduate? I said that I just finished my last test today. At that moment, I suddenly felt sad. I really graduated. Thank you for your support from the library. Goodbye!

Now, let's officially start today's content. This may be the last blog that the blogger wrote during his college career. However, in the future, I will continue to write my blog, because it is not only a witness to the past, but also a part of the life of bloggers. Over the past few days, bloggers have been busy studying NGUI, but they have been abused by NGUI. Why? Because the bloggers feel that there are too many NGUI items and many things need to be studied. If we do not study the tool classes provided by NGUI, A simple function may require us to spend a lot of energy to implement it. But when we spend a lot of energy studying these tools, it is found that we have been drowned in the sea of code. One of the experiences of the bloggers who have studied NGUI over the past few days is that most of the failures are not code failures, but some NGUI parameter settings are faulty, which makes the bloggers feel very depressed. Well, the content of NGUI recently is a bit confusing. Let's just break it down in this article. I hope it will help you learn NGUI!

I. UIGrid

UIGrid is a table-like component provided by NGUI for us. With this component, we can quickly implement a grid layout. Let's first take a look at this component:


This component can define the following parameters here:

Arrangement -- display direction of a table

CellWidth -- table unit width

CellHeigh -- table unit height

MaxPerLine -- display pixels per line

Sorting -- Sorting method

Animate Smoothly-Use smooth animation for excessive Effect

Keep Within Panel -- Keep displayed in a Panel

After setting the preceding parameters, you only need to mount the elements that you want to display in UIGrid to the Transform node where UIGrid is located and use the Clip function of UIPanel to implement grid layout of the elements, the item bar effect shown in. So what is the Clip function of UIPanel? Next we will introduce UIPanel, a more important component in NGUI.



Ii. UIPanel

UIPanel is a core component of the NGUI that is responsible for the actual rendering of the Set graphics. Why? Because you do not need to manually add UIPanel, once you create a control, it will be automatically added. If you want to split your UI rendering into different Draw calls, you can manually create your own UIPanel. What the blogger wants to talk about here is that NGUI developers are very popular in the group, and the NGUI version is updated quickly. It is said that the latest version has already been updated to 3.8. The version used by the blogger here is 3.0. The blogger compares the NGUI version used in the relevant online tutorials and feels like a mess, therefore, we often have to figure out the changes caused by version updates. Therefore, if you want to learn programming well, you 'd better learn English well so that you will not be so confused. I recently looked at an NGUI example and found that the version of the tutorial is different from that of the blogger. As a result, it has been abused by NGUI for several days .......


Note the following:

Clipping-cropping function. You can use this option to set the center and size of the cropping area, in pixels. If cropping is not set, cropping is performed based on the screen size by default. In other words

It determines the display range.

DrawCall -- tell you how many Draw calls this Panel will consume. The lower the value, the higher the efficiency.

DebugInfo -- select the type of debugging information to display. 


Iii. UIScrollView

UIScrollView is the most boring component of the blogger. As its name suggests, this component is a component that implements a rolling view. Let's take a look at the important attributes of this component:


Content Origin -- the starting position of the scrolling Content
Movement -- move direction
Drag Effect -- display Effect when the content is dragged
Scroll Wheel Factor -- percentage of the Scroll time when you Scroll with the mouse
Momentum Amount-the force generated during fast sliding
Restrict Within Panel -- constraint in Panel
Cancel Drag if Fits -- if a component adapts to the Panel size, Cancel the Drag of the component in the panel.
Smooth Drag Start -- Smooth Drag
IOS Drag Emulation-simulate the sliding effect on Apple
Scroll Bars-when dragging, you can add a Scroll Bars to control or display the progress.

To implement a rolling view, you only need to add the ScrollView component to UIPanel and Package A UIGrid. This seems very simple, but you cannot find this component in NGUI3.0 used by the blogger, because it will be replaced with the UIDraggablePanel and UIDrag Panel Contents components, the UIDraggablePanel is mounted to the node where the UIGrid is located. The UIDrag Panel Contents is mounted to the project element in the list. It takes three days for the blogger to find that the node is mounted incorrectly, for three days, learning NGUI is messy.

Iv. TextList

TextList is a component used to implement the chat interface in NGUI. Without knowing that there is such a component, the blogger has been trying to use ScrollView for chatting. Then, the blogger finds that this is simply a dead pace, this point will be mentioned in the following content. Let's take a look at the TextList component:


Style -- the Style of the TextList component, Chat and Text

MaxWidth -- maximum text width

MaxHeight -- maximum text height

SupportScrollWhell -- whether to allow mouse scrolling

When using this component, you only need to mount it to a node with a Label. Then you only need to use the Add method of this component to Add the content. It is a simple chat interface created by the blogger:




5. NGUI dynamic generation

Finally, let's talk about the problem of NGUI dynamic generation. In actual application scenarios, the data we face is dynamically changing. Therefore, we need to dynamically generate interfaces based on the data volume, for example, a variable data item in the list. We know that you only need to call the Instantiate method to generate an object in Unity. Unfortunately, this method is especially embarrassing in NGUI. For example, in the previous UIGrid component, we only need to put an object under its node to implement grid-based or hierarchical layout, in this case, there is a problem of dynamic generation. The dynamically generated object exists independently of other objects. Although we can set the parent control by setting the parent in the code, we don't know why, in doing so, the blogger cannot mount the generated objects to the UIGrid node. So it's depressing. Let's talk about NGUITools. This tool class provides the addChild method. However, this method relies entirely on the user to manually create a specific object, because it is only creating a subnode, what is specific on this node? You need to manually create it, which is undoubtedly a huge workload. Alas, Every time NGUI is used, there is a sense of helplessness. We look forward to continuing to improve UGUI on the official website. It is really depressing ....... Well, today's content is like this. I will go to the internship tomorrow. It is estimated that there is no time to study NGUI. Let's share with you the implementation of an NGUI equipment item bar interface! Download from here (of course not written by me, haha). The blogger thinks the effect is quite good.


Well, today's content is like this. It's just plain, just like my college. Goodbye!


Daily proverbs: what others say to you and what you do never determine who you are. What you say to others and what you do can determine who you are.



 

Certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If you like my blog, please remember my name: Qin Yuanpei. My blog address is blog.csdn.net/qinyuanpei.

Reprinted please indicate the source, Author: Qin Yuanpei, the source of this article: http://blog.csdn.net/qinyuanpei/article/details/40947551

Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Related Article

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.