using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UISlider : MonoBehaviour
{
public Slider slider;
public System.Action<float> onSliderValueChanged;
private void Awake()
{
Debug.Log("Awake");
}
public void Init(float val)
{
Debug.Log("Init");
this.slider.value = val;
}
void Start()
{
Debug.Log("Start");
this.slider.onValueChanged.AddListener((val) =>
{
Debug.Log(val);
});
}
}
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class UIButtons : MonoBehaviour
{
public enum eBtnTypes
{
Yellow, Green
}
public Button[] arrBtns;
public Button btnBlue;
public Button btnLogin;
public UIPopupLogin uiPopupLogin;
public UISlider uiSlider;
public System.Action<eBtnTypes> onClick;
public void Init()
{
this.uiSlider.Init(0.5f);
this.uiSlider.onSliderValueChanged = (val) =>
{
Debug.Log(val);
uiSlider.onSliderValueChanged(val);
};
}
private void start()
{
Debug.Log("start");
for(int i = 0; i < arrBtns.Length; i++)
{
int typeN = i;
this.arrBtns[typeN].onClick.AddListener(() =>
{
this.onClick((eBtnTypes)typeN);
});
}
this.btnLogin.onClick.AddListener(() =>
{
Debug.Log("click");
this.uiPopupLogin.Open();
});
this.uiPopupLogin.btnClose.onClick.AddListener(() =>
{
this.uiPopupLogin.Close();
});
}
}
'Unity > 수업내용' 카테고리의 다른 글
[RestAPI]공공데이터 OpenAPI 데이터 활용하기 (0) | 2024.07.19 |
---|---|
[Unity 3D] IK 역운동학 (0) | 2023.05.22 |
[Unity UI] 1일차 Menu (0) | 2023.02.06 |
[Unity UI] 1일차 Button (0) | 2023.02.06 |
[Unity2D] Shooting Game 구조 만들기 연습 (0) | 2023.02.03 |