As of AC v1.73.0, changes made to character portrait textures (using the "Character: Change portrait" Action) are no longer saved automatically. To save such changes, attach the RememberPortrait script to the character:
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);
}
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));
}
}
}
#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 ()
{ }
}
}