Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

is there a negative to using the legacy OnGUI for layouts?

Discussion in 'Editor & General Support' started by Sylvir, Jan 22, 2016.

  1. Sylvir

    Sylvir

    Joined:
    Mar 21, 2015
    Posts:
    396
    It seems to me that sometimes using the legacy OnGUI to set up a layout for something in a game could be an easier way to make sure it scales correctly and can laid out well. Is there any downside to using this system instead of the new ui system that is in the newer versions of unity? I am just trying to understand what the pros and cons to using either method would be. Thanks for taking the time to read my question!
     
    Kurt-Dekker likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    I'm generally bearish on the hassle of a complicated UI so I use OnGUI for all my games. There can be performance issues on older devices unless you take care to keep it simple. Some guidelines are don't do any actual game calculations inside of OnGUI(), since there's no guarantee how many times it will be called. In fact, you should only display data and accept input into a boolean or other variable, nothing else inside of OnGUI().

    If try my games out on Android or iOS (they are free) you will find them to be quite performant, and they do NOT use the Unity uGUI at all, since that requires hassling with anchors and editors and oh my. Not my cup of tea.

    here's my ios games: https://itunes.apple.com/us/artist/kurt-dekker/id680019078

    here's my android games: https://play.google.com/store/apps/developer?id=Kurt+Dekker
     
  3. Sylvir

    Sylvir

    Joined:
    Mar 21, 2015
    Posts:
    396
    cool, thank you @Kurt Dekker the anchors and other stuff can be a real headache sometime. i wasnt sure if i just need to learn to use it better or if its just how that system is at the moment. That is the main reason i was considering setting up my layouts and stuff in a OnGUI instead of the newer versions. thanks ill takea l ook at your game in a bit here. my phone is charging currently