Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by anszwa · Apr 05, 2017 at 09:17 PM · cameraguioptimizationprofilergc.collect

Deleting GUI Layer creates GC Allocation?

Hi folks I have following problem:

I work on a simple game for mobile an try to optimize it as far as possible. Therefore I checked the Profiler an recognized, that I had a GC allocation at a SendMouseEvent.DoSendMouseEvents() of 0.6 KB.

Dont get me wrong, this is not much of a problem and the game runs fine, but I was wondering where it came from, because I ended up with deactivating all but the camera in my scene, and it still was there. If Altough if I create a new scene, I dont have any GC allocation at all (Unity 5.6).

So i tried to find the difference and ended up recognizing that I had deleted all the unused components from the camera (GUI Layer, GUI Flare Layer).

When I instead leave the GUI Layer on the camera, the problem is gone, even if it is deactivated and not deleted. Do you guys have any idea where this came from even though the GUI Layer is already marked as Legacy an not needed within the new UI System?

https://docs.unity3d.com/Manual/class-GUILayer.html

Thank you in advance for your time!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Apr 06, 2017 at 12:20 AM

The GUILayer component is required / used by the old GUITexture and GUIText components. It's used for hit detection on those components. Inside "DoSendMouseEvents" there is this code which is executed for each camera:

 if (camera.pixelRect.Contains(mousePosition))
 {
     GUILayer component = camera.GetComponent<GUILayer>();
     if (component)
     {
         GUIElement gUIElement = component.HitTest(mousePosition);
         if (gUIElement)
         {
             SendMouseEvents.m_CurrentHit[0].target = gUIElement.gameObject;
             SendMouseEvents.m_CurrentHit[0].camera = camera;
         }
         else
         {
             SendMouseEvents.m_CurrentHit[0].target = null;
             SendMouseEvents.m_CurrentHit[0].camera = null;
         }
     }

As you can see the code uses GetComponent to get the GUILayer component on the camera.

Your problem comes from a debugging feature that only exists inside the UnityEditor. Whenever GetComponent would return a "null" value, it actually returns an instance that pretends to be null. This is used to show a more meaningful error message in the console whenever you try using that "null" value.

This is only an overhead in the editor. At runtime (in a build) this is not a problem. See this Unity blog post for more details.

Comment
Add comment · Show 1 · 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 anszwa · Apr 06, 2017 at 07:28 AM 0
Share

Thank you for your fast and detailed answer!

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

125 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 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 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 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 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 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 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 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 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

Profiler shows Object.ElementAddr_3_8() called over a million times. What is it? How do I reduce this? 1 Answer

EditorOverhead High CPU Usage in Unity Profiler 0 Answers

Having trouble understanding the Unity Profiler, need some help with some of what I'm seeing 0 Answers

Profiler PlayerLoop spikes with no apparent reason 1 Answer

Static variables & performance 2 Answers


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