Skip to content

Commit

Permalink
button to add MechSound with default volume=1
Browse files Browse the repository at this point in the history
  • Loading branch information
linojon authored and arthurkehrwald committed Nov 22, 2024
1 parent d25ec19 commit 491b5c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public override void OnInspectorGUI()

EditorGUILayout.PropertyField(_soundsProperty);

// unity doesnt use default values when adding items in a list so force it (Volume=1)
if (GUILayout.Button("Add New MechSound"))
{
comp.Sounds.Add(new MechSound());
EditorUtility.SetDirty(comp);
}

EditorGUILayout.PropertyField(_audioMixerProperty);

serializedObject.ApplyModifiedProperties();
Expand Down
1 change: 1 addition & 0 deletions VisualPinball.Unity/VisualPinball.Unity/Sound/MechSound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class MechSound
public string TriggerId;

[Range(0.0001f, 1)]
// this initialization doesnt work in inspector https://www.reddit.com/r/Unity3D/comments/j5i6cj/inspector_struct_default_values/
public float Volume = 1;

public MechSoundAction Action = MechSoundAction.Play;
Expand Down

0 comments on commit 491b5c3

Please sign in to comment.