save button state?

This is the place to find out how to accomplish something specific with EZ Game Saver.

save button state?

Postby sharmoni » Mon Aug 16, 2010 2:45 am

I would like to save the state of some of my toggle buttons (UIStateToggleBtn), but I'm not seeing that property in the GameDataSaver inspector. Is that possible to do?
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: save button state?

Postby Brady » Mon Aug 16, 2010 8:31 pm

Yes, with a slight modification of the UIStateToggleBtn.cs file, I think we can get that working just fine. Add the following to the StateNum property:
Code: Select all
set { SetToggleState(value); }


Then the StateNum property should appear in the inspector for the GameDataSaver. Just check that and that should do it.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: save button state?

Postby sharmoni » Tue Aug 17, 2010 12:29 am

Awesome! That's exactly what I needed. It works great. Thanks, Brady.
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: save button state?

Postby sharmoni » Tue Aug 17, 2010 1:03 am

I added a similar line to the UIButton.cs file to see if it would work, and it seems to do what I expected—namely save whether the button is active or disabled:
Code: Select all
   public CONTROL_STATE controlState
   {
      get { return m_ctrlState; }
      set { SetControlState(value); }
   }
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: save button state?

Postby sharmoni » Sat Sep 11, 2010 10:45 pm

This is only working when I'm running in the editor. When I load my build on the iPad the buttons are always in the default state after restarting.
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: save button state?

Postby Brady » Sun Sep 12, 2010 4:09 am

This sounds like it is likely related to the .NET 2.0/2.1 implementation glitch mentioned on the product page. Unity is presently looking into it, but it affects reflection of properties. While it worked just fine in .NET 1.1, the 2.1 .NET implementation somehow broke it. I don't know why they couldn't have just carried the working code over from the iOS .NET 1.1 implementation, but for whatever reason, it's broken in the iOS 2.0/2.1 implementation. It works fine on all other platforms, and even works on iOS using .NET 1.1. Just not iOS 2.0/2.1. And reflecting fields works in all cases, just not properties on iOS with .NET 2.0/2.1. In the meantime, I'm seeing if there is some kind of work-around.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: save button state?

Postby sharmoni » Sun Sep 12, 2010 5:02 am

The state values are being successfully saved as script variables in my game scripts, just not as StateNum for the buttons. Can I change the state of the buttons on initialization from code using those saved values? So far I've only been able to change button states by actually pressing them.
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: save button state?

Postby Brady » Mon Sep 13, 2010 6:08 am

Yes, if you're using the latest version of EZ GUI, SetControlState() is now public. So you can do:

mButton.SetControlState(UIButton.OVER);
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: save button state?

Postby sharmoni » Tue Sep 14, 2010 1:31 am

Do you mean version 1.05_b3 or 1.1_b9?
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: save button state?

Postby Little Angel » Tue Sep 14, 2010 6:55 am

1.05b3 is the most up to date.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Next

Return to EZ Game Saver How to...

Who is online

Users browsing this forum: BobbyMam, liny195 and 2 guests

cron