Search Unity

Is there any reason to use Unity UI and a Canvas in a single-screen 2D game?

Discussion in '2D' started by SlimeProphet, May 30, 2020.

  1. SlimeProphet

    SlimeProphet

    Joined:
    Sep 30, 2019
    Posts:
    50
    I've been learning the UGUI system. I've also been making a single-screen 2D game for practice. At first, I used the UGUI system with a Canvas for the UI. This was good for some fun headaches and learning all about the different coordinate systems in Unity. But then I realized that it was pointless, at least for my simple needs for a "Score" box and "Back" button. The camera already scales on its own, and managing both overlay coordinates and worldspace seems much harder than just manually setting the transform for my "Back" button in its Start() function based on the screen dimensions.

    I do see that the big "Complete C# with Unity" Udemy course uses a scaled-down Canvas set to worldspace for its clone of Plants vs. Zombies, but it doesn't explain why.

    Am I missing something? Is there a reason to use the UGUI system for a single-screen 2D game?
     
    Last edited: May 30, 2020
  2. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Are you talking about putting the entire game in the UI system? (Not a good idea BTW). The UI is notoriously slow, adding gameplay elements to it other than GUI isn't recommended.

    and UUI = "Unity UI"?.. i've never seen this abbreviation here.
     
  3. SlimeProphet

    SlimeProphet

    Joined:
    Sep 30, 2019
    Posts:
    50
    Yes, Unity UI. Maybe people say UGUI? Three UI systems is too many, perhaps... I mean the one the editor treats as default and uses a canvas.

    No, I don't mean making the entire game in the UI. I mean: Is there a point to using the UI system at all, if you're making a single-screen 2D game? Wouldn't it be simpler just to make the UI part of your game, since it doesn't need to move or scale differently than the rest of your game?

    I'm wondering if I'm not seeing an advantage to using the UI in such cases.
     
    spryx likes this.
  4. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Not really, the UI system just makes it easier to manage where elements are placed. It also guarantees an overlay. No reason not to use it if you don't go overboard as it is simple to understand. I'm probably forgetting some of the other advantages, but if you have managed to incorporate all the UI you need in game, no reason to switch up anything.

    Features like this are always a give-and-take type deal. What you gain in something you loose somewhere else. Ease of use is traded for slightly better performance and vice-versa. You just need to decide if the trade-offs are worth it.
     
    x2pi3141 and SlimeProphet like this.