Search Unity

Removing the GUILayer, GUIText & GUITexture components

Discussion in 'Immediate Mode GUI (IMGUI)' started by ascentress, Jan 7, 2019.

  1. ascentress

    ascentress

    Unity Technologies

    Joined:
    May 4, 2017
    Posts:
    9
    As Unity moves ahead, we discover small bits that get naturally left behind. This time we are looking at the GUILayer, GUIText and GUITexture components that, as some of you may have already noticed, have been marked as deprecated since a while back.

    First, let's take a look at what these components do.
    • The GUI Layer is a component you would attach to the Camera to be able to render GUI Text and GUI Texture components.
    • GUI Text and GUI Texture allow text and UI-related 2D images to be displayed in screen coordinates.

    Now, why are we removing these?

    These components predate even the OnGUI system, i.e. they come from a time when Unity was at version 1.x. Completely new ways to handle user interfaces in Unity have come along since then and it is time to really say goodbye to the leftovers of a legacy-legacy UI system. This change is expected to appear in either 2019.2 or 2019.3 so everyone should have enough time to review projects that still rely on GUILayer, GUIText or GUITexture.

    We'd like to hear if you are still using these components -- will their removal affect your workflows and creative processes?
     
    Arshd and ihgyug like this.
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,746
    What I want to know is if I can safely remove the GUILayer from everywhere without getting a performance hit, since Unity searches for the component anyway, even though it’s deprecated.

    Context: https://divillysausages.com/2016/01/21/performance-tips-for-unity-2d-mobile/

     
    Last edited: Jan 7, 2019
  3. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Right, well as long as the components exist in Unity, MouseEvents has to do the component search (even if it's deprecated -- so that existing projects continue to work), and it's unfortunate that this causes an allocation. However once we actually remove it, then it will obviously stop searching for it!
     
    Circool and AcidArrow like this.
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,746
    Then please, please remove it.

    My sample size is small and my evidence anecdotal, but the only “use” I’ve heard anyone have for the GUILayer, is to add it to workaround that issue.

    (edit: And personally, you can go ahead and delete OnGUI as well)
     
    Last edited: Jan 7, 2019
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,746
    Hey @Aras and @lina_unity ,

    I hope you are interpreting the lack of participation in this thread as what I think it is, which is that no one really cares about GUILayer, GUIText or GUITexture (and I would go as far as to include OnGui as well) and that in fact, their inclusion in Unity only causes problems and nothing else.

    Please remove them.
     
    Last edited: Jan 28, 2019
    BinaryCats likes this.
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    You should probably post these in a forum that's actually read - like Scripting or Editor.

    I would love it if you purged these, as they're just in the way.
     
  7. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    866
    Please remove
     
  8. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Never used these components sind 2013. ;)
     
  9. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,746
    So why is GUI Layer still in Unity? No one uses it, it makes everything worse, it's just bad.

    I do not understand how you can deprecate and remove other stuff that people actually use, without much warning, but you hold on to GUI Layer for dear life, much to the dismay of your users.
     
  10. ascentress

    ascentress

    Unity Technologies

    Joined:
    May 4, 2017
    Posts:
    9
    I understand the amount of time it takes to deprecate a feature is frustrating, but I do have some good news in regards to this - - legacy GUI components are no longer in Unity starting with 2019.3. Means that there's no more of that stuff starting with this year's LTS release.
     
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,746
    Good news! Thank you for the update.
     
  12. Icelander78

    Icelander78

    Joined:
    Sep 19, 2012
    Posts:
    34
    Hi, i am very concerned about this because, i am not a software guy, i am just a scientist using Unity since the beginning of Unity to make educational apps that I and others use for teaching, my apps are build on GUI Layer and GUI Text and other legacy stuff, I have been using my apps for years now regularly updating them and now with this removal I will not be able to update them.
    What are you proposing to fix this? I use to write my scripts in unity javascript, this is also gone, What shall I do?
     
  13. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    From my point of view as a user: If you want to use the newest Unity engine features, upgrade your code to C# and replace GUIText components with either IMGUI, Unity UI (4.6 version) or the upcoming UIElements system (2020 or later). Unity has been supporting legacy feature for years now, but at some point users just have to upgrade to the newer versions or continue to use the old editor version. If you do not want to upgrade, you can continue to use Unity 2019.1 for multiple years until some incompatibility with newer operating systems would force you to upgrade. Even more, you can always delay upgrading your operating system as long as possible, that would give you a couple of years on top of that.
     
  14. Icelander78

    Icelander78

    Joined:
    Sep 19, 2012
    Posts:
    34
    Thank you for your answer, the problem is that since I upgraded my mac with the last mac os and xcode, i am not able to get a working build with the unity version 2017 or the early 2018, either unity freeze when trying to build the resources folder in mono or fail when using il2cpp :( and for an other app of mine the build succeed but xcode fails to build refering to il2cpp issues (see my post in ios dev part of the forum). :(
     
  15. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    My game relies on some key asset DLL's that are no longer supported. Some of these DLL's have references to GuiTexture and fail my build since I upgraded to 2019.3...

    What do I do now?
     
  16. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    If you're in control over development you have a couple of options:
    • Contact the original authors of the DLLs and ask them if they consider upgrading them to a newer version without GuiTexture.
    • Try to obtain the source code for the DLLs
    • Use a tool like ILSpy to decompile the library and try to remove the legacy code this way and rebuild
    • Ditch the tool entirely and replace it with your own
    If you're doing this for somebody else:
    • Tell them it's too late to upgrade the project with reasonable costs. GUIText was deprecated years ago, its been more than enough time to upgrade to IMGUI, Unity UI, NGUI, 2DTK or any toolset that has replaced the old GUI components since.
    In both cases, you can also opt for not upgrading to Unity 2019.3. That's pretty bleeding-edge. How come you need cutting-edge features as well as deprecated ones? Maybe it's easier to stay on an older version.
     
    Kurt-Dekker, ascentress and Meltdown like this.
  17. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,090
    Last edited: Feb 13, 2020
  18. PierreLouis29

    PierreLouis29

    Joined:
    Sep 12, 2019
    Posts:
    6
    @ascentress

    Hello,
    I am trying to open a 5.5.3f1 project into 2019.3.2f1 for multiple reasons.

    Everything went quite smoothly as I upgraded some scripts to match the current API.

    The only remaining issues I have are related to this very topic, here are the last errors I get :

    Error1.png
    (end of the two cut lines)
    Error2.png

    All these errors come from the same script : "SteamVR_Camera.cs". Here are screenshots of this script namespaces and of the problematic areas :

    namespaces.png
    group1.png
    group2.png

    Do you know what I have to use instead of GUILayer for my project to compile ?
    Thanks in advance.
     
  19. ascentress

    ascentress

    Unity Technologies

    Joined:
    May 4, 2017
    Posts:
    9
    @PierreLouis29 Hey! Sorry I'm replying quite late. Looking at the code of the SteamVR plugin, I think, these code blocks should be safe to remove. I found this paragraph in the documentation for SteamVR (found here: https://github.com/ValveSoftware/op...eyboard_sample/Assets/SteamVR/readme.txt#L283):
    My assumption is that this code is intended to shift the GUILayer component to another object to avoid compatibility issues. Since GUILayer was only needed to render GUITexture/GUIText, there is no reason for this code to exist anymore and you can safely remove it from the plugin inside your project.

    You might also want to look into updating your version of the SteamVR plugin from the Asset Store since GUILayer behaviour has been fixed there. I cannot assure that your project will be fully compatible with it, however.
     
  20. ascentress

    ascentress

    Unity Technologies

    Joined:
    May 4, 2017
    Posts:
    9
    kreso likes this.
  21. xGeorgeV

    xGeorgeV

    Joined:
    Aug 8, 2013
    Posts:
    65
    The GUILayer is very fast...
    Ideal for mobile games...
    The GUILayer (GUITexture/GUIText) removal is a lot of work for nothing...
    I have to completely rewrite the games interfaces...
    I would have done something else instead...
    Thanks Unity...

    And the Unity does not handle AAR files (Null Reference Exception at runtime) from Unity 2019.2.11 to 2019.2.21.
    Fixed in 2019.3. But 2019.3 does not contain GUILayer. LoL...
    Google (Android) Play Services Resolver use AAR files... Unity from 2019.2.11 to 2019.2.21 are unusable... LoL...

    If Unity would use its head, then it would have taken GUILayer out of Unity 2020.1.0, because Unity 2019.2 is not compatible with Unity 2019.3, and the newer versions of Unity 2019.2 are unusable for Android development.
     
    GameLover90 likes this.
  22. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,746
    What? No, that is absolutely false.
     
  23. xGeorgeV

    xGeorgeV

    Joined:
    Aug 8, 2013
    Posts:
    65
    I have been using it since 2014.
    I know what I'm talking about.
    The GUILayer is very fast.
    The Unity Canvas and a lot of scripts (Resolution, Raycaster, Text, Image, Button, Layout, Content Size, Aspect Ratio, etc.) are very slooooooooooooooooooooooow.
     
  24. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,746
    Untiy can't program GUIs, both are slow, roll your own.
     
  25. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    I've been using Unity since 2009, I know what I 'm talking about more than you.
    It is not fast.
     
  26. xGeorgeV

    xGeorgeV

    Joined:
    Aug 8, 2013
    Posts:
    65
    I tested this.
    Android game while playing with GUILayer: 60 fps.
    Same Android game with Canvas UI and buttons: 54 fps.

    Why not take GUILayer out in Unity 2020.1.0?
    Unity 2019.3 will be LTS, but this version is not compatible with Unity 2019.2.
    The games with GUILayers can't use Unity 2019.3 LTS. Ahhh...

    The Unity 4 was the best for mobile development.
    The Unity 5 was a Terrain killer (sloooow) and the PBS shaders (sloooow), ohhh... Performance killers for mobile developers. And the lags in 3D games. Incremental GC and Optimzed Frame Pacing options didn't really help.

    https://forum.unity.com/threads/unity-ui-performance-tips-sharing-my-findings.524916/
    "Uncheck "Pixel Perfect" in the Canvas settings. Big performance hitter."

    https://create.unity3d.com/Unity-UI-optimization-tips
    https://learn.unity.com/tutorial/optimizing-unity-ui
     
  27. Normark

    Normark

    Joined:
    Jul 25, 2018
    Posts:
    8
    Ascentress how do I use the script you have made?
    I have a god deal of VR projects that use the "Movement pack for VR" from the asset store, and all their scripts gives problems after update to 2019.3.4f1
     
    Last edited: Apr 26, 2020
  28. ascentress

    ascentress

    Unity Technologies

    Joined:
    May 4, 2017
    Posts:
    9
    Place the download Editor folder and its contents at the root of your Assets folder, then click "Cleanup/Cleanup Scenes with Deprecated Components" in the top toolbar menu.
     
  29. Normark

    Normark

    Joined:
    Jul 25, 2018
    Posts:
    8
    Thanks :)
     
  30. unity_0AD426A006EE51C47EE8

    unity_0AD426A006EE51C47EE8

    Joined:
    Sep 22, 2021
    Posts:
    2
    Would you know what replaced the "GUILayer" component ?
    Can Anyone tell me the exact answer. What should I write in the GUILayer?
    Reference
    cam.AddComponent<GUILayer>();
     
  31. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    You should find a tutorial made after 2015!
     
  32. Cuicui_Studios

    Cuicui_Studios

    Joined:
    May 3, 2014
    Posts:
    72
  33. ascentress

    ascentress

    Unity Technologies

    Joined:
    May 4, 2017
    Posts:
    9
    That's bad news, I'm sorry!

    Using this method might not be a good idea anymore since there's a chance that packages or scene-modifying callbacks could modify a scene in an unintended way just by opening it.