Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using UnityEngine;
using UnityEngine.AddressableAssets;
public class SwapCharacter : MonoBehaviour
[SerializeField] Animator parentAnimator; // 登録するAnimator
private GameObject cacheCharacter; // 差し替え時に元オブジェクトを削除する用
public void Load(string characterName)
Addressables.Instantiate(characterName, parentAnimator.transform, false).Completed +=(res)=>
// 以前のキャラ情報を破棄
if( cacheCharacter != null)
cacheCharacter = res.Result;
// 再構築
var childAnimator = res.Result.GetComponent<Animator>();
parentAnimator.avatar = childAnimator.avatar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.