Variable increments when I press any button, not the ones I want to.
Re: Variable increments when I press any button, not the ones I want to.
Once you get it set up, I think you'll find that the final setup is quite simple.
What exactly do you want to happen?
What exactly do you want to happen?
Re: Variable increments when I press any button, not the ones I want to.
1. I created a quest about collecting (clicking on specific UI buttons in the scene) objects.
2. I defined a variable to track the quest's progress.
3. The user is entering a dialogue that starts a quest. It works.
4. The user needs to go to another scene and click on specific buttons to influence the variable.
5. When they clicked on enough buttons then they can go back to the quest giver and finish the quest.
The problem is that if I click on the wrong button (not flower ) under FlowerFields 2 component, under Canvas obviously, the variable is incremented as well.
Let me know if sth is unclear.
2. I defined a variable to track the quest's progress.
3. The user is entering a dialogue that starts a quest. It works.
4. The user needs to go to another scene and click on specific buttons to influence the variable.
5. When they clicked on enough buttons then they can go back to the quest giver and finish the quest.
The problem is that if I click on the wrong button (not flower ) under FlowerFields 2 component, under Canvas obviously, the variable is incremented as well.
Let me know if sth is unclear.
Re: Variable increments when I press any button, not the ones I want to.
What is the purpose of the UI buttons?
Do you want to increment the variable when the player clicks the green area (not UI button) or when the player clicks a UI button?
Do you want to increment the variable when the player clicks the green area (not UI button) or when the player clicks a UI button?
Re: Variable increments when I press any button, not the ones I want to.
Rather UI button.
I hope it is obvious that the flower in the green area is also a button.
I hope it is obvious that the flower in the green area is also a button.
Re: Variable increments when I press any button, not the ones I want to.
Got it. Then remove the Selector component. On the flowers, remove the Dialogue System Trigger and Usable components.
Keep the Increment On Destroy component.
Configure the Button's OnClick() event to disable the GameObject.
Keep the Increment On Destroy component.
Configure the Button's OnClick() event to disable the GameObject.
Re: Variable increments when I press any button, not the ones I want to.
I did all of it and the effect was the same. BUT! I found out that if I will set on the component "Increment On Destroy" Increment On "destroy" the thing is reacting on the button that takes us to another scene because it is destroyed. If Increment On is disabled, it interacts with anything that can be disabled, so with all the buttons on the scene. So it affect all the objects in the scene that cointains the script.
There needs to be a way to define objects that Increment On Destroy interprets only specific objects. I tried to do it here:
But it does not work...
There needs to be a way to define objects that Increment On Destroy interprets only specific objects. I tried to do it here:
But it does not work...
Re: Variable increments when I press any button, not the ones I want to.
Hi,
Your UI Button's OnClick() event should deactivate a GameObject (i.e., the flower containing that UI Button). The Increment On Destroy component should be on that GameObject.
Also, see How to: Change Scenes..
Your UI Button's OnClick() event should deactivate a GameObject (i.e., the flower containing that UI Button). The Increment On Destroy component should be on that GameObject.
Also, see How to: Change Scenes..
Re: Variable increments when I press any button, not the ones I want to.
Yes, I have exactly that setup.
My objects are appearing and disappearing exactly as I want. I have no problem with it.
Increment On Destroy is also on the object I want to use to influence my variable. But as I said, each UI button in the scene is influencing Increment On Destroy script. That is my problem.
I appreciate your help but it seems to miss my difficulty here.
My objects are appearing and disappearing exactly as I want. I have no problem with it.
Increment On Destroy is also on the object I want to use to influence my variable. But as I said, each UI button in the scene is influencing Increment On Destroy script. That is my problem.
I appreciate your help but it seems to miss my difficulty here.
Re: Variable increments when I press any button, not the ones I want to.
Increment On Destroy must be on the object that has the UI Button and that you are deactivating. Here's an example scene:
DS_TestPickFlowers_2021-02-21.unitypackage
The Flower is set up like this:
DS_TestPickFlowers_2021-02-21.unitypackage
The Flower is set up like this:
Re: Variable increments when I press any button, not the ones I want to.
Thank you for creating the scene. Yes, it works in your example.
My buttons are set up exactly like yours, but it is not working. Probably the problem is somewhere else... Maybe I changed some setups or... I have no clue.
I will try to rebuild the scene tomorrow. If it will help, I will let you know.
Thanks for your effort!
My buttons are set up exactly like yours, but it is not working. Probably the problem is somewhere else... Maybe I changed some setups or... I have no clue.
I will try to rebuild the scene tomorrow. If it will help, I will let you know.
Thanks for your effort!