NewN_UAVPlane/Assets/Temp/Scripts/Mastermanagement.cs

79 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Mastermanagement : MonoBehaviour
{
public List<DragController> dragControllers = new List<DragController>();//用于存UI元素
public List<GameObject> weapongames = new List<GameObject>();//用于存储场景中的物体
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);
}
}
}