1
0
Fork 0
LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/ObjectDataComponent.cs

61 lines
1.6 KiB
C#
Raw Normal View History

2023-09-13 02:20:37 +08:00
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace UnityTest.ZXL
{
2023-09-13 20:15:22 +08:00
public class ObjectDataComponent : BaseAutoMono<ObjectDataComponent>
2023-09-13 02:20:37 +08:00
{
2023-09-13 15:04:19 +08:00
public List<ObjectData> objectData = new List<ObjectData>();
2023-09-13 20:15:22 +08:00
2023-09-13 15:04:19 +08:00
public List<ObjectData> highlightObjectData = new List<ObjectData>();
2023-09-13 20:15:22 +08:00
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;
}
2023-09-14 15:36:17 +08:00
#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
2023-09-13 02:20:37 +08:00
}
[System.Serializable]
2023-09-13 15:04:19 +08:00
public struct ObjectData
2023-09-13 02:20:37 +08:00
{
2023-09-13 15:04:19 +08:00
public string goName;
public GameObject go;
2023-09-13 02:20:37 +08:00
}
2023-09-13 09:28:54 +08:00
2023-09-13 20:15:22 +08:00
public enum HighlightObjectType
2023-09-13 09:28:54 +08:00
{
,
,
2023-09-14 23:09:07 +08:00
,
2023-09-13 09:28:54 +08:00
湿,
,
,
2023-09-18 03:39:32 +08:00
,
,
2023-09-27 23:28:03 +08:00
,
2023-09-13 09:28:54 +08:00
}
2023-09-13 02:20:37 +08:00
}