반응형
Dictionary<> 를 활용하여 실제 유니티에 적용시킨 코드.
public class Camera : MonoBehaviour
{
Dictionary<int, float[]> stageSizeDic;
public float maxXsize;
public float maxYsize;
private void Awake()
{
stageSizeDic = new Dictionary<int, float[]>();
MakeStageSizeDictionary();
ApplyStageSize();
}
void MakeStageSizeDictionary()
{
stageSizeDic.Add(0, new float[] {1.0f, 2.0f});
stageSizeDic.Add(1, new float[] { 3.0f, 4.0f });
}
void ApplyStageSize()
{
int stageIndex = 0;
maxXsize = stageSizeDic[stageIndex][0]; ///1.0f
maxYsize = stageSizeDic[stageIndex][1]; ///2.0f
}
}
댓글