Forum rules - please read before posting.

Scene switching stopped working properly

I had scene switching set up properly and after that started working on making sure that everything that needed to be saved (animations, visibility, hotspots, etc) was saved properly. Now when I go from scene 1 to scene 2 it works (scene 2 has no saving scripts yet) but when I come back to scene 1 I get an error (posted on the bottom of this message) and the game just puts the player at the 0,0,0 position instead of any player start which keeps the camera from fading in. I am no programmer so I can't make anything out of this error. Hope somebody here can tell me what's going on. In the meantime I will start evaluating all the added save components starting with the 'remember animator' ones. 

Error Message:
InvalidOperationException: <VisibilityData xmlns=''> was not expected
System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadRoot (System.Xml.Serialization.XmlTypeMapping rootMap)
System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadRoot ()
System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.Serialization.XmlSerializationReader reader)
Rethrow as InvalidOperationException: There is an error in XML document.
System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.Serialization.XmlSerializationReader reader)
System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.XmlReader xmlReader)
System.Xml.Serialization.XmlSerializer.Deserialize (System.IO.Stream stream)
AC.Serializer.DeserializeObjectXML[AnimatorData] (System.String pXmlizedString) (at Assets/AdventureCreator/Scripts/Save system/Serializer.cs:354)
AC.Serializer.DeserializeObject[AnimatorData] (System.String dataString) (at Assets/AdventureCreator/Scripts/Save system/Serializer.cs:234)
AC.Serializer.LoadScriptData[AnimatorData] (System.String dataString) (at Assets/AdventureCreator/Scripts/Save system/Serializer.cs:665)
AC.RememberAnimator.LoadData (System.String stringData) (at Assets/AdventureCreator/Scripts/Save system/RememberAnimator.cs:56)
AC.ConstantID.LoadData (System.String stringData, Boolean restoringSaveFile) (at Assets/AdventureCreator/Scripts/Save system/ConstantID.cs:75)
AC.LevelStorage.SendDataToScene (AC.SingleLevelData levelData, Boolean restoringSaveFile, AC.SubScene subScene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:136)
AC.LevelStorage.ReturnCurrentLevelData (Boolean restoringSaveFile) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:77)
AC.SceneSettings.OnStart () (at Assets/AdventureCreator/Scripts/Game engine/SceneSettings.cs:107)
AC.MultiSceneChecker.Start () (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:72)

Comments

  • Okay, so I had a 'remember visibility' component and a 'remember animator' component on the same object which probably caused the error cause since I removed the 'remember animator' scene switching works again as expected. So is it impossible for an object to remember both states or should both settings (visibility and animator) get different constant ID's? It automatically sets the same ID for both settings when adding a second remember component.
  • edited June 2017
    The error is indeed pointing to the Remember Animator component.  Does it work if you separate them (i.e. have another Animator object with a Remember Animator without any other one).

    If need be, you could animate the visibility of the object within the Animator as well, but there shouldn't generally be an issue with having two Remember components on the same object.

    What version are you using, and what platform are you building to?
  • I've recreated this in iOS, so assuming that's what you're using, try this:

    Open Serializer.cs, and replace the function DeserializeObjectXML with the following:

    private static object DeserializeObjectXML <T> (string pXmlizedString)
    {
        XmlSerializer xs = new XmlSerializer (typeof (T));
        MemoryStream memoryStream = new MemoryStream (StringToUTF8ByteArray (pXmlizedString));

        try
        {
            object deserializedObject = xs.Deserialize (memoryStream);
            if (deserializedObject is T)
            {
                return (T) deserializedObject;
            }
        }
        catch {}
        return null;
    }


    That fixes it on my end.  How about you?
  • Hi Chris, thanks for the reply! I hope to have some time to try this out this evening, although I am a bit anxious to start copying and pasting stuff in your code for it is all magic to me ;) But hey, I did set up GIT so I can screw stuff up! I'll give an update as soon as I tried it.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.