2024-12-20 10:10:19 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
public class Drill : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private Button ScheduledBtn;
|
|
|
|
|
public bool isadministrator; // <20>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>Ա
|
|
|
|
|
private bool eventAdded = false; // <20><>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
public delegate void BoolChangedHandler(bool value);
|
|
|
|
|
public event BoolChangedHandler OnBoolAChanged;
|
|
|
|
|
|
|
|
|
|
private Text noRoomText; // "û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><><EFBFBD>ı<EFBFBD>
|
|
|
|
|
private Transform content; // Scroll View Content
|
|
|
|
|
|
|
|
|
|
// <20><>¼<EFBFBD><C2BC>һ<EFBFBD>ε<EFBFBD> isadministrator ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>ظ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>
|
|
|
|
|
private bool lastIsAdministratorState;
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
ScheduledBtn = transform.Find("down/ScheduledBtn").GetComponent<Button>();
|
|
|
|
|
ScheduledBtn.gameObject.SetActive(false); // <20><>ʼ<EFBFBD><CABC><EFBFBD>ذ<EFBFBD>ť
|
|
|
|
|
|
|
|
|
|
noRoomText = transform.Find("Text").GetComponent<Text>();
|
|
|
|
|
noRoomText.gameObject.SetActive(false); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|
|
|
|
|
|
|
|
|
content = transform.Find("Mid/Scroll View/Viewport/Content");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
// ʵʱ<CAB5><CAB1><EFBFBD>ⷿ<EFBFBD><E2B7BF><EFBFBD>б<EFBFBD><D0B1>Ƿ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD> noRoomText <20>Ŀɼ<C4BF><C9BC><EFBFBD>
|
|
|
|
|
noRoomText.gameObject.SetActive(content.childCount == 0);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա״̬<D7B4>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯
|
|
|
|
|
if (isadministrator != lastIsAdministratorState)
|
|
|
|
|
{
|
|
|
|
|
lastIsAdministratorState = isadministrator; // <20><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>¼
|
|
|
|
|
UpdateScheduledBtnVisibility(); // <20><><EFBFBD>°<EFBFBD>ť<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> isadministrator ״̬ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD> ScheduledBtn <20>Ŀɼ<C4BF><C9BC><EFBFBD>
|
|
|
|
|
private void UpdateScheduledBtnVisibility()
|
|
|
|
|
{
|
|
|
|
|
if (isadministrator)
|
|
|
|
|
{
|
|
|
|
|
ScheduledBtn.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
|
|
// <20><>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
if (!eventAdded)
|
|
|
|
|
{
|
|
|
|
|
ScheduledBtn.onClick.AddListener(OnClickScheduleBtn);
|
|
|
|
|
eventAdded = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ScheduledBtn.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
OnBoolAChanged?.Invoke(isadministrator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
void OnClickScheduleBtn()
|
|
|
|
|
{
|
2024-12-26 22:26:18 +08:00
|
|
|
|
SceneManager.LoadScene(2);
|
2024-12-20 10:10:19 +08:00
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>ť<EFBFBD><C5A5>");
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|