Recently, there have been some bug problems in Ngui in Unity5.0.1, for example, you use Ngui development to drag a sprite
function, or use the dynamic font on some lable, and then compile it into an EXE executable that can run on a PC
File (remember that the Player settings the resolution in Resizealbe Window), and when it runs, you
You will find the problem, such as opening the window area of the 720*480 size, and then you drag the window boundary, or directly
To maximize the window magnification, you will find that the sprite in the UI root is still only dragged in the 720*480 size area,
And the dynamic font can be distorted by amplification,
(Here the picture shrinks, the effect of the dynamic font distortion may not be seen, the original font is clearer than here,
In addition, the dragged Sprite character picture has reached the border, in the lower right corner of the 720*480 position.
I tried, this problem also exists in 4.6.4, but this is not my personal problem!! Why do you say that? Because the problem is
Also exists in Ngui's EXAMPLE11 example!! Later I went to unity official re-4.5.5 version of the sudden miracle of discovery, Ngui this
The problem disappears, so I guess Unity's support for Ngui is not good since Ugui appeared, so unless you know Ngui you can
Modify the source code to the point, otherwise it is best not to use Ngui in more than 4.6.x version. (actually I have only 3 days from using Ngui to now)
(PS: I use the Ngui is the latest 3.8.2 version, 3.6.8 also tried, the situation has not changed)
OK, now I know the cause of the bug, but my project is using Unity5.0.1, and I've already used Ngui to find this bug.
, is there a way to solve this problem amicably in unity? The answer is yes.
But I am not very familiar with Ngui, and I have seen some of the source code, found to be thoroughly familiar with and to modify its underlying code needs some
Time, and there is a certain difficulty, so I chose the second road, directly from the top of the changes, will change the response to Ngui, then how to do it? Very simple
Just hang the C # script I wrote on the UI Root, and here's what the script says:
Using unityengine;using System.collections;public class Screen_adapt:monobehaviour { uipanel panel; Vector2 screen; float Alphadelta = 0.001f;//Use this for initializationvoid Start () { panel = getcomponent<uipanel> (); Screen = new Vector2 (screen.width, screen.height);} Update is called once per framevoid Update () { bool scrsizechanged = screen.x! = Screen.width | | SCREEN.Y! = scree N.height; if (scrsizechanged) { //Set resolution to notify Ngui update drag area screen.setresolution (Screen.width, Screen.height, false); Screen = new Vector2 (screen.width, screen.height); / * * If set to the same value, Ngui will take into account efficiency, so does not reset, * So use delta to set the invisible small Change */ alphadelta =-alphadelta; Panel.alpha + = Alphadelta;}}}
As long as the size of the screen area changes, the setresolution () function that calls the same window area size is displayed to
The updated window drop zone is synchronized to Ngui, so we change the Panel.alpah value of a small change to make the Ngui
To help you update the distorted dynamic font so that you can solve the problem well, and the performance overhead
Very small, so the friends who meet this problem can draw on.
Ngui handling of bugs in unity due to changing window areas