forked from zxl/LaboratoryProtection
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace UnityTest.ZXL
|
|
{
|
|
public class ObjectDataComponent : BaseAutoMono<ObjectDataComponent>
|
|
{
|
|
public List<ObjectData> objectData = new List<ObjectData>();
|
|
|
|
|
|
public List<ObjectData> highlightObjectData = new List<ObjectData>();
|
|
|
|
public Dictionary<string, ObjectComponent> objectComponents = new Dictionary<string, ObjectComponent>();
|
|
|
|
public GameObject GetObject(HighlightObjectType objectType)
|
|
{
|
|
var key = objectType.ToString();
|
|
if (objectComponents.TryGetValue(key, out ObjectComponent component))
|
|
{
|
|
return component.gameObject;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
[Button]
|
|
void AddHighlight()
|
|
{
|
|
objectComponents.Clear();
|
|
var components = GameObject.FindObjectsOfType<ObjectComponent>();
|
|
foreach (var objectComponent in components)
|
|
{
|
|
// highlightObjectData.Add(new ObjectData() { goName = objectComponent.objectName, go = objectComponent.gameObject });
|
|
objectComponents.Add(objectComponent.objectName, objectComponent);
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
[System.Serializable]
|
|
public struct ObjectData
|
|
{
|
|
public string goName;
|
|
public GameObject go;
|
|
}
|
|
|
|
public enum HighlightObjectType
|
|
{
|
|
乙炔气瓶开关,
|
|
电脑屏幕,
|
|
乙炔瓶柜门,
|
|
湿抹布,
|
|
警示牌,
|
|
应急处理表,
|
|
消火栓,
|
|
灭火器,
|
|
}
|
|
} |