캐릭터 선택 화면에서 선택한 캐릭터 인덱스 연동 작업
This commit is contained in:
@@ -14,6 +14,8 @@ namespace TON
|
||||
|
||||
[SerializeField] private List<PlayerData> playerDatas;
|
||||
|
||||
private int currentSelectCharacterIndex;
|
||||
|
||||
public List<CharaterSelectUI_SlotItem> CharacterSlots = new List<CharaterSelectUI_SlotItem>();
|
||||
|
||||
public SerializableDictionary<string, Sprite> CharacterSpriteDict = new SerializableDictionary<string, Sprite>();
|
||||
@@ -37,7 +39,7 @@ namespace TON
|
||||
|
||||
if (sprite)
|
||||
{
|
||||
CharacterSlots[i].SetCharaterData(sprite, name);
|
||||
CharacterSlots[i].SetCharaterData(sprite, name, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +50,16 @@ namespace TON
|
||||
playerDatas = datas;
|
||||
}
|
||||
|
||||
public void SelectCharacter(int index)
|
||||
{
|
||||
Debug.Log("선택한 캐릭터 인덱스" + index);
|
||||
currentSelectCharacterIndex = index;
|
||||
playButton.interactable = true;
|
||||
}
|
||||
|
||||
public void OnClickPlayButton()
|
||||
{
|
||||
|
||||
Debug.Log(currentSelectCharacterIndex);
|
||||
}
|
||||
|
||||
public void OnClickCreateButton()
|
||||
|
||||
@@ -10,12 +10,29 @@ namespace TON
|
||||
{
|
||||
[SerializeField] private Image character_image;
|
||||
[SerializeField] private TextMeshProUGUI charater_name;
|
||||
[SerializeField] private int index;
|
||||
|
||||
public void SetCharaterData(Sprite image, string name)
|
||||
private CharaterSelectUI charaterSelectUI;
|
||||
|
||||
public void SetCharaterData(Sprite image, string name, int i)
|
||||
{
|
||||
character_image.sprite = image;
|
||||
charater_name.text = name;
|
||||
index = i;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 상위 오브젝트에서 CharacterSelectUI 찾기
|
||||
charaterSelectUI = FindObjectOfType<CharaterSelectUI>();
|
||||
|
||||
// 버튼 클릭 이벤트 등록
|
||||
GetComponent<Button>().onClick.AddListener(OnClickPlayer);
|
||||
}
|
||||
|
||||
public void OnClickPlayer()
|
||||
{
|
||||
charaterSelectUI.SelectCharacter(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user