Problems loading a saved gameObject
Posted: Tue Sep 17, 2019 5:41 pm
Hello Folks! I hope this is the right Thread to ask for help on an error that i aparrently don't understand!
In my Scene I have an inventory that contains gameObjects that are loaded from a prefab. I wanted to save the whole gameObject with all its components and children, ticked the "save Gameobject children" box and at first glance it seemd to work...
When I want to load the game object however, I get this error
I see that It has some trouble with a recttransform component which is on the gameobject but I thought saving the game object would save all component...?
This is my code
The GameObject is on a UI Canvas with a Rect transform, canvas renderer, Image, Grid layout Group and an Event Trigger on it. Its not even about this object but about ist children! The childrne are instanciated on run time whenever I pick up something and my idea was to save this gameobject with its children components and then instanciate the children on start again! But... I cant even load the original game object, not even in a Debug function and I see that it has to do something with thre rectTransform or better say the components on it but why is that a problem and how can I solve it?
Thanks in advance, Anna
In my Scene I have an inventory that contains gameObjects that are loaded from a prefab. I wanted to save the whole gameObject with all its components and children, ticked the "save Gameobject children" box and at first glance it seemd to work...
When I want to load the game object however, I get this error
Code: Select all
InvalidCastException: Specified cast is not valid.
ES3Types.ES3Type_RectTransform.ReadComponent[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_RectTransform.cs:36)
ES3Types.ES3ComponentType.ReadUnityObject[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ComponentType.cs:36)
ES3Types.ES3UnityObjectType.ReadObject[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3UnityObjectType.cs:79)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:41)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:35)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:244)
ES3Types.ES3ArrayType.Read (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ArrayType.cs:58)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:240)
ES3Reader.Read[T] () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:98)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:161)
ES3Types.ES3ObjectType.ReadInto[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:64)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:128)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:41)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:244)
ES3Types.ES3ArrayType.Read (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ArrayType.cs:58)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:240)
ES3Reader.Read[T] () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:98)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:158)
ES3Types.ES3ObjectType.ReadInto[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:64)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:128)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:41)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:244)
ES3Types.ES3ArrayType.Read (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ArrayType.cs:58)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:240)
ES3Reader.Read[T] () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:98)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:158)
ES3Types.ES3ObjectType.ReadInto[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:64)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:128)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:41)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:244)
ES3Reader.Read[T] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:162)
ES3.Load[T] (System.String key, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:269)
ES3.Load[T] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:240)
SaveSystem.Start () (at Assets/Scripts/SaveSystem/SaveSystem.cs:44)
This is my code
Code: Select all
public void start()
{
if(ES3.KeyExists("Inventory"))
{
ES3.LoadInto<GameObject>("Inventory", InventorySystem.Instance.inventoryCollector);
}
}
private void OnApplicationQuit()
{
ES3.Save<GameObject>("Inventory", InventorySystem.Instance.inventoryCollector);
}
The GameObject is on a UI Canvas with a Rect transform, canvas renderer, Image, Grid layout Group and an Event Trigger on it. Its not even about this object but about ist children! The childrne are instanciated on run time whenever I pick up something and my idea was to save this gameobject with its children components and then instanciate the children on start again! But... I cant even load the original game object, not even in a Debug function and I see that it has to do something with thre rectTransform or better say the components on it but why is that a problem and how can I solve it?
Thanks in advance, Anna