using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class SomeLogicMethods : MonoBehaviour { public List allLevel1Pages; public InputField distributionStationIDInputField; public string givenDistributionStationID; [ContextMenu("Set")] // Start is called before the first frame update void Start() { allLevel1Pages = FindObjectsOfType(true).ToList(); /*CloseAllLevel1Page(); ShowLevel1Page("登陆界面");*/ } // Update is called once per frame void Update() { } public void ShowLevel1Page(string pageWantToShow) { GameObject pageWantToShowGO = GetGameObjectStatic(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(GameObject gameObject, string name, bool showError = true) where T : Component { List gos = new List(); if (gameObject == null) { gos = UnityEngine.Object.FindObjectsOfType(true).ToList(); } else { gos = gameObject.GetComponentsInChildren(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; } }