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
0
Question by ThunderbirdX11 · Nov 23, 2012 at 10:39 PM · guibuttondialogueanswercontinue

How to continue a dialog (GUI.Label) with answering Buttons?

Hi Guys,

I need help again, but this time, it is about scripting a dialog between my Player and a Cube (very cool, isn't it?)

Here is the Behaviour I would like to see:

  • The Player approaches to the Cube and gets in its Trigger.

  • The Player then presses "E" to start a conversation with that Cube.

  • The GUI.Area with the conversation text appears like this:

alt text

  • Now I would like to press the Button to continue the dialog, you know? It would just be like in The Elder Scrolls - Morrowind.

  • The Cube would tell me something like: "The Quest-NPC is behind that house" and I would Click on the appearing OK-Button to Close the whole Dialog.

Basically I would like to see the second Part of the text only if I clicked on the button in the dialog.

But if I click this Button, nothing happens.

Here is my Script:

     if (other.gameObject.tag == "NPC"){
         
         NPCtalk = true;
         if(Input.GetKeyUp(KeyCode.E)){
             
             startdialog = true;
             item_name = other.gameObject.name;
             playername = "Ark";
             
             }
             }    
             }
     
     
     void OnTriggerExit(Collider other){
         NPCtalk = false;
         WeaponPickup = false;
     }
     
         void OnGUI(){
             if (WeaponPickup){
                 GUI.Label (new Rect (500,500,1000,1000), "[E] Waffe aufnehmen"); 
             }
             
             if (NPCtalk){
                 GUI.Label (new Rect (500,500,1000,1000), "[E] Reden"); 
             }
             if (startdialog){
                 NPCtalk = false;
                 if (item_name == "Cube"){
                 
                 GUILayout.BeginArea(new Rect(100,100,200,200));
                 GUILayout.Label(item_name + ": Alter...du redest mit einem Wuerfel...");
                 if (GUILayout.Button(playername + ": Ich geh dann mal weiter")){
                     GUILayout.Label(item_name + ":...den Questgeber findest du hinter dem Haus.");
                             if (GUILayout.Button("OK")){
                             
                                 
                 }
                 }
             }
                 
                 GUILayout.EndArea();
                 
                 
             
             }
            
           }
             }

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

Answer by Berenger · Nov 23, 2012 at 11:01 PM

Dialogue in a RPG is quite a tricky thing, and there is a lot of stuff to think before you start coding. First, note that I'm not an expert, I'm just giving you my not professional experiences.

I see your dialogue is in your script, that doesn't feel right. It's going to be hard to translate, to add new stuff, and the more characters, the more stuff to compile. I suggest you store your dialogs into a file (xml, for instance), and load them on the run.

Then you need a way to go from sentence A to sentence B. If it's linear (A, then B, C, D, etc) it's no big deal, just a counter and go through the array. But if you can go from one sentence to any another depending of some input (keywords ?), that's a bit more difficult.

So you see, I think your going too fast into this, better think it through first.

PS : Be careful with that cube, those guys can be quite obtuse when you press them :p

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 ThunderbirdX11 · Nov 23, 2012 at 11:25 PM 0
Share

Thx for the hints. I wrote that little dialogue only for testing purposes. When the game gets bigger, I'll put the dialogues in a X$$anonymous$$L file.

Hmm I didn't expect it to be that hard to script a Dialogue with buttons.

Here is the dialoguebox of TES $$anonymous$$orrowind:

http://img69.imageshack.us/img69/2374/screenshot42fally5lr.jpg

As far as I can understand this, the Buttons on the right lead to an if or case statement wich then delivers the right sentence in the dialog-box. The two sentences in the Dialog Box are alternatives. If "Yes" then sentence "Oh I'm glad to hear that", if "No" "Oh Ok then..."

And a similar but much smaller dialogue-system is my target for now. :)

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

11 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

Related Questions

Problems with simple dialogue 0 Answers

Strange NullReferenceException when drawing DragableWindow 0 Answers

GUI create 2 buttons after activated when user clicks the mouse 3 Answers

Gui Button Solid 2 Answers

(4.6 UI) How to set up a window with x buttons, with a scroll bar? 1 Answer


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