클릭하면 체크가 나타났다 사라졌다...

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting.Antlr3.Runtime.Tree;
using UnityEngine;
using UnityEngine.UI;
public class ToggleController : MonoBehaviour
{
// 체크 박스
public Button chackBox;
public GameObject OnBox;
bool isOn;
void Start()
{
// 디폴트: OFF
this.chackBox.onClick.AddListener(() => {
if (isOn == false)
{
Debug.Log("껴져있길래 켰어");
OnBox.SetActive(true); // 게임 오브젝트 보이기
isOn = true; // 버튼 bool 상태 변경
}
else
{
Debug.Log("켜있길래 껐어");
OnBox.SetActive(false); // 게임 오브젝트 안보이기
isOn = false; // 버튼 bool 상태 변경
}
});
}
}
empty UICheckBox
- bg(최하단에 깔아놓음)
- On(이미지 클릭하면 사라짐)
- Button
'게임 UI,UX 프로그래밍' 카테고리의 다른 글
| 쿨타임 표기 (0) | 2024.08.29 |
|---|---|
| 인풋필드 만들기 (0) | 2024.08.29 |
| 슬라이더 버튼 만들기 (0) | 2024.08.29 |
| toggle 스위치 버튼 만들기 (0) | 2024.08.29 |
| 버튼 클릭하기 (0) | 2024.08.29 |