Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to optimize NGUI Battle words and Interface

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report