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 aomikki · Jul 03, 2018 at 03:54 PM · scripting problemdialogue

Need help with dialogue system script

I'm sorry if this sounds too amateur. I am working on a Visual Novel project where the game majority mechanic is on its dialogues. I'm working with a friend of mine and we've done several base of the system like changing the name line, dialogue lines, and even character sprites (though only limited to one sprite each time). There are scripts that build this system, one of them is the serializable that fills the lines, it makes a limited space of array, but we don't mind that.

The main problem now is that I unable to insert choice, its flag, and transition to other scene (the script has limit for handling the queue, so I still need to load other screen to make a new queue and manually write it).

Things that I really in dire need to know: 1. making the choice flag as the parent of the dialog queue so each choices goes to each different flag which contains different respond 2. change scene according to choice flag

Here is how the code goes:

  1. The serializable script

    [System.Serializable] public class Dialog {

      [TextArea(1,2)]
         public string[] name;
     
         [TextArea(1,2)]
         public string[] chars;
     
         [TextArea(3,10)]
         public string[] sentence;
         
     }
    
    
    
  2. The dialogue manager (overview)

      //these queue to list all the entries
         private Queue<string> sentences;
         private Queue<string> nama;
         private Queue<string> chara;
     
         public Dialog dial; //calling the serializable class
     
          void Start()
          {
             sentences = new Queue<string>();
             nama = new Queue<string>();
             chara = new Queue<string>();
             StartDialog (dial);
         }
     
         //starting the dialogue system by clearing any previous dialogue
         public void StartDialog(Dialog Dialog)
          {
             nama.Clear ();
             foreach (string nama in Dialog.name) {
                 namas.Enqueue (nama);
             }
             sentences.Clear();
             foreach (string sentes in Dialog.sentence) {
             sentences.Enqueue(sentes);
             }
             chara.Clear ();
             foreach (string chars in Dialog.chars) {
                 chara.Enqueue (chars);
             }
             DisplayNextSentes();
         }
     
         //taking out all line from the queue
         public void DisplayNextSentes()
         {
             //if all sentence, name, and chars line finished, go to end dialogue
             if(sentences.Count == 0 && nama.Count==0&&chara.Count==0)
             {
                  EndDialog();
                  return;
              }
             //otherwise dequeue the queue
             string sentes = sentences.Dequeue();
             string nama = nama.Dequeue ();
             string chars = chara.Dequeue ();
         }
     
         void EndDialog()
         {
             //The end dialogue is still in unfinished, it's also the problem but I prioritize the choices first
             FindObjectOfType<ChangeScene>().changeScene("Prologue2");
         }
    
    

As you can see, we tried to use the queue method. It works to make basic conversation in general, but when it comes to choices, we don't have the place to put option and locating the lines for every choice chosen.

Thank you in advance!

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

0 Replies

· Add your reply
  • Sort: 

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

151 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

Related Questions

How do i change script in one scene without changing it in all the scenes 1 Answer

npc dialogue 0 Answers

Dialogue System only plays the same words 1 Answer

Polymorphism for decisions in a dialogue editor 1 Answer

Why is my coroutine skipping a method? 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