© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
22 replies
microx

✅ object types?

hey ive been following this video on how to make tictactoe, for a class assignment, (https://youtu.be/AzPgov_stdI?list=PLWeGoBm1YHVj7cYQSglzBU0gb7ecDNf4g)
this guy uses images for his X's and O's. i decided to make gameObjects out of 3Dobjects (bc my teacher is not smart and would accuse me of cheating if i use pictures...)

  public void tictactoeButton(int WhichNum)
    {
        tictactoespaces[WhichNum].GameObject = playerIcons[playerIcons];

       

        //...

        if(playerTurn == 0)
        {
            playerTurn = 1;
        }
        else
        {
            playerTurn = 0;
        }
    }
  public void tictactoeButton(int WhichNum)
    {
        tictactoespaces[WhichNum].GameObject = playerIcons[playerIcons];

       

        //...

        if(playerTurn == 0)
        {
            playerTurn = 1;
        }
        else
        {
            playerTurn = 0;
        }
    }

i have this code here which is supposed to mark the spaces when you click them. but i get this error, when i save: Assets\scripts\NewBehaviourScript.cs(39,35): error CS1061: 'Button' does not contain a definition for 'GameObject' and no accessible extension method 'GameObject' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)
any help? this is his code btw:

public void tictactoeButton(int WhichNum)
    {
        tictactoespaces[WhichNum].image.sprite = playerIcons[playerIcons];

       

        //...

        if(playerTurn == 0)
        {
            playerTurn = 1;
        }
        else
        {
            playerTurn = 0;
        }
    }
public void tictactoeButton(int WhichNum)
    {
        tictactoespaces[WhichNum].image.sprite = playerIcons[playerIcons];

       

        //...

        if(playerTurn == 0)
        {
            playerTurn = 1;
        }
        else
        {
            playerTurn = 0;
        }
    }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Json array with multiple types to object
C#CC# / help
3y ago
WPF TreeListView bind multiple different node object types
C#CC# / help
2y ago
Double check if an object is one of provided types
C#CC# / help
4y ago
Opening DB Connection: Object cannot be cast from DBNull to other types
C#CC# / help
2y ago