Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Apr 06 at 11:42 PM by PresidentTree.
avatar image
0
Question by PresidentTree · Apr 05 at 11:56 PM · scripting problemscript errormethodsskip

Why are some of my methods being skipped?

I am creating a dialogue system that continues the dialog every time a key is pressed. However, when it comes to dialogue that involves choices, only the first choice dialogue plays. Both choice dialogue and non-choice dialogue use the same method, ReadLine(), but choice dialogue includes a number that prevents the dialogue from playing unless it matches the number determined by the choices. There are no differences in the conditions for the choice dialogue, so I do not know what is missing that allows it to be skipped. Thanks in advance for the help. Here is what I currently have:

Dialogue Script:

 //Play dialogue:
     void Update()
     {
         ToggleDialogueBox();
         ReadLine("David", "This is a test.");
         ReadLine("Alfred", "Did it work?");
         ReadLine(null, "Did the text type out like a typewriter?");
         AskQuestion(null, "What do you think?");
         ReadLine("You", "Yes.", 1);
         ReadLine("David", "We agree.", 1);
         ReadLine(null, "Goodbye.");
         ToggleDialogueBox();
     }
 
     //Type dialogue:
     void ReadLine(string name, string text)
     {
         TypeDialogue(name, text);
 
         if ((textBox.text == text || nameBox.text == text) && dialogueScript.Count > textIndex && Input.GetKeyDown(KeyCode.T))
         {
             textIndex++;
         }
     }
 
     //Type dialogue for choices (overload):
     void ReadLine(string name, string text, int num)
     {
         if (num == choiceNum)
         {
             TypeDialogue(name, text);
         }
 
         if ((textBox.text == text || nameBox.text == text) && dialogueScript.Count > textIndex && Input.GetKeyDown(KeyCode.T))
         {
             textIndex++;
         }
     }
 
     //Get choices:
     void AskQuestion(string name, string text)
     {
         choiceNum = 0;
 
         TypeDialogue(name, text);
 
         if ((textBox.text == text || nameBox.text == text) && dialogueScript.Count > textIndex)
         {
             if (Input.GetKeyDown(KeyCode.O))
             {
                 choiceNum = 1;
                 textIndex++;
             }
 
             if (Input.GetKeyDown(KeyCode.P))
             {
                 choiceNum = 2;
                 textIndex++;
             }
         }
     }
 
     //Function for conversation:
     void TypeDialogue(string name, string text)
     {
         if (dialogueScript.Count == textIndex && dialogueBox.gameObject.activeSelf)
         {
             string[] line = { name, text };
 
             if (!dialogueScript.Contains(line))
             {
                 dialogueScript.Add(line);
             }
 
             if (dialogueScript[textIndex][0] == null)
             {
                 nameBox.text = string.Empty;
             }
             else
             {
                 nameBox.text = name;
             }
 
             textBox.text = string.Empty;
             StartCoroutine(TypeLine(dialogueScript[textIndex][0], dialogueScript[textIndex][1]));
         }
     }
 }
Comment
Add comment · Show 2
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 jmgek · Apr 05 at 11:59 PM 0
Share

No ones is going to read 140 lines to try and fix your problem when you can fix it yourself with a breakpoint. https://docs.unity3d.com/Manual/ManagedCodeDebugging.html

avatar image PresidentTree jmgek · Apr 06 at 12:10 AM 0
Share

I wouldn't have submitted my issue to Unity Answers if I could get the debugger to work. I removed some things. Is that short enough?

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

237 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 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 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 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

Help with script 1 Answer

[C#] Quaternion Rotations with Input.GetAxis problems. 1 Answer

ArgumentException for UnityEvent 0 Answers

[Help!]Unity FPS Health script error. 1 Answer

How to know exactly which game objects and objects are not referenced ? 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