DataManager 안 쓰는거 먼저

새로운 Practice05 Scene을 만들어서 연습
1. guide 만들어주기

2. main 빈 오브젝트 만들어주기, UIScrollView 만들어주기

3. scroll Rect, mask, horizontal layout group, Content Size cutter 추가



4. 이미지 ChestCell들 이미지 만들어주기

5. 메모장에 적은거 보고 코딩해보기 [DataManager X]

Practice05UIChestCell
csharp
닫기using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Practice05UIChestCell : MonoBehaviour
{
public enum eChestType
{
Wooden, Silver, Golden, Epic, Legendary
}
[SerializeField]
private eChestType chestType;
public eChestType ChestType
{
get
{
return this.chestType;
}
}
[SerializeField]
private int price;
protected int Price => this.price;
[SerializeField]
protected Button btnPrice;
public virtual void Init()
{
this.btnPrice.onClick.AddListener(() => {
Debug.LogFormat("{0}, {1}", this.chestType, this.Price);
});
}
}
Practice05UIChestCellAd
csharp
닫기using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Practice05UIChestCellAd : Practice05UIChestCell
{
[SerializeField]
private Button btnAd;
public override void Init()
{
//부모꺼 사용
base.Init();
this.btnAd.onClick.AddListener(() => {
Debug.LogFormat("{0}, 광고보기", this.ChestType);
});
}
}
Practice05UIChestScrollView
csharp
닫기using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Practice05UIChestScrollView : MonoBehaviour
{
[SerializeField]
private Practice05UIChestCell[] uiChestCells;
private void Start()
{
for(int i = 0; i < this.uiChestCells.Length; i++)
{
Practice05UIChestCell uiChestCell = this.uiChestCells[i];
uiChestCell.Init();
}
}
}
메모장에 적고나서 해보니 더 쉽게 다가오는거 같다.
'유니티 심화 > 복습' 카테고리의 다른 글
[주말과제] LearnUGUI - HW01 [ Shop_Gold ] (0) | 2023.09.10 |
---|---|
[복습] LearnUGUI - Practice05 [Shop], DataManager로 데이터 받아오기 (0) | 2023.09.08 |
[복습] LearnUGUI - Test05[Shop] (0) | 2023.09.07 |
[복습] LearnUGUI - Test04[Stage] (2) | 2023.09.07 |
[복습] LearnUGUI - Stage (0) | 2023.09.06 |