As you can see in the image above, the input fields of “Gravity” and “Blast Height” are not in line with that of the other values. Any ideas on how I would fix this? (The other values don’t require a GUILayout.Label ()
.)
Thanks!
Edit: As requested, here is my code for the custom inspector (Sorry it’s kinda messy):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor (typeof (ProjectileScript))]
public class ProjectileInspector : Editor {
public ProjectileScript script;
//public ProjectileType type;
void OnEnable () {
script = (ProjectileScript) target;
}
public override void OnInspectorGUI () {
GUILayout.BeginHorizontal ();
script.rb = (Rigidbody) EditorGUILayout.ObjectField ("Rigidbody", script.rb, typeof (Rigidbody), true);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
script.gravity = EditorGUILayout.FloatField ("Gravity", script.gravity);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
EditorGUILayout.LabelField ("Specifications", EditorStyles.boldLabel);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
script.damage = EditorGUILayout.FloatField ("Damage", script.damage);
GUILayout.EndHorizontal ();
DisplayBlast ();
GUILayout.BeginHorizontal ();
script.floodingChance = EditorGUILayout.FloatField ("Flooding Chance", script.floodingChance);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
script.type = (ProjectileType) EditorGUILayout.EnumPopup ("Projectile Type", script.type);
GUILayout.EndHorizontal ();
DisplayOptions ();
GUILayout.BeginHorizontal ();
EditorGUILayout.LabelField ("Particles", EditorStyles.boldLabel);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
script.splash = (ParticleSystem) EditorGUILayout.ObjectField ("Splash", script.splash, typeof (ParticleSystem), true);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
script.blast = (ParticleSystem) EditorGUILayout.ObjectField ("Explosion", script.blast, typeof (ParticleSystem), true);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
script.trail = (ParticleSystem) EditorGUILayout.ObjectField ("Trail", script.trail, typeof (ParticleSystem), true);
GUILayout.EndHorizontal ();
}
void DisplayBlast () {
GUILayout.BeginHorizontal ();
script.explosion = EditorGUILayout.Toggle ("Blast Damage", script.explosion);
GUILayout.EndHorizontal ();
if (script.explosion) {
GUILayout.BeginHorizontal ();
script.radius = EditorGUILayout.FloatField ("Explosion Radius", script.radius);
GUILayout.EndHorizontal ();
GUILayout.BeginHorizontal ();
script.dropoff = EditorGUILayout.CurveField ("Damage Dropoff", script.dropoff);
GUILayout.EndHorizontal ();
}
}
void DisplayOptions () {
switch (script.type) {
case ProjectileType.Shell:
GUILayout.BeginHorizontal ();
script.spin = EditorGUILayout.FloatField ("Shell Spin", script.spin);
GUILayout.EndHorizontal ();
break;
case ProjectileType.Torpedo:
GUILayout.BeginHorizontal ();
script.torpedoSpeed = EditorGUILayout.FloatField ("Torpedo Speed", script.torpedoSpeed);
GUILayout.EndHorizontal ();
break;
case ProjectileType.Bomb:
GUILayout.BeginHorizontal ();
script.bombDetonateHeight = EditorGUILayout.FloatField ("Blast Height", script.bombDetonateHeight);
GUILayout.EndHorizontal ();
break;
case ProjectileType.Rocket:
break;
case ProjectileType.DepthCharge:
GUILayout.BeginHorizontal ();
script.chargefuseTime = EditorGUILayout.FloatField ("Fuse Length", script.chargefuseTime);
GUILayout.EndHorizontal ();
break;
}
}
}