Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
avatar image
0
Question by AlejandroBoss10 · Jun 28, 2018 at 03:31 AM · child objectparent-childindexdialoguedisable object

Dialogue system with index, children, and parent.

What I want is that when I press Y, the current gameobject deactivates and the gameobject below it activates. Then when the last gameobject is reached and Y is pressed, the parent is deactivated. I'm trying to make a Text panel similar to that of Harvest Moon 64 or any other game actually. Where the NPC talks in like 3-4 boxes and then it disappears. It's more like a dialogue box.

Hey there everyone, I need help with something that I think is pretty easy to do, but it has me stumped. So what I'm trying to achieve is a dialogue sequence. The way I'm doing this is by having one parent gameobject that holds all the UI Text elements. I have DialogueSequence1 as the parent which holds all the UI Text elements as children and they're called TextPanel_1, TextPanel_2, etc. There's going to be a varying amount of these TexPanels and what I want is that when the player presses Y, the TextPanel that is currently active now, deactivates and the next TextPanel below it in the hierarchy activates and so on and so forth. I'm guessing that the easiest way to do this would be with some sort of index type of code, but I am not familiar with how to do that, and the internet isn't being too helpful. To give you an idea, think of pressing the A button to move onto what the NPC is going to say next in any game. That's what I'm trying to achieve. Here's a model: NPC talks --> Player presses Y --> Next dialogue panels appears while the previous one deactivates --> so on and so forth until the last one --> on the last dialogue panel, the parent deactivates. This should work with just one text panel as well, if not I'll adjust. I have some code that I wrote and this is it. Feel free to work off of that if you'd like.

 public GameObject ObjectToDisable;
 public GameObject ObjectToEnable;
 public GameObject TextParentToDisable;

 public int TextCounterMax; //This should be how many text panels you have
 int TextCounter; // Don't forget that this only happens when the GameObject is actually active

 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Y))
     {
         NextPanel();
     }

     if (TextCounter >= TextCounterMax)
     {
         TextParentToDisable.SetActive(false);
     }
 }

 public void NextPanel()
 {
     ObjectToDisable.SetActive(false);
     ObjectToEnable.SetActive(true);
     TextCounter += 1;
     Debug.Log(TextCounter);
 }
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

88 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

Related Questions

How do you call child in group of elements? 2 Answers

child not moving with parent 4 Answers

Dialogue problems? 1 Answer

How to make throwable child object? 0 Answers

when i make a gameobject child of another gameobject, then it's scale and rotation both changes in a very wierd manner. 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