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

Games Adult card game Confused beginner please point in the write direction.

Discussion in 'Works In Progress - Archive' started by Bizarrestile, Apr 19, 2020.

  1. Bizarrestile

    Bizarrestile

    Joined:
    Apr 19, 2020
    Posts:
    5
    Hey I’m new to unity and I have been learning for a few weeks now.
    What I’m trying to do is create this game where I have four decks of cards and when you click on a deck the card displays and then when you click done it destroys that card.
    So I learned basic c# and did some research and people on the forums said to use an array for cards but I’m not making a complicated card game.
    I researched arrays and found that it’s not what I need.
    So I decide to make a list of Gameobjects call them cards.
    I made a list with the card gameobjects and populated the elements in the list how do I draw from the list using a button to display one card from the top of the list? I would assume Onclick event?


    Any help would be appreciated
     
  2. Bizarrestile

    Bizarrestile

    Joined:
    Apr 19, 2020
    Posts:
    5
    I just want to have a button draw a gameobject/sprite from the list and display it why is this so hard to find the answer to. I have been looking for hours...
    some please help
     
  3. Bizarrestile

    Bizarrestile

    Joined:
    Apr 19, 2020
    Posts:
    5
    Public List <GameOject> deckAcards=

    new List <GameObject>();


    Public void OnClick ()

    {

    If (GameObject == deckAcards [0]);

    deckAcards[0].SetActive(true);

    Else

    deckAcards[1].SetActive(false);

    deckAcards[2].SetActive(false);

    deckAcards[3].SetActive(false);

    deckAcards[4].SetActive(false);

    Etc...

    }

    Public void OnDoneclick()

    {

    deckAcards[0].SetActive(false);

    List.Remove(deckAcards[0]);


    }