Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using Game.Logic;
- using Game.Logic.EnemySpawners;
- using Game.Utilities;
- using UnityEditor;
- using UnityEngine;
- namespace Game.StaticData
- {
- [CustomPropertyDrawer(typeof(EnemySpawnerStaticData))]
- public class EnemySpawnerStaticDataPropertyDrawer : PropertyDrawer
- {
- private RectDrawer _drawer;
- public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
- {
- EditorGUI.BeginProperty(position, label, property);
- SerializedProperty idProperty = property.FindPropertyRelative("Id");
- SerializedProperty monsterTypeIdProperty = property.FindPropertyRelative("MonsterTypeId");
- SerializedProperty positionProperty = property.FindPropertyRelative("Position");
- _drawer ??= new RectDrawer(
- new PropertyLineDrawer(idProperty),
- new PropertyLineDrawer(positionProperty),
- new PropertyLineDrawer(monsterTypeIdProperty),
- new ButtonLineDrawer(nameof(Ping), () => Ping(idProperty.stringValue)));
- _drawer.Draw(position);
- EditorGUI.EndProperty();
- }
- private static void Ping(string id) =>
- Selection.activeGameObject = Object.FindObjectsOfType<SpawnMarker>()
- .Select(maker => maker.GetComponent<UniqueId>())
- .First(uniqueId1 => uniqueId1.Id == id)
- .gameObject;
- public override float GetPropertyHeight(SerializedProperty property, GUIContent label) =>
- _drawer?.Height ?? EditorGUIUtility.singleLineHeight;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement