Page 1 of 1

Support for serialising Animators

Posted: Wed Sep 23, 2020 9:02 am
by Joel
Status

Requested

Complexity

6/10

Description

Ability to save Unity Animator components.

This is not automatically serialisable, so further exploration would be needed to understand whether it can be serialised using its Get/Set methods. As such, this is not trivial to implement.

Re: Support for serialising Animators

Posted: Mon May 10, 2021 5:44 am
by AdamStepinski
+1, when loaded, Animator loses "Controller" field

My solution: have singleton with RuntimeAnimatorController field

Code: Select all

public class EasySaveReferenceHelper : MonoBehaviour
{
	public static EasySaveReferenceHelper Instance;
	public RuntimeAnimatorController CharRuntimeAnimController;

	private void Awake()
	{
		Instance = this;
	}
}
Create script on your animator and in Start():

Code: Select all

private void Start()
{
	Animator charAnimator = GetComponent<Animator>();
	charAnimator.runtimeAnimatorController = EasySaveReferenceHelper.Instance.CharRuntimeAnimController;
}

Re: Support for serialising Animators

Posted: Fri May 21, 2021 4:46 am
by syu15
I am also hoping for this feature as I am loading the animator controller from an accessibles directory when I instantiate my prefab. If I can't save my runtime animator controller, I will have to reload it again from the accessibles directory when the saved prefab is loaded which is not ideal.