Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by unity_optimosgame · Oct 14, 2017 at 12:07 PM · messagemessagingmessagebox

[En & Fr] Show a message on the screen - Faire apparaître un message sur l’écran

English:

Hello, I am creating a game and I would like to know how to make a temporary message that will be displayed like a screen like "This box is empty" or "You do not have the green key", which would be displayed only seconds. To be more precise I would like me to approach a GameObject (Cube, Sphere, ...) is that I collide with him a temporary message appearing in the middle of the screen with written, as an example "No interaction possible". I would also like to have the script in C # version otherwise the java script Unity will do the job :)! Thank you and good day.

Français:

Bonjour, Je suis en cour de création d'un jeu et j'aimerais savoir comment faire un message temporaire qui s'afficherai a l'écran comme par exemple "Cette boîte est vide" ou " Vous n'avez pas la clé verte", qui s'afficherais que quelque secondes. Pour être plus précis j'aimerais que quand je m'approche d'un GameObject (Cube, Sphère, ...) est que je rentre en collision avec lui un message temporaire apparaisse au milieu de l'écran avec écrit, comme exemple "Pas d'interaction possible". J'aimerais aussi avoir le script en version C# sinon le Unity java script fera l'affaire :) ! Merci et bonne journée.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by SoulRider · Oct 14, 2017 at 12:37 PM

All you need to do is create a generic canvas and add a text box. Make the canvas available to all items, by adding a reference to it, then in the item, where you handle the collisions, call a co-routine where you enable the canvas, set the text, then wait for x seconds, before disabling the canvas.

This works for when you will only have one message on screen at a time. If you need a message box for each item, then simply create a canvas in each object then enable and disable this.

psuedocode:

 public Canvas message;
 
 void OnCollision()
  MessageAlert()
 
 co-routine MessageAlert()
 message.gameobject.SetActive(true);
 message.messagebox.text = "Get Off My Lawn";
 yield return waitforseconds(2f);
 message.gameobject.SetActive(false);
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unity_optimosgame · Oct 14, 2017 at 02:03 PM 0
Share

Very good code ! Thanks !

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

71 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Message Box Question(please read) 2 Answers

In which script(s) are the messages sent by the Network class actually called? 0 Answers

I need a function so that when and event is trigger a message is displayed on the screen for a set duration. 1 Answer

.exe error 0 Answers

Message Boxes and running .exe files 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges