Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by crtapps · May 08, 2013 at 11:04 AM · ngui

High CPU usage in UIPanel.LateUpdate of NGUI

Hi all,

Recently I'm testing my game on iPod2 device. My game's UI solution is NGUI. I found that UIPanel.LateUpdate alwasy cost about 7ms - 10ms every frame. I think this is abnormal, does anyone know what's going on about the high cpu usage in UIPanel.LateUpdate?

Thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · May 08, 2013 at 11:24 AM

Yeah it's rebuilding one of the atlas materials every frame. This is not a good thing.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · May 08, 2013 at 11:25 AM 0
Share

I'm struggling to remember why I had that - I think it is one panel with two atlases or something.

avatar image whydoidoit · May 16, 2013 at 01:17 PM 0
Share

Right $$anonymous$$e was due to it thinking things had moved when that wasn't really true!

I changed UINode to do the other way of testing for rebuild and it's fine now:

/ /---------------------------------------------- // NGUI: Next-Gen UI kit // Copyright © 2011-2012 Tasharen Entertainment //----------------------------------------------

 #if UNITY_3_4 || UNITY_3_5
 #define UNITY_3
 #endif
 
 using UnityEngine;
 using System.Collections.Generic;
 
 /// <summary>
 /// UIPanel creates one of these records for each child transform under it.
 /// This makes it possible to watch for transform changes, and if something does
 /// change -- rebuild the buffer as necessary.
 /// </summary>
 
 public class UINode
 {
     int mVisibleFlag = -1;
 
     public Transform trans;            // $$anonymous$$anaged transform
     public UIWidget widget;            // Widget on this transform, if any
 
     public bool lastActive = false;    // Last active state
     public Vector3 lastPos;            // Last local position, used to see if it has changed
     public Quaternion lastRot;        // Last local rotation
     public Vector3 lastScale;        // Last local scale
 
     GameObject mGo;
 
     public int changeFlag = -1;        // -1 = not checked, 0 = not changed, 1 = changed
 
     /// <summary>
     /// -1 = not initialized, 0 = not visible, 1 = visible.
     /// </summary>
 
     public int visibleFlag
     {
         get
         {
             return (widget != null) ? widget.visibleFlag : mVisibleFlag;
         }
         set
         {
             if (widget != null) widget.visibleFlag = value;
             else mVisibleFlag = value;
         }
     }
 
     /// <summary>
     /// $$anonymous$$ust always have a transform.
     /// </summary>
 
     public UINode (Transform t)
     {
         trans = t;
         lastPos = trans.localPosition;
         lastRot = trans.localRotation;
         lastScale = trans.localScale;
         mGo = t.gameObject;
     }
 
     /// <summary>
     /// Check to see if the local transform has changed since the last time this function was called.
     /// </summary>
 
     public bool HasChanged ()
     {
 
         bool isActive = NGUITools.GetActive(mGo) && (widget == null || (widget.enabled && widget.color.a > 0.001f));
 
         if (lastActive != isActive || (isActive &&
             (lastPos != trans.localPosition ||
              lastRot != trans.localRotation ||
              lastScale != trans.localScale)))
         {
             lastActive = isActive;
             lastPos = trans.localPosition;
             lastRot = trans.localRotation;
             lastScale = trans.localScale;
             return true;
         }
         return false;
     }
 }
avatar image
0

Answer by DuckOfDoom · May 08, 2013 at 11:39 AM

As you can see UIPanel runs over all transforms on LateUpdate() to see if their geometry has changed and updates matrices and clipping bounds. So CPU usage like this is pretty standart. You can adress this as optimization request to NGUI creator at Tasharen.com.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NGUI Implemeting Date Picker 0 Answers

Positioning Label with NGUI 1 Answer

loading assetbundle from assets folder 0 Answers

How To Get The Image From Atlas At Run Time 0 Answers

An another problem - Tower Defense GUI (ver.3.) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges