using System; using System.Collections; using System.Collections.Generic; using Gameplay; using Sirenix.OdinInspector.Editor; using UnityEditor; using UnityEditor.UI; using UnityEngine; using UnityEngine.UIElements; [CustomEditor(typeof(RaffleShowComponent), true)] public class RaffleShowComponentInspector : OdinEditor { private RaffleShowComponent Target => target as RaffleShowComponent; private readonly List listShowPoint = new(); private Transform lastShowPointRoot; private bool isFoldOut; private GUIStyle style; private void InitGuiStyle() { if (style == null) { style = new(GUI.skin.label) { fontSize = 30, }; style.normal.textColor = Color.black; } } public override void OnInspectorGUI() { base.OnInspectorGUI(); RefreshShowPoint(); isFoldOut = EditorGUILayout.Foldout(isFoldOut, $"演出点: ({listShowPoint.Count}个)"); if (isFoldOut) { foreach (Transform tsShowPoint in listShowPoint) { EditorGUILayout.LabelField(tsShowPoint.name); } } } private void OnSceneGUI() { InitGuiStyle(); int pointID = 1; Color oldColor = Handles.color; Handles.color = Color.red; foreach (Transform tsShowPoint in listShowPoint) { if (tsShowPoint) { Handles.DrawSolidDisc(tsShowPoint.position, Vector3.up, 0.5f); Handles.Label(tsShowPoint.position, $"{pointID}", style); } pointID++; } Handles.color = oldColor; } private void RefreshShowPoint() { if (lastShowPointRoot == Target.TsShowPointRoot) return; lastShowPointRoot = Target.TsShowPointRoot; listShowPoint.Clear(); if (Target.TsShowPointRoot == null) return; for (int i = 0; i < Target.TsShowPointRoot.childCount; ++i) { listShowPoint.Add(Target.TsShowPointRoot.GetChild(i)); } } }