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 /
  • Help Room /
avatar image
0
Question by Cerasus13 · Jan 31 at 10:29 AM · messageide

How do I Scene Switch after Dialogue is finished,How do I change Scene after the Dialogue is finished?

So I was doing a 3D platformer with some Dialogue sometimes when you start or finish a Level. So I need to Change Scene to the next Level after the Dialogue. So here I got the Dialogue Trigger, that is set to an Invisible Box and in another Script, triggers with an OnCollisionEnter when the Player hits the Box Collider. I might just be dumb and you can't Array a Bool, but the IDE would have told me right? Please help!

 using UnityEngine;
 
 public class DialogueTrigger : MonoBehaviour
 {
     public Message[] messages;
     public Actor[] actors;
     public Changescene[] change;
 
     public void StartDialogue()
     {
         FindObjectOfType<DialogueManager>().OpenDialogue(messages, actors, change);
     }
 }
 
 [System.Serializable]
 public class Message
 {
     public int actorID;
     [TextArea(3, 10)]
     public string message;
 }
 
 [System.Serializable]
 
 public class Actor
 {
     public string name;
     public Sprite sprite;
 }
 
 [System.Serializable]
 public class Changescene
 {
     public bool change;
     public string levelName;
 }

And here is the Manager if the Dialogue itself, and what is giving me the trouble. I have a Textbox with Name of the Character, a Sprite or small Pic of him, and the Text itself. The Idea is to in the Trigger, put if you want to Change Scene After, and write the Name of the new one down. And that works, but I can't figure out what is wrong with me calling upon the changed stuff.

 using UnityEngine;
 using UnityEngine.SceneManagement;
 using UnityEngine.UI;
 using Image = UnityEngine.UI.Image;
 
 public class DialogueManager : MonoBehaviour
 {
     public Image actorImage;
     public Text actorName;
     public Text messageText;
     public RectTransform backgroundBox;
 
     private Message[] _currentMessages;
     private Actor[] _currentActors;
     private int _activeMessages;
     private static bool _isActive;
     private Changescene[] _changescenes;
 
     public void OpenDialogue(Message[] messages, Actor[] actors, Changescene[] changescenes)
     {
         _currentMessages = messages;
         _currentActors = actors;
         _activeMessages = 0;
         _isActive = true;
         _changescenes = changescenes;
 
         Debug.Log("Dialogue started, there are messages: " + messages.Length);
         DisplayMessage();
 
         backgroundBox.LeanScale(Vector3.one, 0.5f).setEaseInOutExpo();
     }
 
     private void DisplayMessage()
     {
         Message messageToDisplay = _currentMessages[_activeMessages];
         messageText.text = messageToDisplay.message;
 
         Actor actorToDisplay = _currentActors[messageToDisplay.actorID];
         actorName.text = actorToDisplay.name;
         actorImage.sprite = actorToDisplay.sprite;
         
     }
 
     private void NextMessage()
     {
         _activeMessages++;
         if (_activeMessages < _currentMessages.Length)
         {
             DisplayMessage();
         } else {
             Debug.Log("Dialogue Finished");
             _isActive = false;
             Changescene checkswitch = _changescenes.change;
             Changescene sceneChangedToo = _changescenes.levelName;
             if (checkswitch == true)
             {
                 SceneManager.LoadScene(sceneChangedToo);
             }
         }
     }
 
     private void Update()
     {
         if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0) && _isActive)
         {
             NextMessage();
         }
     }
 }
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

173 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

Related Questions

[Unet] How to Use SendBytesToPlayer? 1 Answer

Problem with reading text in Unity IDE. 0 Answers

Standalone disable crash message 1 Answer

Last message won't leave screen.,Only one message won't delete after 2 seconds all others do. 0 Answers

Display a message on lock screen - iOS 0 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