Finalize the parallax work

This commit is contained in:
Michal Pikulski
2025-12-17 22:54:24 +01:00
parent 867399c838
commit 7f5a229c3a
46 changed files with 3908 additions and 1246 deletions

View File

@@ -14,9 +14,13 @@ namespace Editor.Minigames.Airplane
public class ParallaxBackgroundSpawnerEditor : UnityEditor.Editor
{
private SerializedProperty _poolsProperty;
private SerializedProperty _backgroundSortLayerProperty;
private SerializedProperty _middleSortLayerProperty;
private SerializedProperty _foregroundSortLayerProperty;
private SerializedProperty _parallaxSortLayerProperty;
private SerializedProperty _backgroundSortOrderProperty;
private SerializedProperty _sortOrderIncrementProperty;
private SerializedProperty _globalStrengthProperty;
private SerializedProperty _backgroundSpeedProperty;
private SerializedProperty _middleSpeedProperty;
private SerializedProperty _foregroundSpeedProperty;
private SerializedProperty _cameraManagerProperty;
private SerializedProperty _showDebugLogsProperty;
@@ -33,9 +37,13 @@ namespace Editor.Minigames.Airplane
private void OnEnable()
{
_poolsProperty = serializedObject.FindProperty("pools");
_backgroundSortLayerProperty = serializedObject.FindProperty("backgroundSortLayer");
_middleSortLayerProperty = serializedObject.FindProperty("middleSortLayer");
_foregroundSortLayerProperty = serializedObject.FindProperty("foregroundSortLayer");
_parallaxSortLayerProperty = serializedObject.FindProperty("parallaxSortLayer");
_backgroundSortOrderProperty = serializedObject.FindProperty("backgroundSortOrder");
_sortOrderIncrementProperty = serializedObject.FindProperty("sortOrderIncrement");
_globalStrengthProperty = serializedObject.FindProperty("globalStrength");
_backgroundSpeedProperty = serializedObject.FindProperty("backgroundSpeed");
_middleSpeedProperty = serializedObject.FindProperty("middleSpeed");
_foregroundSpeedProperty = serializedObject.FindProperty("foregroundSpeed");
_cameraManagerProperty = serializedObject.FindProperty("cameraManager");
_showDebugLogsProperty = serializedObject.FindProperty("showDebugLogs");
@@ -74,11 +82,44 @@ namespace Editor.Minigames.Airplane
EditorGUILayout.PropertyField(_cameraManagerProperty);
EditorGUILayout.Space();
// Sort Layers
EditorGUILayout.LabelField("Sort Layer Configuration", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_backgroundSortLayerProperty, new GUIContent("Background Sort Layer"));
EditorGUILayout.PropertyField(_middleSortLayerProperty, new GUIContent("Middle Sort Layer"));
EditorGUILayout.PropertyField(_foregroundSortLayerProperty, new GUIContent("Foreground Sort Layer"));
// Parallax Configuration (CENTRALIZED SETTINGS)
EditorGUILayout.LabelField("Parallax Configuration", EditorStyles.boldLabel);
EditorGUILayout.HelpBox("These settings apply to ALL parallax elements spawned by this spawner. Adjust speeds to control depth perception.", MessageType.Info);
EditorGUILayout.PropertyField(_globalStrengthProperty, new GUIContent("Global Strength", "Overall parallax intensity (0 = no effect, 1 = full)"));
EditorGUILayout.Space(5);
EditorGUILayout.LabelField("Per-Layer Speeds", EditorStyles.miniBoldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_backgroundSpeedProperty, new GUIContent("Background Speed", "Slowest layer, appears furthest (e.g., 0.3)"));
EditorGUILayout.PropertyField(_middleSpeedProperty, new GUIContent("Middle Speed", "Medium speed layer (e.g., 0.6)"));
EditorGUILayout.PropertyField(_foregroundSpeedProperty, new GUIContent("Foreground Speed", "Fastest layer, appears closest (e.g., 0.9)"));
EditorGUI.indentLevel--;
// Validation warnings
if (_backgroundSpeedProperty.floatValue >= _middleSpeedProperty.floatValue)
{
EditorGUILayout.HelpBox("Warning: Background speed should be less than Middle speed for proper depth effect", MessageType.Warning);
}
if (_middleSpeedProperty.floatValue >= _foregroundSpeedProperty.floatValue)
{
EditorGUILayout.HelpBox("Warning: Middle speed should be less than Foreground speed for proper depth effect", MessageType.Warning);
}
EditorGUILayout.Space();
// Sort Configuration
EditorGUILayout.LabelField("Sort Configuration", EditorStyles.boldLabel);
EditorGUILayout.HelpBox("All parallax objects use the same sort layer with different sort orders for depth.", MessageType.Info);
EditorGUILayout.PropertyField(_parallaxSortLayerProperty, new GUIContent("Sort Layer", "Sort layer for all parallax elements (typically 'Background')"));
EditorGUILayout.PropertyField(_backgroundSortOrderProperty, new GUIContent("Background Sort Order", "Sort order for furthest back layer (e.g., -50)"));
EditorGUILayout.PropertyField(_sortOrderIncrementProperty, new GUIContent("Sort Order Increment", "Increment between layers (e.g., 10 → Middle: -40, Foreground: -30)"));
// Show calculated sort orders
int middleOrder = _backgroundSortOrderProperty.intValue + _sortOrderIncrementProperty.intValue;
int foregroundOrder = _backgroundSortOrderProperty.intValue + (_sortOrderIncrementProperty.intValue * 2);
EditorGUILayout.LabelField($"Calculated: Background={_backgroundSortOrderProperty.intValue}, Middle={middleOrder}, Foreground={foregroundOrder}", EditorStyles.miniLabel);
EditorGUILayout.Space();
// Pool Mode (locked to Exclusive)
@@ -98,8 +139,9 @@ namespace Editor.Minigames.Airplane
{
var poolElement = _poolsProperty.GetArrayElementAtIndex(i);
var prefabsProperty = poolElement.FindPropertyRelative("prefabs");
var unlockTimeProperty = poolElement.FindPropertyRelative("unlockTime");
var descProperty = poolElement.FindPropertyRelative("description");
var overrideMinDistProperty = poolElement.FindPropertyRelative("overrideMinDistance");
var overrideMaxDistProperty = poolElement.FindPropertyRelative("overrideMaxDistance");
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
@@ -113,8 +155,14 @@ namespace Editor.Minigames.Airplane
EditorGUILayout.LabelField(_layerDescriptions[i], EditorStyles.miniLabel);
EditorGUILayout.Space(5);
EditorGUILayout.PropertyField(descProperty, new GUIContent("Description"));
EditorGUILayout.PropertyField(prefabsProperty, new GUIContent("Prefabs"), true);
EditorGUILayout.PropertyField(unlockTimeProperty, new GUIContent("Unlock Time (seconds)"));
EditorGUILayout.Space(5);
EditorGUILayout.LabelField("Spawn Distance Overrides", EditorStyles.miniBoldLabel);
EditorGUILayout.HelpBox("Leave at 0 to use global settings. Set > 0 to override for this layer.", MessageType.Info);
EditorGUILayout.PropertyField(overrideMinDistProperty, new GUIContent("Min Distance Override", "Minimum distance between objects (0 = use global)"));
EditorGUILayout.PropertyField(overrideMaxDistProperty, new GUIContent("Max Distance Override", "Maximum distance between objects (0 = use global)"));
// Show info about prefab count
if (prefabsProperty.arraySize == 0)