Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by RSunity · Dec 08, 2010 at 01:16 AM · messagebox

GUI Message Box

Hi, I've been having some trouble creating a GUI Message Box. Basically, I want to make a script for the message box, but be able to call this message box from a different script.

For example,

I would use this on a different script:

MessageBox("Text goes here.");

or something like that but it would be getting the message box from the original script.

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

2 Replies

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

Answer by Jesus_Freak · Dec 08, 2010 at 01:27 AM

you vould put on this script if you want only words but can convert it into a button easily if you want:

//the name of this script this following code is in is important! will be //refered to as "Message" by me. so you could replace Message in the next code with your actual name for it. static var Str : String;

function OnGUI() { GUILayout.Label(Str); }

and that would automaticlly make the string ubneditable through the inspector (making it 100% program-changable and programming-changable only!) but it displays the text as a preset label.

in another script you could do

function Update()
{
 if(Input.GetKeyDown(KeyCode.delete)) // when the delete key is pressed
 {
  Message.Str = "Deleted"; // example word to be displayed.
 }
}

i hope that helps you, and that if this isn't what you wanted, that it at least helps you understand what you could do to optimize it to your situation!

Comment
Add comment · Show 7 · 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 Jesus_Freak · Dec 08, 2010 at 01:32 AM 0
Share

right now, the default string to be "GUI'd" is empty, so it won't play until you change it like shown in the second code.

avatar image RSunity · Dec 08, 2010 at 01:34 AM 0
Share

Thank you, helped a lot.

avatar image Jesus_Freak · Dec 08, 2010 at 01:40 AM 0
Share

sure! glad to help! if you need help with anything or something isn't just right, let me know, with specifics, and i or anyone else could possibly help you more.

avatar image Jesus_Freak · Dec 08, 2010 at 01:47 AM 0
Share

i'll check into it. until then, you could change the first static var to make it look like:

static var Str : String = "$$anonymous$$y $$anonymous$$essage"; and change the "$$anonymous$$y $$anonymous$$essage" to whatever you want. for right now...

avatar image Jesus_Freak · Dec 08, 2010 at 01:50 AM 0
Share

well, i see you deleted your comment, so i guess you figured it out. but i tested it myself just to be sure, and it works for default, now i'll check if you can edit the words.

Show more comments
avatar image
0

Answer by HaimBendanan · Dec 31, 2016 at 01:27 PM

For anyone looking for something similar, i made a simple message box, easy to use, feel free to try it: Simple-Message-Box-Unity on Github

Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

.exe error 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

new ui 2d gameobject position message box 0 Answers

Design Pattern: How to make a MessageBox 0 Answers

Issues building an in-game MsgBox 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