42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
|
|||
|
|
public class PopupController_Auto : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
private GameObject popupPanel;
|
|||
|
|
private Button openButton;
|
|||
|
|
private Button closeButton;
|
|||
|
|
|
|||
|
|
void Awake()
|
|||
|
|
{
|
|||
|
|
// Otomatik bulma
|
|||
|
|
popupPanel = GameObject.Find("PopupPanel");
|
|||
|
|
openButton = GameObject.Find("HelpButton").GetComponent<Button>();
|
|||
|
|
closeButton = GameObject.Find("CloseButton").GetComponent<Button>();
|
|||
|
|
|
|||
|
|
if (popupPanel == null)
|
|||
|
|
Debug.LogError("PopupPanel bulunamadı! İsmi tam olarak 'PopupPanel' olmalı.");
|
|||
|
|
|
|||
|
|
if (openButton == null)
|
|||
|
|
Debug.LogError("HelpButton bulunamadı! İsmi tam olarak 'HelpButton' olmalı.");
|
|||
|
|
|
|||
|
|
if (closeButton == null)
|
|||
|
|
Debug.LogError("CloseButton bulunamadı! İsmi tam olarak 'CloseButton' olmalı.");
|
|||
|
|
|
|||
|
|
popupPanel.SetActive(false);
|
|||
|
|
|
|||
|
|
// Eventleri otomatik bağlama
|
|||
|
|
openButton.onClick.AddListener(OpenPopup);
|
|||
|
|
closeButton.onClick.AddListener(ClosePopup);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void OpenPopup()
|
|||
|
|
{
|
|||
|
|
popupPanel.SetActive(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ClosePopup()
|
|||
|
|
{
|
|||
|
|
popupPanel.SetActive(false);
|
|||
|
|
}
|
|||
|
|
}
|