Unity 내배캠 TIL

Unity 게임 개발 최종 팀 프로젝트(11주차 1일)

오늘도즐겨 2024. 12. 3. 03:14

🔥 12월 2일 월요일 목표 🔥

🔍 팀 프로젝트 UI 스킬 정보 세팅하기

🔍 팀 프로젝트 게임 씬 UI , 메인 게임 씬에 합치기

🔍 팀 프로젝트 무기 데이터 정리하기

 

📌UnitInfo - ListKey 가져와서, 세팅하기

Slot Image를 각각 대입해 주는 방법으로 일단 구현함!

public Image skillSlotImg1;
public Image skillSlotImg2;
public Image skillSlotImg3;
public Image skillSlotImg4;
public Image skillSlotImg5;

public UnitInfo unitInfo;
    
void SetUnitInfo()
{ 
    playableUnitImg.sprite = Resources.Load<Sprite>(dummyUnit.unitInfo.Path);
    
    nameTxt.text = dummyUnit.unitInfo.Name;
    levelTxt.text = $"Lv. {dummyUnit.Level}";
                
    attackPowerTxt.text = dummyUnit.unitInfo.AttackPower.ToString();
    defensivePowerTxt.text = dummyUnit.unitInfo.DefensivePower.ToString();

	//각 키 유닛인포에 있는 스킬 정보 담아주는 리스트
    List<int> unitSkillList = unitInfo.Skill; //unitInfoData.Skill;
        
    //스킬인포에 있는 스킬전체정보를 담고있는 리스트
    List<SkillInfo> skillInfoList = new ();         
        
    //유닛스킬 리스트에 스킬키 담아주기
    foreach (int skillKey in unitSkillList)
    {
        skillInfoList.Add(Core.DataManager.SkillTable.GetByKey(skillKey));
    }

    string skillSpritePath1 = skillInfoList[0].Path;
    string skillSpritePath2 = skillInfoList[1].Path;
    string skillSpritePath3 = skillInfoList[2].Path;
    string skillSpritePath4 = skillInfoList[3].Path;
    string skillSpritePath5 = skillInfoList[4].Path;
        
    skillSlotImg1.sprite = Resources.Load<Sprite>(skillSpritePath1);
    skillSlotImg2.sprite = Resources.Load<Sprite>(skillSpritePath2);
    skillSlotImg3.sprite = Resources.Load<Sprite>(skillSpritePath3);
    skillSlotImg4.sprite = Resources.Load<Sprite>(skillSpritePath4);
    skillSlotImg5.sprite = Resources.Load<Sprite>(skillSpritePath5);        
}

 

📌GameScene으로 합치기 위해 UnitInfo 내용 수정

     List로 변환해준 SkillSlot에 각각 SkilInfo.Path 이미지 대입해 주기

[SerializeField] private List<Image> unitSkillSlotList = new();

void SetUnitInfo()
{    
    unitInfo = playerUnit.data.UnitBase;
    UnitInstance inst = playerUnit.da
    
    playableUnitImg.sprite = Resources.Load<Sprite>(unitInfo.Path);
    nameTxt.text = unitInfo.Name;
    levelTxt.text = $"Lv. {inst.Level}";
    
    attackPowerTxt.text = unitInfo.AttackPower.ToString();
    defensivePowerTxt.text = unitInfo.DefensivePower.ToString();
    criticalTxt.text = unitInfo.Critical.ToString();
    multipleTxt.text = unitInfo.Multiple.ToString();
    
    List<int> unitSkillInfoList = unitInfo.Skill;
    List<SkillInfo> skillInfoList = new();

    foreach (int skillKey in unitSkillInfoList) //유닛스킬 리스트에 스킬키 담아주기
    {
        SkillInfo skillInfo = Core.DataManager.SkillTable.GetByKey(skillKey);
        skillInfoList.Add(skillInfo);
  
    for (int i = 0; i < unitSkillSlotList.Count; i++)
    {
        unitSkillSlotList[i].sprite = Resources.Load<Sprite>(skillInfoList[i].Path);
  
}

 

게임씬에 합치게 되면서 뜯어볼 팀원들의 스크립트 양이 어마어마해졌다.

월요일이라 그런지 구조 생각하다가 머리가 안 돌아간다 ㅠㅠ!

 

 

❓ UI HPbar 구현할때, 실제 구현할 HPImage가 BackGround Image를 넘지 않게 설정하는 방법

 

💡 뒷 배경 Object에 Mask 컴포넌트를 추가해준다!

- 뒷 배경은 앞에 표현되는 HP 보다 작은데, 실제 HP는 사이즈가 서로 맞지 않았는데, 

   간단하게 해결 하는 방법을 알았다 !!!!!!💡

 

 

🔥 12월 3일 화요일 목표 🔥

🔍 팀 프로젝트 데이터 정리 빨리 하기