C#/문제해결

0727 UI image의 enable

버스창문 2022. 7. 27. 17:54
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ToggleBtn : MonoBehaviour
{
    public Image check_on;
    private Button toggleBtn;
    // Start is called before the first frame update
    void Start()
    {
        this.toggleBtn = this.GetComponent<Button>();
        this.toggleBtn.onClick.AddListener(() => {
            if(this.check_on.IsActive() == true)
            {
                Debug.Log("?");
                this.check_on.enabled = false;
            }
            else
            {
                Debug.Log("!");
                this.check_on.enabled = true;
            }
        });
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

이 코드에서 isActive와 enable이 참조하는건,

안에 컴포넌트로 들어있는 이 image지

이름 옆에 있는 저 친구가 아니다.

저건 setActive로만 건드려지는것같다.