24 lines
854 B
C#
24 lines
854 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class LevelPanel : MonoBehaviour
|
|
{
|
|
public int levelNum = 6;
|
|
public float buttonHeight = 31;
|
|
|
|
public void Initialization(int levelNum,float buttonHeight = 31)
|
|
{
|
|
this.levelNum = levelNum;
|
|
this.buttonHeight = buttonHeight;
|
|
RectTransform rectTransform = GetComponent<RectTransform>();
|
|
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, levelNum * buttonHeight);
|
|
for (int i = 0; i < levelNum; i++)
|
|
{
|
|
GameObject button = Instantiate(Resources.Load<GameObject>("Prefabs/LevelButton"), transform);
|
|
button.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -i * buttonHeight);
|
|
button.GetComponent<LevelButton>().Initialization(i);
|
|
}
|
|
}
|
|
}
|