Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- public class MovingPlatform : MonoBehaviour {
- public enum Direction {Vertical, Horizontal}
- public Direction direction;
- [HideInInspector] public Vector2 verticalPath;
- [HideInInspector] public Vector2 horizontalPath;
- }
- [CustomEditor(typeof(MovingPlatform))]
- public class MovingPlatformEditor : Editor
- {
- public override void OnInspectorGUI()
- {
- DrawDefaultInspector();
- var scr = target as MovingPlatform;
- bool vertical = (scr.direction == MovingPlatform.Direction.Vertical);
- string tooltip = "X: Start Point, Y: End Point";
- if(vertical)
- {
- GUIContent content = new GUIContent("Vertical", tooltip);
- scr.verticalPath = EditorGUILayout.Vector2Field(content, scr.verticalPath);
- }
- else
- {
- GUIContent content = new GUIContent("Horizontal", tooltip);
- scr.horizontalPath = EditorGUILayout.Vector2Field(content, scr.horizontalPath);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment