little problem with Button UI

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Frioniel
Posts: 13
Joined: Fri Sep 22, 2017 9:25 am

little problem with Button UI

Post by Frioniel »

Hi,

I'm making text adventure game.

What I'm going to do is,

If I click the button(Unity.UI button),

the Gameobject that contains Conversation Trigger component(On Enable Setting) will appear.

and Dialogue event will activate.

when I click the button

Gameobject appears well....

but the problem is...

Conversation Trigger component disappears itself!

Well.. I can't understand why the component destroys itself.

Is there any special setting for Unity UI Button?

p.s Thanks for your time.
-----------------------------------------------------------------------------------
To add

I just write the script for the button like this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SetActiveUI : MonoBehaviour
{
public GameObject GO;

public void OnClick()
{
{
GO.SetActive(true);

}
}
}

and setting for the button.

Image
Attachments
2.png
2.png (24.42 KiB) Viewed 643 times
Last edited by Frioniel on Sat Nov 04, 2017 11:18 am, edited 1 time in total.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: little problem with Button UI

Post by Tony Li »

Hi,

Did you tick the "Once" checkbox? This destroys the Conversation Trigger after it's used once.
Frioniel
Posts: 13
Joined: Fri Sep 22, 2017 9:25 am

Re: little problem with Button UI

Post by Frioniel »

Oh... I think I forgot to turn off the Once function.

But..

still there's the problem :(

Dialogue event doesn't work even if Conversation trigger exists.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: little problem with Button UI

Post by Tony Li »

Is the Conversation Trigger's Trigger dropdown set to OnEnable?

If you inspect it at runtime after clicking the UI button, does the Condition section say True or False?
Frioniel
Posts: 13
Joined: Fri Sep 22, 2017 9:25 am

Re: little problem with Button UI

Post by Frioniel »

Yep! I checked several times that dropdown set to the OnEnable.

and I don't get it what's the last sentence means.

Does it mean, while playing the game, does console window show the error?

if it is right, well... there's no error in console window (Currently debug level in dialogue manager is info setting)

and I didn't handle anything in condition section. (It means, condition section is empty)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: little problem with Button UI

Post by Tony Li »

Here's an example scene:

ButtonGameObjectConversationExample_2017-11-05.unitypackage

This is how I set it up:

1. Created an empty GameObject named "Conversation GameObject" with a Conversation Trigger set to OnEnable, and deactivated the GameObject:

Image

2. Created a UI button. Instead of using a script, I configured the OnClick() event to activate "Conversation GameObject" and make the UI button non-interactive:

Image

3. When "Conversation GameObject" becomes active, the Conversation Trigger checks if it should run. Since the Condition is empty, it's always true:

Image
Frioniel
Posts: 13
Joined: Fri Sep 22, 2017 9:25 am

Re: little problem with Button UI

Post by Frioniel »

Hello

I tried as your guide

If I click the button, then the GameObject is active well

But...

stilll the conversation event doesn't work :cry:

is there another setting for conversation event?

-----------------------------------------
Try to do
1. Button Click -> GameObject becomes active -> then Conversation Event (Database) works.

Current
1. Button Click (Clear :D ) -> Gameobject becomes active (Clear :D ) -> then Conversation Event works. (Not Clear:cry: )
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: little problem with Button UI

Post by Tony Li »

When you do this, inspect the Conversation Trigger. Does its condition say (Last Check: True) or (Last Check: False)?

If you set the Dialogue Manager's Debug Level to Info, does the Console window show anything when you click the button? Look for a line such as:

Code: Select all

Dialogue System: Starting conversation 'title'...
Does the example scene (in my previous reply) work for you?

Please feel free to send an example project to tony (at) pixelcrushers.com. I'll be happy to take a look.
Post Reply