Forum rules - please read before posting.

Avatar/portraits not saving

Hello,
I've got a problem with the avataras. The problem is simple: we save the game but the avatars are not the one it should be (right before de save). I've checked the forum and the Manual and I noticed there is no "remember" for portraits.

1) I've read I need to create a "Resources" folder under Assets and throw there the portaits (the files). That way I don't have to re-link them again. The character has two just to test it out. Even if I relink them, nothing new happens.

2) Yes, they have a unique name for each one: "Leone - 01" , "Leone - 02" etc. There are no two avatars with the same.

I save the game, return to main menu, load, everything works! Even without the Resources folder.
The problem is that if I quit the game or stop, the avatar which shows is "the last one" I used, and not the correct one.
We don't have that many so performance is not an issue. The thing is that I'm not sure what else I'm missing... maybe on the prefab part?

Thanks for any support on this. I might be missing something...

Comments

  • I may have omitted some info on how we created this logic. We have two avatars depending on where the character is. A Trigger makes the avatars flip (it's just another image, different name). This flips the avatars and locations from left to right and viceversa and does the same for NPCs. The logic works flawlessly. This doesn't involve expressions. It's just another file. The problem occurs only with the picture it loads: it's the, let's say, default. Even if I remove the default, it always gives me the one that comes from the Cutscene (for example, player on the left). Now, the positions, they are loaded perfectly! If the character is on the right, then it knows it's on the right, and the NPC is on the left. The problems are the pictures it uses: always wrong.

    Hope this clarifies a bit on how to approach this issue.
    Thanks a lot.
    AC: Latest version
    Unity 2020.3.27 (willing to upgrade soon if the game works).

  • You can find a script on the AC wiki to assist with this here:
    https://adventure-creator.fandom.com/wiki/Portrait_graphics_-_saving

  • Hello! Thanks. Yes, I tried that before posting, but it didn't work. After a couple of hours testing stuff I believe the triggers are overwriting some saved values upon loading a gamesave if they are triggered afterwards in a new game.

    Video: https://www.veed.io/view/001f6a8c-f503-497d-ac74-2e74ff66b4ce?sharingWidget=true

    Short explanation: I have 4 menus: one for Main Character Left, one for Right and the same for NPC. When I lock one, I unlock the other, and at the same time I assign a new avatar. In this scenario I have the General X, an NPC which will look to where the main character is. In second 45+ you can see both triggers: Each trigger locks the unused menus and unlocks the correct ones, and assigns the new avatar. Plus it renames the characters so they match the menu. Nothing fancy.

    The main character in that scenario starts on the Right so his avatar looks to the left. If he passes through the General, he will look right in his avatar (trigger). I save right there! If I load "without stopping Unity", then it works just fine.

    Problem? If I stop (or if I build the game and just quit) and then restart the stage (not yet loading the savestate) and trigger the opposite trigger, then it will "save" that avatar's value. I can load the previous gamestate and there you can see the avatar is flipped. To recap: if I load within the game the avatars work. If I quit and trigger them again from a "new game" they are lost.

    My guess is that the "new game" or new start overwrites something related to avatars because it's the only scenario in which it doesn't save a value.
    Also! you may not hava noticed but the animator has a remember animator. It didn't also save the "face direction". At least that was easy to fix.
    Anyways, I hope the problem is clear now.

    Thank you very much

  • The behaviour shown in the video suggests that the Remember Portrait component is not loading correctly - I don't see any issues with the Triggers / Actions.

    Replace the script with the following, which prints messages into the Console when saving/loading. What does it show?

    using UnityEngine;
    #if AddressableIsPresent
    using System.Collections;
    using UnityEngine.ResourceManagement.AsyncOperations;
    using UnityEngine.AddressableAssets;
    #endif
    
    namespace AC
    {
    
        [AddComponentMenu ("Adventure Creator/Save system/Remember Portrait")]
        public class RememberPortrait : Remember 
        {
    
            private Char character;
    
            public override string SaveData ()
            {
                PortraitData portraitData = new PortraitData ();
                portraitData.objectID = constantID;
                portraitData.savePrevented = savePrevented; 
    
                if (Character)
                { 
                    portraitData.portraitGraphic = AssetLoader.GetAssetInstanceID (Character.portraitIcon.texture);
                    Debug.Log ("Saved character " + Character + " portrait graphic: " + portraitData.portraitGraphic);
                } 
                return Serializer.SaveScriptData<NameData> (portraitData);
            }
    
            public override void LoadData (string stringData)
            {
                PortraitData data = Serializer.LoadScriptData<PortraitData> (stringData);
                if (data == null) return;
    
                SavePrevented = data.savePrevented;
                if (savePrevented) return;
    
                if (Character && !string.IsNullOrEmpty (data.portraitGraphic))
                {
                    #if AddressableIsPresent
                    if (KickStarter.settingsManager.saveAssetReferencesWithAddressables)
                    {
                        StartCoroutine (LoadDataFromAddressables (data));
                    }
                    else 
                    #endif
                    {
                        Character.portraitIcon.ReplaceTexture (AssetLoader.RetrieveAsset (Character.portraitIcon.texture, data.portraitGraphic));
                        Debug.Log ("Loaded " + Character + " portrait graphic. Saved: " + data.portraitGraphic + ", Assigned: " + Character.portraitIcon.texture);
                    } 
                }
            }
    
            #if AddressableIsPresent
    
            private IEnumerator LoadDataFromAddressables (PortraitData data)
            {
                AsyncOperationHandle<Texture> textureHandle = Addressables.LoadAssetAsync<Texture> (data.portraitGraphic); 
                yield return textureHandle;
                if (textureHandle.Status == AsyncOperationStatus.Succeeded)
                {
                    Character.portraitIcon.ReplaceTexture (textureHandle.Result);
                } 
                Addressables.Release (textureHandle); 
            }
    
            #endif
    
            private Char Character
            {
                get
                {
                    if (character == null) character = GetComponent <Char>(); 
                    return character;
                } 
            }
        }
    
    
        [System.Serializable]
        public class PortraitData : RememberData
        {
    
            public string portraitGraphic;
    
            public PortraitData ()
            { }
    
        } 
    }
    
  • Thanks! Unfortunately it doesn't save my player's Avatar. The NPC is saved, but not the player (though it is in the parent of the Player).
    The first part of the code is the "save". The second the "load" after hitting stop and then "play" again: it loads another avatar (check how it switches from 19 to 16)

    Saved character General X (NPC) (AC.NPC) portrait graphic: UnityEngine.Texture2DGeneral X Avatar - 16
    UnityEngine.Debug:Log (object)
    AC.RememberPortrait:SaveData () (at Assets/Noir Storm/Scripts/RememberPortrait.cs:26)
    AC.LevelStorage:PopulateScriptData (UnityEngine.SceneManagement.Scene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:761)
    AC.LevelStorage:SaveSceneData (AC.SubScene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:428)
    AC.LevelStorage:StoreAllOpenLevelData () (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:320)
    AC.SaveSystem:SaveSaveGame (int,bool,string) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:849)
    AC.SaveSystem:SaveGame (int,int,bool,bool,string) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:833)
    AC.ActionSaveHandle:PerformSaveOrLoad () (at Assets/AdventureCreator/Scripts/Actions/ActionSaveHandle.cs:223)
    AC.ActionSaveHandle:Run () (at Assets/AdventureCreator/Scripts/Actions/ActionSaveHandle.cs:69)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:455)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:597)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:597)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:597)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.RuntimeActionList:BeginActionList (int,bool) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:181)
    AC.ActionList:Interact (int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:273)
    AC.RuntimeActionList:DownloadActions (AC.ActionListAsset,AC.Conversation,int,bool,bool,bool) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:136)
    AC.AdvGame:RunActionListAsset (AC.ActionListAsset,AC.Conversation,int,bool,bool) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:242)
    AC.AdvGame:RunActionListAsset (AC.ActionListAsset,int,int) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:163)
    AC.MenuSavesList:RunActionList (int) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:957)
    AC.MenuSavesList:ProcessClick (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:856)
    AC.MenuElement:ProcessClickUI (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:265)
    AC.MenuSavesList/<>c__DisplayClass31_1:b__0 () (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:198)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

  • The "Load" part that changes from 19 to 16:

    Loaded General X (NPC) (AC.NPC) portrait graphic. Saved: UnityEngine.Texture2DGeneral X Avatar - 19, Assigned: General X Avatar - 16 (UnityEngine.Texture2D)
    UnityEngine.Debug:Log (object)
    AC.RememberPortrait:LoadData (string) (at Assets/Noir Storm/Scripts/RememberPortrait.cs:50)
    AC.LevelStorage:UnloadScriptData (System.Collections.Generic.List`1<AC.ScriptData>,UnityEngine.SceneManagement.Scene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:742)
    AC.LevelStorage:LoadSceneData (AC.SingleLevelData,AC.SubScene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:411)
    AC.LevelStorage:ReturnCurrentLevelData () (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:167)
    AC.SaveSystem:InitAfterLoad () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:667)
    AC.SaveSystem:ReceiveDataToLoad (AC.SaveFile,string) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:575)
    AC.SaveSystem:LoadSaveGame (AC.SaveFile) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:409)
    AC.SaveSystem:LoadGame (int,int,bool) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:325)
    AC.MenuSavesList:ProcessClick (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:866)
    AC.MenuElement:ProcessClickUI (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:265)
    AC.MenuSavesList/<>c__DisplayClass31_1:b__0 () (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:198)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

  • This doesn't look right - the data being loaded should match that being saved, even if it doesn't load correctly.

    Both logs are referencing the same save file? What data is listed if you find the NPC's save data in the Save File Manager?

  • Thanks. Here is a second try... but I guess it's exactly the same.
    The order is (first delete all saves and profiles). Play, trigger the left part so the player is facing right in his avatar and the General (NPC) to the left. Then quit the game. Play. Trigger the right trigger (NPC faces right, Player faces left). Load the game (the player's avatar should face right and NPC to the left. Results:

    Saved character General X (NPC) (AC.NPC) portrait graphic: UnityEngine.Texture2DGeneral X Avatar - 19
    UnityEngine.Debug:Log (object)
    AC.RememberPortrait:SaveData () (at Assets/Noir Storm/Scripts/RememberPortrait.cs:26)
    AC.LevelStorage:PopulateScriptData (UnityEngine.SceneManagement.Scene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:761)
    AC.LevelStorage:SaveSceneData (AC.SubScene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:428)
    AC.LevelStorage:StoreAllOpenLevelData () (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:320)
    AC.SaveSystem:SaveSaveGame (int,bool,string) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:849)
    AC.SaveSystem:SaveGame (int,int,bool,bool,string) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:833)
    AC.ActionSaveHandle:PerformSaveOrLoad () (at Assets/AdventureCreator/Scripts/Actions/ActionSaveHandle.cs:223)
    AC.ActionSaveHandle:Run () (at Assets/AdventureCreator/Scripts/Actions/ActionSaveHandle.cs:69)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:455)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:597)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:597)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:587)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.ActionList:ProcessActionEnd (AC.ActionEnd,int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:597)
    AC.ActionList:EndAction (AC.Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:556)
    AC.ActionList/d__44:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:520)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:405)
    AC.RuntimeActionList:BeginActionList (int,bool) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:181)
    AC.ActionList:Interact (int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:273)
    AC.RuntimeActionList:DownloadActions (AC.ActionListAsset,AC.Conversation,int,bool,bool,bool) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:136)
    AC.AdvGame:RunActionListAsset (AC.ActionListAsset,AC.Conversation,int,bool,bool) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:242)
    AC.AdvGame:RunActionListAsset (AC.ActionListAsset,int,int) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:163)
    AC.MenuSavesList:RunActionList (int) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:957)
    AC.MenuSavesList:ProcessClick (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:856)
    AC.MenuElement:ProcessClickUI (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:265)
    AC.MenuSavesList/<>c__DisplayClass31_1:b__0 () (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:198)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

  • Load:
    Loaded General X (NPC) (AC.NPC) portrait graphic. Saved: UnityEngine.Texture2DGeneral X Avatar - 19, Assigned: General X Avatar - 16 (UnityEngine.Texture2D)
    UnityEngine.Debug:Log (object)
    AC.RememberPortrait:LoadData (string) (at Assets/Noir Storm/Scripts/RememberPortrait.cs:50)
    AC.LevelStorage:UnloadScriptData (System.Collections.Generic.List`1<AC.ScriptData>,UnityEngine.SceneManagement.Scene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:742)
    AC.LevelStorage:LoadSceneData (AC.SingleLevelData,AC.SubScene) (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:411)
    AC.LevelStorage:ReturnCurrentLevelData () (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:167)
    AC.SaveSystem:InitAfterLoad () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:667)
    AC.SaveSystem:ReceiveDataToLoad (AC.SaveFile,string) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:575)
    AC.SaveSystem:LoadSaveGame (AC.SaveFile) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:409)
    AC.SaveSystem:LoadGame (int,int,bool) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:325)
    AC.MenuSavesList:ProcessClick (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:866)
    AC.MenuElement:ProcessClickUI (AC.Menu,int,AC.MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:265)
    AC.MenuSavesList/<>c__DisplayClass31_1:b__0 () (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:198)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)


    Remember that the player's avatar can't be seen anywhere on this save and load.

    Thanks!

  • Thanks. Here is a second try... but I guess it's exactly the same.

    The data now matches up. But what of the data as listed in the Save File manager?

    It looks like the files aren't being found by the AssetLoader. Open up AssetLoader.cs, and replace its GetAssetFile function with the following:

    private static T GetAssetFile <T> (Object[] assetFiles, string _name) where T : Object
    {
        if (assetFiles != null && _name != null)
        {
            _name = _name.Replace (" (Instance)", string.Empty);
            Debug.Log ("Search for " + _name + " in " + assetFiles.Length + " asset files");
            foreach (Object assetFile in assetFiles)
            {
                Debug.Log ("Found: " + assetFile);
                if (assetFile != null && (_name == (assetFile.GetType () + assetFile.name) || _name == assetFile.name))
                {
                    Debug.Log ("Match!");
                    return (T) assetFile;
                }
            }
        }
        return null;
    }
    

    This may result in a lot of messages when you load, but the stacktraces won't be necessary - a screenshot should be enough.

    Remember that the player's avatar can't be seen anywhere on this save and load.

    One thing at a time. But make sure Retain in prefab? is checked - I can't recreate the issue so long as this is the case.

  • I'm so sorry for the amount of text. I know it's a problem but I didn't know how important the level of details you needed. Apologies.
    Oddly enough, when I check what that game save should've saved in the Save manager I see it saved well! Both! NPC and Player. The numbers are the ones it should've been!
    Something else. This was the "tricky" test using two characters but I have several other examples in which the only character on screen goes from one room to another and the avatar changes and same results.
    Yes: the retain in prefab is clicked in all the remembers: Remember Portrait, footsteps, NPC (in case it's an NPC), constant ID.

    https://imgur.com/a/hds067q

    Hope this helps! IT eventually saves them but loads them incorrectly.
    I'm not sure if it's helpful or not for you but we can share the repo with you.
    Thanks a lot Chris for everything.

  • If you scroll through the Console list, does it find a match?

    91 is many assets to go through, however. Try using the "SaveableData" approach outlined in the Manual's "Performance and optimisation" chapter. This should reduce the searching to more manageable numbers - and will make it easier to see what's going on.

    This was the "tricky" test using two characters but I have several other examples in which the only character on screen goes from one room to another and the avatar changes and same results.

    It is worth noting that the approach you're taking (Triggers to switch to a mirrored texture) would be better replaced with a custom script that compares the X-position values of the two characters at the time Subtitles appear.

    If you use Unity UI, you could also rely on a single Sprite and flip it in the Image component - if the textures are indeed mirrors. It should also be feasible to use scripting to update the position of your portrait graphic dynamically based on the same information - so that you could rely on just a single Subtitles menu.

  • Thanks Chris,
    I did try it but I guess I did something wrong because they are not detected:
    I created a "Resources" folder under Assets. Then another folder inside the previous one named "SaveableData" and another inside this one named "Textures" "and threw there the portaits (the files).
    AND IT DID WORK!!!! Thanks a lot Chris! Thanks a lot!

  • Error while writing the message. At first it didn't work, then renamed the folder correctly and put them one inside another and they did work! Sorry. Forgot to check what I wrote before.

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.