Some more airplane game doodles
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
using Minigames.Airplane.Interactive;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Editor.CustomEditorsAndDrawers
|
||||
{
|
||||
[CustomEditor(typeof(AirplaneBouncySurface))]
|
||||
public class AirplaneBouncySurfaceEditor : UnityEditor.Editor
|
||||
{
|
||||
private SerializedProperty _bounceMultiplierProp;
|
||||
private SerializedProperty _bounceDirectionProp;
|
||||
private SerializedProperty _useReflectionProp;
|
||||
private SerializedProperty _minBounceVelocityProp;
|
||||
private SerializedProperty _maxBounceVelocityProp;
|
||||
private SerializedProperty _bounceAnimatorProp;
|
||||
private SerializedProperty _bounceTriggerProp;
|
||||
private SerializedProperty _bounceSoundProp;
|
||||
private SerializedProperty _showDebugLogsProp;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_bounceMultiplierProp = serializedObject.FindProperty("bounceMultiplier");
|
||||
_bounceDirectionProp = serializedObject.FindProperty("bounceDirection");
|
||||
_useReflectionProp = serializedObject.FindProperty("useReflection");
|
||||
_minBounceVelocityProp = serializedObject.FindProperty("minBounceVelocity");
|
||||
_maxBounceVelocityProp = serializedObject.FindProperty("maxBounceVelocity");
|
||||
_bounceAnimatorProp = serializedObject.FindProperty("bounceAnimator");
|
||||
_bounceTriggerProp = serializedObject.FindProperty("bounceTrigger");
|
||||
_bounceSoundProp = serializedObject.FindProperty("bounceSound");
|
||||
_showDebugLogsProp = serializedObject.FindProperty("showDebugLogs");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("Bounce Configuration", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUILayout.PropertyField(_bounceMultiplierProp);
|
||||
EditorGUILayout.PropertyField(_useReflectionProp);
|
||||
|
||||
// Grey out bounceDirection when useReflection is true
|
||||
bool isReflectionEnabled = _useReflectionProp.boolValue;
|
||||
|
||||
EditorGUI.BeginDisabledGroup(isReflectionEnabled);
|
||||
EditorGUILayout.PropertyField(_bounceDirectionProp);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
if (isReflectionEnabled)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Bounce direction is used as surface normal for reflection when 'Use Reflection' is enabled.", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Plane will be launched directly in the specified direction (no reflection).", MessageType.Info);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Optional Modifiers", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_minBounceVelocityProp);
|
||||
EditorGUILayout.PropertyField(_maxBounceVelocityProp);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Visual Feedback (Optional)", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_bounceAnimatorProp);
|
||||
EditorGUILayout.PropertyField(_bounceTriggerProp);
|
||||
EditorGUILayout.PropertyField(_bounceSoundProp);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Debug", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_showDebugLogsProp);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 813d27f62bb94a3cbbf5b504a0209257
|
||||
timeCreated: 1765188846
|
||||
@@ -0,0 +1,24 @@
|
||||
using Minigames.Airplane.Core;
|
||||
using Minigames.Airplane.Data;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Editor.CustomEditorsAndDrawers
|
||||
{
|
||||
[CustomEditor(typeof(AirplaneSpawnManager))]
|
||||
public class AirplaneSpawnManagerEditor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
// Draw default inspector - all fields now have proper property drawers
|
||||
DrawDefaultInspector();
|
||||
|
||||
// Add helpful info box
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.HelpBox(
|
||||
"Each prefab now has its own spawn position configuration. " +
|
||||
"Expand entries in Positive/Negative Object Prefabs to configure individual spawn behavior.",
|
||||
MessageType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5bd22e99d254c229cca7cee79b40baf
|
||||
timeCreated: 1765189346
|
||||
@@ -0,0 +1,97 @@
|
||||
using Minigames.Airplane.Data;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Editor.CustomEditorsAndDrawers
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(PrefabSpawnEntry))]
|
||||
public class PrefabSpawnEntryDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
// Draw foldout
|
||||
property.isExpanded = EditorGUI.Foldout(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight),
|
||||
property.isExpanded, label, true);
|
||||
|
||||
if (property.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
float yPos = position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
// Draw prefab
|
||||
SerializedProperty prefabProp = property.FindPropertyRelative("prefab");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), prefabProp);
|
||||
yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
// Draw spawn position mode
|
||||
SerializedProperty spawnModeProp = property.FindPropertyRelative("spawnPositionMode");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), spawnModeProp);
|
||||
yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
// Draw conditional fields based on mode
|
||||
SpawnPositionMode mode = (SpawnPositionMode)spawnModeProp.enumValueIndex;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SpawnPositionMode.SpecifiedY:
|
||||
SerializedProperty specifiedYProp = property.FindPropertyRelative("specifiedY");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), specifiedYProp);
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.RandomRange:
|
||||
SerializedProperty randomYMinProp = property.FindPropertyRelative("randomYMin");
|
||||
SerializedProperty randomYMaxProp = property.FindPropertyRelative("randomYMax");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), randomYMinProp);
|
||||
yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), randomYMaxProp);
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.SnapToGround:
|
||||
// No additional fields needed
|
||||
EditorGUI.LabelField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight),
|
||||
"Uses raycast to snap to ground", EditorStyles.miniLabel);
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (!property.isExpanded)
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
|
||||
float height = EditorGUIUtility.singleLineHeight; // Foldout
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // prefab
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // spawnPositionMode
|
||||
|
||||
// Add height for mode-specific fields
|
||||
SerializedProperty spawnModeProp = property.FindPropertyRelative("spawnPositionMode");
|
||||
SpawnPositionMode mode = (SpawnPositionMode)spawnModeProp.enumValueIndex;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SpawnPositionMode.SpecifiedY:
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // specifiedY
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.RandomRange:
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // randomYMin
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // randomYMax
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.SnapToGround:
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // Info label
|
||||
break;
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3e7b9fb5ac24beca6cc32e3025dc12f
|
||||
timeCreated: 1765189641
|
||||
104
Assets/Editor/CustomEditorsAndDrawers/TargetPrefabEntryDrawer.cs
Normal file
104
Assets/Editor/CustomEditorsAndDrawers/TargetPrefabEntryDrawer.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using Minigames.Airplane.Core;
|
||||
using Minigames.Airplane.Data;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Editor.CustomEditorsAndDrawers
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(AirplaneSpawnManager.TargetPrefabEntry))]
|
||||
public class TargetPrefabEntryDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
// Draw foldout
|
||||
property.isExpanded = EditorGUI.Foldout(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight),
|
||||
property.isExpanded, label, true);
|
||||
|
||||
if (property.isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
float yPos = position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
// Draw targetKey
|
||||
SerializedProperty targetKeyProp = property.FindPropertyRelative("targetKey");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), targetKeyProp);
|
||||
yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
// Draw prefab
|
||||
SerializedProperty prefabProp = property.FindPropertyRelative("prefab");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), prefabProp);
|
||||
yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
// Draw spawn position mode
|
||||
SerializedProperty spawnModeProp = property.FindPropertyRelative("spawnPositionMode");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), spawnModeProp);
|
||||
yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
// Draw conditional fields based on mode
|
||||
SpawnPositionMode mode = (SpawnPositionMode)spawnModeProp.enumValueIndex;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SpawnPositionMode.SpecifiedY:
|
||||
SerializedProperty specifiedYProp = property.FindPropertyRelative("specifiedY");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), specifiedYProp);
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.RandomRange:
|
||||
SerializedProperty randomYMinProp = property.FindPropertyRelative("randomYMin");
|
||||
SerializedProperty randomYMaxProp = property.FindPropertyRelative("randomYMax");
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), randomYMinProp);
|
||||
yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight), randomYMaxProp);
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.SnapToGround:
|
||||
// No additional fields needed
|
||||
EditorGUI.LabelField(new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight),
|
||||
"Uses raycast to snap to ground", EditorStyles.miniLabel);
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (!property.isExpanded)
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
|
||||
float height = EditorGUIUtility.singleLineHeight; // Foldout
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // targetKey
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // prefab
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // spawnPositionMode
|
||||
|
||||
// Add height for mode-specific fields
|
||||
SerializedProperty spawnModeProp = property.FindPropertyRelative("spawnPositionMode");
|
||||
SpawnPositionMode mode = (SpawnPositionMode)spawnModeProp.enumValueIndex;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SpawnPositionMode.SpecifiedY:
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // specifiedY
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.RandomRange:
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // randomYMin
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // randomYMax
|
||||
break;
|
||||
|
||||
case SpawnPositionMode.SnapToGround:
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; // Info label
|
||||
break;
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63205158adf24f9f9e4c6fa21da543ff
|
||||
timeCreated: 1765189334
|
||||
Reference in New Issue
Block a user