Introduce background spawning with parallax effect (#86)
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #86
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using Minigames.Airplane.Core.Spawning;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Editor.Minigames.Airplane
|
||||
{
|
||||
/// <summary>
|
||||
/// Simplified custom editor for GroundDistanceSpawner.
|
||||
/// Shows only ground-relevant fields. Ground Y and interval are in AirplaneSettings.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(GroundDistanceSpawner))]
|
||||
public class GroundDistanceSpawnerEditor : UnityEditor.Editor
|
||||
{
|
||||
private SerializedProperty _poolsProperty;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_poolsProperty = serializedObject.FindProperty("pools");
|
||||
|
||||
// Ensure exactly 1 pool exists
|
||||
if (_poolsProperty.arraySize != 1)
|
||||
{
|
||||
_poolsProperty.arraySize = 1;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Ensure exactly 1 pool
|
||||
if (_poolsProperty.arraySize != 1)
|
||||
{
|
||||
_poolsProperty.arraySize = 1;
|
||||
}
|
||||
|
||||
// Draw single pool
|
||||
EditorGUILayout.LabelField("Ground Tiles (Fixed: 1 pool)", EditorStyles.boldLabel);
|
||||
|
||||
var poolElement = _poolsProperty.GetArrayElementAtIndex(0);
|
||||
var prefabsProperty = poolElement.FindPropertyRelative("prefabs");
|
||||
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
|
||||
EditorGUILayout.PropertyField(prefabsProperty, new GUIContent("Prefabs"), true);
|
||||
|
||||
if (prefabsProperty.arraySize == 0)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Add at least one ground tile prefab", MessageType.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.LabelField($"Prefabs: {prefabsProperty.arraySize}", EditorStyles.miniLabel);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user