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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Trying to get the colours of the buttons next to mine

Discussion in 'Scripting' started by acimutstudios2, Apr 30, 2018.

  1. acimutstudios2

    acimutstudios2

    Joined:
    Apr 30, 2018
    Posts:
    11
    Im trying to create a candy crush to practice my coding skills, but cant seem to figure out how can i check if there are 3 buttons of the same colour, either in the X axis or Y axis. Im just using buttons and changing their colours ramdonly. But i want to know when 3 buttons of the same colour are next to each other.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,956
    probably easiest is to have some 2D grid array to hold that data,
    so when you create those buttons or change their colors,
    set the grid cell to hold color code or color index, if you have just few colors there..

    about 2d arrays
    https://www.dotnetperls.com/2d
     
  3. acimutstudios2

    acimutstudios2

    Joined:
    Apr 30, 2018
    Posts:
    11
    Thanks! will check a bit more about 2d arrays