using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameManager_Tools : MonoBehaviour { public List tool_Objects_UI = new List(); public GameObject target; //public Button button; public GameObject 工具面板_content; public List 正确工具; //[HideInInspector] public string toolsname; private int 工具选择得分 = 0; // Start is called before the first frame update void Start() { // button.onClick.AddListener(change_toolsbutton); } // Update is called once per frame void Update() { } public void Remove_tool_Objects_Base(GameObject gameObject) { tool_Objects_UI.Remove(gameObject.GetComponent()); } public void change_toolsbutton() { if (工具面板_content == null) { 工具面板_content = GameObject.Find("Don'Destory").GetComponent().工具面板; } var load = Resources.Load("Prefab/工具按钮"); GameObject 工具按钮 = Instantiate(load) as GameObject; 工具按钮.transform.SetParent(工具面板_content.transform); tool_Objects_UI.Add(工具按钮.GetComponent()); 工具按钮.transform.localScale = new Vector3(1, 1, 1); 工具按钮.transform.localPosition = new Vector3(0, 0, 0); 工具按钮.transform.localEulerAngles = new Vector3(0, 0, 0); // 工具按钮.GetComponent().sprite_name = toolsname; 工具按钮.GetComponent().targetobject = target; target = null; // Debug.Log(工具按钮.GetComponent().sprite_name); 工具按钮.GetComponent().UI_name = toolsname; 工具按钮.GetComponent().change(); } public void Reload() { } public void fenshu_check() { for (int i = 0; i < 正确工具.Count; i++) { for (int g = 0; g < tool_Objects_UI.Count; g++) { if (tool_Objects_UI[g] = 正确工具[i]) { 工具选择得分 += 1; } } } for (int i = 0; i < tool_Objects_UI.Count; i++) { GameObject.Find("Don'Destory").GetComponent().持有工具.Add(tool_Objects_UI[i].UI_name); } if (GameObject.Find("Don'Destory").GetComponent().已得分 == false) { GameObject.Find("Don'Destory").GetComponent().工具选择得分 = 工具选择得分; GameObject.Find("Don'Destory").GetComponent().已得分 = true; } } public void ResToolsUI() { } }