Auto Save: GUI + component parameters

Discussion and help for Easy Save 3
Post Reply
pupazze
Posts: 2
Joined: Mon Jan 21, 2019 2:39 pm

Auto Save: GUI + component parameters

Post by pupazze »

hi, I got a question about the auto save feature. I added just Easy Save 3 to my project and enabled the auto save feature, so the Object "Easy Save 3 Manager" was added to my scene with the 3 components ES3 inspector, Auto Save Mgr & Reference Mgr.

As I understand, everything listed in the Reference Mgr. should be saved automatically, right? I also checked the Reference Mgr list - all my sliders I want to save are included in the list. But just to be sure I also added the ES3 Auto Save script to the objects I want to save. No success.

Some more details: in my project there are several GUI objects with sliders and toggles which activates components or change component parameters. But none of these details are saved. Just the movement of some 3D objects are saved correctly, but the GUI and the changed components parameters are not saved. Any idea what I could doing wrong?

Tnx pupazze
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Auto Save: GUI + component parameters

Post by Joel »

Hi there,

The reference list is not a list of object which will be saved. Only GameObjects with an ES3AutoSave component will be saved, and their supported Components.

Please see the Auto Save guide for information on how to use Auto Save: https://docs.moodkie.com/easy-save-3/es ... hout-code/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
pupazze
Posts: 2
Joined: Mon Jan 21, 2019 2:39 pm

Re: Auto Save: GUI + component parameters

Post by pupazze »

hi Joel,
thanks for your reply, but https://docs.moodkie.com/easy-save-3/es ... hout-code/ is exactly the doc I used to understand how it works. For example the transform settings of my 3d objects are saved. But not the settings of my toggle and slider panels. So it seams my needed properties are not supported by default.

I tried a little bit around and found this doc https://docs.moodkie.com/easy-save-3/es ... -es3types/ - so I used this to activate my needed properties:

* Toggle > Properties > isOn
* Slider > Properties > value

For the first run everything works now as expected. After that, my Toggle and Slider components are broken:

Code: Select all

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.UI.Toggle.Set (System.Boolean value, System.Boolean sendCallback) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:275)
UnityEngine.UI.Toggle.Set (System.Boolean value) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:248)
UnityEngine.UI.Toggle.set_isOn (System.Boolean value) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:242)
UnityEngine.UI.Toggle.InternalToggle () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:308)
UnityEngine.UI.Toggle.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Toggle.cs:319)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update()
The easy save types settings give me also the following hint:

Code: Select all

This type has no public parameterless constructors.

To support this type you will need to modify the ES3Type script to use a specific constructor instead of the parameterless constructor.

Code: Select all

using System;
using UnityEngine;

namespace ES3Types
{
	[ES3PropertiesAttribute("toggleTransition", "graphic", "onValueChanged", "isOn")]
	public class ES3Type_Toggle : ES3ComponentType
	{
		public static ES3Type Instance = null;

		public ES3Type_Toggle() : base(typeof(UnityEngine.UI.Toggle))
		{
			Instance = this;
		}

		protected override void WriteComponent(object obj, ES3Writer writer)
		{
			var instance = (UnityEngine.UI.Toggle)obj;
			
			writer.WriteProperty("toggleTransition", instance.toggleTransition);
			writer.WritePropertyByRef("graphic", instance.graphic);
			writer.WriteProperty("onValueChanged", instance.onValueChanged);
			writer.WriteProperty("isOn", instance.isOn, ES3Type_bool.Instance);
		}

		protected override void ReadComponent<T>(ES3Reader reader, object obj)
		{
			var instance = (UnityEngine.UI.Toggle)obj;
			foreach(string propertyName in reader.Properties)
			{
				switch(propertyName)
				{
					
					case "toggleTransition":
						instance.toggleTransition = reader.Read<UnityEngine.UI.Toggle.ToggleTransition>();
						break;
					case "graphic":
						instance.graphic = reader.Read<UnityEngine.UI.Graphic>();
						break;
					case "onValueChanged":
						instance.onValueChanged = reader.Read<UnityEngine.UI.Toggle.ToggleEvent>();
						break;
					case "isOn":
						instance.isOn = reader.Read<System.Boolean>(ES3Type_bool.Instance);
						break;
					default:
						reader.Skip();
						break;
				}
			}
		}
	}

	public class ES3Type_ToggleArray : ES3ArrayType
	{
		public static ES3Type Instance;

		public ES3Type_ToggleArray() : base(typeof(UnityEngine.UI.Toggle[]), ES3Type_Toggle.Instance)
		{
			Instance = this;
		}
	}
}
Is this my problem? If so could you please tell me what to do with the ES3Type script? tnx pupazze
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Auto Save: GUI + component parameters

Post by Joel »

Hi there,

I'm afraid it's not possible to understand what is happening from what you've said. Please could you create a new project which replicates the issue (with only the minimum required to replicate the issue) and PM it to me?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply