• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

RefreshUI(); 기능이 궁금합니다.

23.10.17 09:49 작성 조회수 145

0

UI_ConfirmPopup.cs 파일에서 RefreshUI(); 함수 기능이 궁금합니다.

 

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static Define;

public class UI_ConfirmPopup : UI_Popup
{
	enum Texts
	{
		MessageText
	}

	enum Buttons
	{
		YesButton,
		NoButton
	}

	string _text;

	public override bool Init()
	{
		//초기화를 안전하게 사용해도 되는지 확인하는 과정
		//base.Init()이 true면 초기화 과정이 되어 있음.
		if (base.Init() == false)
			return false;

		BindText(typeof(Texts));
		BindButton(typeof(Buttons));

		GetButton((int)Buttons.YesButton).gameObject.BindEvent(OnClickYesButton);
		GetButton((int)Buttons.NoButton).gameObject.BindEvent(OnClickNoButton);
		GetText((int)Texts.MessageText).text = _text;

		RefreshUI();
		return true;
	}

	Action _onClickYesButton;

    /// <summary>
    /// 람다식 실행을 위한 콜백함수
    /// </summary>
    /// <param name="onClickYesButton"></param>
    /// <param name="text"></param>
    public void SetInfo(Action onClickYesButton, string text)
	{
		_onClickYesButton = onClickYesButton;
		_text = text;

		RefreshUI();
	}

	void RefreshUI()
	{
		if (_init == false)
			return;

	}

	void OnClickYesButton()
	{
		Managers.UI.ClosePopupUI(this);
		Managers.Sound.Play(Sound.Effect, "Sound_CheckButton");
		if (_onClickYesButton != null)
			_onClickYesButton.Invoke();
	}

	void OnClickNoButton()
	{
		Managers.Sound.Play(Sound.Effect, "Sound_CancelButton");
		OnComplete();
	}


	void OnComplete()
	{
		Managers.UI.ClosePopupUI(this);
	}
}

답변 1

답변을 작성해보세요.

0

이 코드만 놓고 보면 별 기능이 없지만,
다른 아이들의 경우 UI가 갱신되어야 할 때 사용됩니다.
어떤 UI든 작업할 때 공식처럼 일부 공통 함수를 만들어서 하는 편입니다.

Eunu Sa님의 프로필

Eunu Sa

질문자

2023.10.17

빠른 답변 감사합니다.^^