Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to optimize NGUI Battle words and Interface

Shulou Source: shulou.com Published: 2022-06-01 03:34:48 09月17日 Update

This article shows you how to optimize the NGUI fighting words and interface. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Floating character problem: floating character will have a gradual change of Alpha. When the gradient changes to 0, it will trigger the Rebuild of UIPanel.

Solve the problem: find out where Rebuild is triggered, add log code to UIPanel, find the corresponding UI control, change the minimum value of Alpha in Animation to greater than 0.001, and set the location of label to infinity without doing explicit and implicit operations.

Public UIDrawCall FindDrawCall (UIWidget w) {Material mat = W. complete; Texture tex = W. mainTexture; int depth = w. Depth; for (int I = 0; I

< drawCalls.Count; ++i) { UIDrawCall dc = drawCalls[i]; int dcStart = (i == 0) ? int.MinValue : drawCalls[i - 1].depthEnd + 1; int dcEnd = (i + 1 == drawCalls.Count) ? int.MaxValue : drawCalls[i + 1].depthStart - 1; if (dcStart = depth) { if (dc.baseMaterial == mat && dc.mainTexture == tex) { if (w.isVisible) { w.drawCall = dc; if (w.hasVertices) dc.isDirty = true; return dc; } } else mRebuild = true; if (mRebuild) { DebugShow(w); } return null; } } DebugShow(w); mRebuild = true; return null; } private void DebugShow(UIWidget w) { string path = ""; Transform t = w.transform; while(null != t) { path += t.transform.name + "/"; t = t.parent; } Debug.LogWarning("" + path + "time:" + Time.time+ ""); } 查找出对应的UI控件,将Animation中的Alpha的最小值修改为大于0.001(UIWidget),及TweenAlpha动画中做同样的修改 /// /// Update the widget's visibility and final alpha. /// public override void Invalidate (bool includeChildren) { mChanged = true; mAlphaFrameID = -1; if (panel != null) { bool vis = (hideIfOffScreen || panel.hasCumulativeClipping) ? panel.IsVisible(this) : true; UpdateVisibility(CalculateCumulativeAlpha(Time.frameCount) >

0.001f, vis); UpdateFinalAlpha (Time.frameCount); if (includeChildren) base.Invalidate (true);}}

two。 The combat interface consists of skill countdown, number of combo, etc.

1)。 Modify the countdown at the end of the label is not hidden, instead set to empty, set the string method to use U3D memory to optimize the use of String in UILabel.

2)。 Add a separate UIPanel to the frequently refreshed area

3)。 Minimize explicit and implicit operations on interface elements to reduce the Rebuild process of UIpanel, thus reducing DrawCall

After testing, the Rebuild of UIPanel has been greatly reduced, especially those with floating characters.

The above content is how to optimize the NGUI fighting words and interface. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Interface combat skill problem minimum countdown content control time knowledge explicit concise concise code location element memory animation area and at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Shulou Tech Info Microsoft MySQL