-
Notifications
You must be signed in to change notification settings - Fork 2
develop Character Select
Jeon-YJ1004 edited this page Mar 9, 2023
·
1 revision
- CharacterSelection.scene Hierachy에 Create Empty, 아래 처럼 설정
- Character 버튼에 On Click() 지정
- PlayerMovement.cs에 Awake 할때 애니메이터를 바꾸는 코드 추가
[PlayerMovement.cs]
private void Awake()
{
//애니메이터 파일 이름을 설정 ex> Animator/Heroknight
string resourceName = "Animator/" + DataManager.instance.currentCharcter;
//실행중에 에니메이터 바꾸기. Resources.Load()는 path의 파일을 load한다. Asset>Resource가 root 경로
animator.runtimeAnimatorController = Resources.Load<RuntimeAnimatorController>(resourceName);
}
[DataManager.cs]
public enum CharacterName
{
Alchemist, Barbarian, Blademaster, Druid,FireMage, KnightHero, Necromancer
}
public class DataManager : MonoBehaviour
{
public static DataManager instance;
public CharacterName currentCharcter;
private void Awake()
{
instance = this;
DontDestroyOnLoad(gameObject);
}
}
[SelectCharacter.cs]
public class SelectCharacter : MonoBehaviour
{
public CharacterName charname;
public void OnClickCharacter()
{
DataManager.instance.currentCharcter=charname;
Debug.Log(DataManager.instance.currentCharcter);
}
}