using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class SomeLogicMethods : MonoBehaviour { public List<PageLevel1> allLevel1Pages; public InputField distributionStationIDInputField; public string givenDistributionStationID; [ContextMenu("Set")] // Start is called before the first frame update void Start() { allLevel1Pages = FindObjectsOfType<PageLevel1>(true).ToList(); /*CloseAllLevel1Page(); ShowLevel1Page("µÇ½½çÃæ");*/ } // Update is called once per frame void Update() { } public void ShowLevel1Page(string pageWantToShow) { GameObject pageWantToShowGO = GetGameObjectStatic<PageLevel1>(null, pageWantToShow, true); foreach (PageLevel1 pageLevel1 in allLevel1Pages) { pageLevel1.gameObject.SetActive(false); } pageWantToShowGO.SetActive(true); } public void CloseAllLevel1Page() { foreach (PageLevel1 pageLevel1 in allLevel1Pages) { pageLevel1.gameObject.SetActive(false); } } public static GameObject GetGameObjectStatic<T>(GameObject gameObject, string name, bool showError = true) where T : Component { List<T> gos = new List<T>(); if (gameObject == null) { gos = UnityEngine.Object.FindObjectsOfType<T>(true).ToList(); } else { gos = gameObject.GetComponentsInChildren<T>(true).ToList(); } foreach (T t in gos) { if (t.name == name) { return t.gameObject; } } if (showError) { Debug.Log("¶ÔÏó" + gameObject.name + "²»´æÔÚ×Ó¶ÔÏó" + name); } return null; } public void DistributionStationIDCheck() { if (distributionStationIDInputField.text == givenDistributionStationID) { ShowLevel1Page("²½Öè7"); } } public void CtrlC(string Text1) { GUIUtility.systemCopyBuffer = Text1; } }