using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class Mastermanagement : MonoBehaviour { public List dragControllers = new List();//用于存UI元素 public List weapongames = new List();//用于存储场景中的物体 void Awake() { } void Start() { StartCoroutine(WaitGetAllDevice()); } private IEnumerator WaitGetAllDevice() { yield return new WaitForSeconds(0.1f); weapongames = DeviceManager.Instance.GetPlayerDecive1(); if (weapongames != null) { for (int i = 0; i < weapongames.Count; i++) { Noobj(weapongames[i]); } } } void Update() { } //初始化场景的设备 public void Noobj(GameObject game) { for (int i = 0; i < dragControllers.Count; i++) { if (dragControllers[i].gameObject.name == game.name) { dragControllers[i].gameObject.SetActive(false); break; } } } //判断链表的名字是否有相等的 public void Onobj(GameObject game) { for (int i = 0; i < dragControllers.Count; i++) { if (dragControllers[i].gameObject.name == game.name) { dragControllers[i].gameObject.SetActive(true); } } } //给列表添加游戏物体 public void OnAdd(GameObject obj) { if (!weapongames.Contains(obj)) { weapongames.Add(obj); } } //给游戏删除物体 public void Remove(GameObject obj) { if (weapongames.Contains(obj)) { weapongames.Remove(obj); Destroy(obj); } } }