playMaker

Author Topic: Deactivated button is active again after level load [SOLVED]  (Read 1341 times)

marvoc

  • Playmaker Newbie
  • *
  • Posts: 37
Deactivated button is active again after level load [SOLVED]
« on: March 07, 2019, 07:00:11 AM »
Hello all:)
 I have only short question.
I have Shop scene when, after selling an item, Im deactivating its Buy button. This is working, but when I come again back from other scene, button is active again.
What I should do, to keep button deactivated?

Thanks :)
« Last Edit: March 09, 2019, 03:57:45 PM by marvoc »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Deactivated button is active again after level load
« Reply #1 on: March 07, 2019, 11:01:53 AM »
Hi.
you will need to save it.

you can save an int using playerprefs but its better you purchase easy save (asset store) and save as a bool.

PlayerPrefs is very 'Hackable' and limited

When using playerprefs :

On the start of you game, check if the save reference (key) exists by using 'PlayerPrefs Has Key'

if it does not exists.
Create by using 'PlayerPrefs Set Int'. and set value to 0

Then go back to the state where you check if exists.

if it does exist.
Go next state.

in next state get the int value by using 'PlayerPrefs Get Int'
then do an int compare.
if int is equal to one disable the button.

on the buy state, where you deactivate when purchase is done ,
Use 'PlayerPrefs Set Int' and set it to 1.

The 'Key' should be the same on all actions as it is the reference to the variable.

i hope this helps.

marvoc

  • Playmaker Newbie
  • *
  • Posts: 37
Re: Deactivated button is active again after level load
« Reply #2 on: March 08, 2019, 03:23:02 PM »
Hi, thank you for nice answer.
I tried to do it over PlayerPrefs, but I cant get no int to the (Key). Really doesnt make sence :)
I understand that if I dont have any defined Key, I have to created one, but I dont get there. So Im not sure what Im doing wrong.

Picture as attachment.


marvoc

  • Playmaker Newbie
  • *
  • Posts: 37
Re: Deactivated button is active again after level load
« Reply #3 on: March 09, 2019, 03:57:07 PM »
Ha sorry, I downloaded an example from this thread and now I understand correctly. That Key isnt by itself a variable to me. But variable is a Key -> value within it.
:)

nmillett

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Deactivated button is active again after level load [SOLVED]
« Reply #4 on: March 10, 2019, 01:50:16 AM »
Can you post a screenshot of the correct setup with playmaker?  This would be very useful for me in a similar scenario trying to disable a canvas component.