using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; public class btmandtopController : MonoBehaviour { [Header("player unique so")] public Player_SO player_SO; [Header("put prefabs here")] public GameObject putPrefabsHere; [Header("son buttons")] public Button settings_launch; public Button userInfo_launch; public Button store_launch; public Button showLevel_display; public Button email_display; public Button notice_display; [Header("sig prefabs")] public GameObject showLevel_prefab; public GameObject store_prefab; public GameObject settings_prefab; public GameObject userInfo_prefab; public GameObject email_prefab; public GameObject notice_prefab; private UnityAction instantiateSettings; private UnityAction instantiateUserInfo; private UnityAction instantiateStore; private UnityAction instantiateShowLevel; private UnityAction instantiateEmail; private UnityAction instantiateNotice; void Start() { instantiateSettings = () => InstantiatePrefab(settings_prefab); instantiateUserInfo = () => InstantiatePrefab(userInfo_prefab); instantiateStore = () => InstantiatePrefab(store_prefab); instantiateShowLevel = () => InstantiatePrefab(showLevel_prefab); instantiateEmail = () => InstantiatePrefab(email_prefab); instantiateNotice = () => InstantiatePrefab(notice_prefab); if (settings_launch != null) settings_launch.onClick.AddListener(instantiateSettings); if (userInfo_launch != null) userInfo_launch.onClick.AddListener(instantiateUserInfo); if (store_launch != null) store_launch.onClick.AddListener(instantiateStore); if (showLevel_display != null) showLevel_display.onClick.AddListener(instantiateShowLevel); if (email_display != null) email_display.onClick.AddListener(instantiateEmail); if (notice_display != null) notice_display.onClick.AddListener(instantiateNotice); } void OnDestroy() { if (settings_launch != null) settings_launch.onClick.RemoveListener(instantiateSettings); if (userInfo_launch != null) userInfo_launch.onClick.RemoveListener(instantiateUserInfo); if (store_launch != null) store_launch.onClick.RemoveListener(instantiateStore); if (showLevel_display != null) showLevel_display.onClick.RemoveListener(instantiateShowLevel); if (email_display != null) email_display.onClick.RemoveListener(instantiateEmail); if (notice_display != null) notice_display.onClick.RemoveListener(instantiateNotice); } private void InstantiatePrefab(GameObject prefab) { if (prefab != null && putPrefabsHere != null) { Instantiate(prefab, putPrefabsHere.transform); } } }