빈 image로 영역 시각화
Content Size Fitter 컴포넌트 - Horizontal Fit : Preferred Size
Horizontal rayout group 컴포넌트 - spacing으로 간격 조절
더보기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIScrollviewChestItemAd : MonoBehaviour
{
public Button btnAd;
public Button btnGem;
void Start()
{
this.btnAd.onClick.AddListener(() =>
{
Debug.Log("광고");
});
this.btnGem.onClick.AddListener(() =>
{
Debug.Log("잼 구매");
});
}
// Update is called once per frame
void Update()
{
}
}
더보기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIScrollviewChest : MonoBehaviour
{
public GameObject adItemPrefab;
public GameObject itemPrefab;
public Transform contents;
public bool hasAd;
public int count;
private void Start()
{
//test
this.Init();
}
public void Init()
{
if (this.hasAd)
{
var item = Instantiate(this.adItemPrefab, contents);
}
for (int i = 0; i < this.count; i++)
{
var item = Instantiate(this.itemPrefab, contents);
}
}
}
더보기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIScrollviewChestItem : MonoBehaviour
{
public Button btnGem;
void Start()
{
this.btnGem.onClick.AddListener(() =>
{
Debug.Log("잼 구매");
});
}
}
'유니티 > 수업 내용' 카테고리의 다른 글
게임인공지능 - Ml-Agents - Penguin (0) | 2022.01.18 |
---|---|
게임인공지능 Ml-Agents - rollerball_config (0) | 2022.01.18 |
[UGUI] Joystick (0) | 2022.01.18 |
[UGUI] UIStage (0) | 2022.01.18 |
[UGUI] 버젯, InputField (0) | 2022.01.18 |