- Home /
Problem with click to display information
Hello guys, i made a project for my final assignment. it is a monopoly game with C#. i have finished the dice but i confuse with the board. when clicking an area then a property card will display information within. how i do that? anyone can give me a clue or a script? Illustration is here:
Thanks for helping me :D
This is not something you just post a script to solve. You have the following problems to be solved:
How to display the board
How to detect hits on specific areas of the board
How to 'load' or 'address' the texture to be displayed
How to display the texture.
And the choices you make for the above list partly depend on factors that you did not provide: target platform, size of the textures, number of cards to be displayed at any one time (i.e. will a player collect cards), etc.
$$anonymous$$aking some educated guess and trying to keep things simple, I would suggest you do the following at least as an initial approach:
Display the game board on a Quad in world space
Over each place on the board you want clickable, place a game object with a box collider.
Set the name of the game object to the name of the texture of the card.
Detect the hit and get the name using a Raycast().
Get the texture to be displayed by putting your textures in Assets/Resources and using Resources.Load() to get the texture by the name you received in the Raycast().
Show/hide the card on a Quad and turning the renderer on and off.
Set the material.mainTexture on the Quad to show a specific card.
Answer by zaid87 · Aug 12, 2014 at 09:31 AM
I'm a bit new to Unity (so there might be a better way that I don't know), but here's a suggestion I can think of:
First, create a GameObject to show the information of the property whenever the player clicks on it. Deactivate the object at start and when a player clicks on a property, you activate the object and sets the value you want to show. When the player close the information, just deactivate the GameObject again.
Hope this helps.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Selecting scene for your main menu 1 Answer
How can I save scripted variable changes? 2 Answers
Audio source in two different scenes 1 Answer
Enable/Disable objects, with script 9 Answers