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. Dismiss Notice

Question Sprites vs UI Images

Discussion in '2D' started by guillemp95, Aug 7, 2023.

  1. guillemp95

    guillemp95

    Joined:
    Mar 13, 2020
    Posts:
    4
    I am making a 2D chess game and I am debating what system to use to create the chess board (visually I am trying to do something similar to chess.com). I have been researching previous questions about this exact same topic but could not find any convincing argument towards one or the other. So should I use UI Images inside a Canvas or Sprites to create the chess board? What are the pros and cons of each system? What in terms of performance? I want to target mobile devices, so the board should adapt to any kind of resolution (portrait).
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,708
    There are many many blog posts that discuss it. I am not going to retype all that stuff here in this little box.

    Instead, experiment, ask yourself "can I???" and work through all the things you think you'll need to do.

    Like this guy does:

    Imphenzia: How Did I Learn To Make Games:



    You're already a leg up just by being aware that there is a difference.

    ANYTIME you work with UI, keep this firmly in mind or you may end up having to redo it all several times:

    Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:

    https://forum.unity.com/threads/inc...size-between-two-people.1130146/#post-7261747

    https://forum.unity.com/threads/game-ui-button-size-problem.1142650/#post-7337383

    Usually you need to choose a suitable ScaleMode and MatchMode in the Canvas Scaler and stick with it 100%. Generally if you change those settings you will often need to redo your UI entirely.

    I also use this
    CanvasScalerOrientationDriver
    utility to make sharing UI for Landscape / Portrait easier. Read what it does carefully.

    https://gist.github.com/kurtdekker/8802b1b6c708637398f8c9167641efd3
     
  3. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    sprites will give you more freedom

    you can just use UI and you probably could make it work without issue

    its a matter of preference, that you could only get if you knew both systems
    if i was in your shoes i would prefer to use sprite renderers
     
  4. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,131
    You could also use a mesh to render the board for the board….but the visual representation of your 2D chess game is likely the thing to worry least about (performance, etc.). Get the logic (multiplayer, AI, chess engine, ..,) down with a simple array (data structure) and then worry about visualization…or are you already this far?
     
  5. guillemp95

    guillemp95

    Joined:
    Mar 13, 2020
    Posts:
    4
    Thanks for the resources provided I think they can be useful!
     
  6. guillemp95

    guillemp95

    Joined:
    Mar 13, 2020
    Posts:
    4
    Yep, I think I will go for sprites and see how far can I go
     
  7. guillemp95

    guillemp95

    Joined:
    Mar 13, 2020
    Posts:
    4
    Actually I do not have the logic yet, but I wanted to tackle the visualization problem first. I want to go for a decoupled logic so that shouldn't be very important.