Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- [CustomEditor(typeof(HybridSpawner))]
- public class HybridSpawnerEditor : Editor
- {
- public override void OnInspectorGUI()
- {
- serializedObject.Update();
- HybridSpawner spawner = (HybridSpawner)target;
- SerializedProperty array = serializedObject.FindProperty("arrayChildren");
- EditorGUI.BeginChangeCheck();
- EditorGUILayout.PropertyField(array, true);
- if (EditorGUI.EndChangeCheck())
- serializedObject.ApplyModifiedProperties();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Spawn Mode");
- spawner.SpawnShape = (HybridSpawner.SpawnMode)EditorGUILayout.EnumPopup(spawner.SpawnShape);
- EditorGUILayout.EndHorizontal();
- spawner.cloneCount = EditorGUILayout.IntField("Spawn Count", spawner.cloneCount);
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Alignment Mode");
- spawner.LookAtMode = (HybridSpawner.LookAt)EditorGUILayout.EnumPopup(spawner.LookAtMode);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.LabelField("Tip: You can rotate the spawner without rotating the children.");
- switch (spawner.LookAtMode)
- {
- case HybridSpawner.LookAt.customRotation:
- break;
- case HybridSpawner.LookAt.lookAtCentre:
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Lock Look Rotation");
- GUILayout.Label("X", GUILayout.Width(12));
- spawner.dontLookX = GUILayout.Toggle(spawner.dontLookX, "");
- GUILayout.Label("Y", GUILayout.Width(12));
- spawner.dontLookY = GUILayout.Toggle(spawner.dontLookY, "");
- GUILayout.Label("Z", GUILayout.Width(12));
- spawner.dontLookZ = GUILayout.Toggle(spawner.dontLookZ, "");
- EditorGUILayout.EndHorizontal();
- break;
- case HybridSpawner.LookAt.lookAtSpawner:
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Lock Look Rotation");
- GUILayout.Label("X", GUILayout.Width(12));
- spawner.dontLookX = GUILayout.Toggle(spawner.dontLookX, "");
- GUILayout.Label("Y", GUILayout.Width(12));
- spawner.dontLookY = GUILayout.Toggle(spawner.dontLookY, "");
- GUILayout.Label("Z", GUILayout.Width(12));
- spawner.dontLookZ = GUILayout.Toggle(spawner.dontLookZ, "");
- EditorGUILayout.EndHorizontal();
- break;
- }
- switch (spawner.SpawnShape)
- {
- case HybridSpawner.SpawnMode.staticPoint:
- spawner.setRotation = EditorGUILayout.Vector3Field(new GUIContent("Rotation Offset", "If left as zero in a custom rotation, it will be changed to the object's forward vector."), spawner.setRotation);
- spawner.setPosition = EditorGUILayout.Vector3Field("Spawn Position Offset", spawner.setPosition);
- break;
- case HybridSpawner.SpawnMode.staticLine:
- spawner.setRotation = EditorGUILayout.Vector3Field(new GUIContent("Rotation Offset", "If left as zero in a custom rotation, it will be changed to the object's forward vector."), spawner.setRotation);
- spawner.setPosition = EditorGUILayout.Vector3Field(new GUIContent("Spawn Position Offset", "This offset position children spawn from each other starting from the spawner."), spawner.setPosition);
- spawner.staticCircleY = EditorGUILayout.FloatField("Y Position Offset", spawner.staticCircleY);
- break;
- case HybridSpawner.SpawnMode.staticCircle:
- spawner.setRotation = EditorGUILayout.Vector3Field(new GUIContent("Rotation Offset", "If left as zero in a custom rotation, it will be changed to the object's forward vector."), spawner.setRotation);
- spawner.spawnRadiusScale = EditorGUILayout.FloatField(new GUIContent("Circle Radius", "Circle default radius is 1."), spawner.spawnRadiusScale);
- spawner.staticCircleY = EditorGUILayout.FloatField("Y Position Offset", spawner.staticCircleY);
- break;
- case HybridSpawner.SpawnMode.randomCircle:
- spawner.setRotation = EditorGUILayout.Vector3Field(new GUIContent("Rotation Offset", "If left as zero in a custom rotation, it will be changed to the object's forward vector."), spawner.setRotation);
- spawner.randomRotMax = EditorGUILayout.Vector3Field(new GUIContent("Max Rotation", "Independent X, Y, and Z values ranging from 0 to infinity. Acts as upper bounds. If left as 0, it will be set to 360."), spawner.randomRotMax);
- spawner.spawnRadiusScale = EditorGUILayout.FloatField(new GUIContent("Circle Radius", "Circle default radius is 1."), spawner.spawnRadiusScale);
- spawner.staticCircleY = EditorGUILayout.FloatField("Y Position Offset", spawner.staticCircleY);
- break;
- case HybridSpawner.SpawnMode.randomSphere:
- spawner.setRotation = EditorGUILayout.Vector3Field(new GUIContent("Rotation Offset", "If left as zero in a custom rotation, it will be changed to the object's forward vector."), spawner.setRotation);
- spawner.randomRotMax = EditorGUILayout.Vector3Field(new GUIContent("Max Rotation", "Independent X, Y, and Z values ranging from 0 to infinity. Acts as upper bounds. If left as 0, it will be set to 360."), spawner.randomRotMax);
- spawner.spawnRadiusScale = EditorGUILayout.FloatField(new GUIContent("Sphere Radius", "Sphere default radius is 1."), spawner.spawnRadiusScale);
- spawner.staticCircleY = EditorGUILayout.FloatField("Y Position Offset", spawner.staticCircleY);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement