91 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
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;
 | 
						|
    }
 | 
						|
}
 |