hi everyone, i have a class like this :
using UnityEngine;
using System;
[System.Serializable]
public class ScaledCurve
{
public float Speed = 1;
public Animation Animation;
//public int FPS;
public AnimationFPS FPS;
}
public enum AnimationFPS { WEB = 15, Film = 24, PAL = 25, NTSC = 30, HDTV = 60, UHDTV = 120 }
now, i’m writing a drawer for it in unity 4 but :
i can’t make the enum show properly, and, i want the float slider show in one line then go to next vertical line and show the other stuff there, here is what i tried till now :
using UnityEngine;
using UnityEditor;
using System;
[CustomPropertyDrawer(typeof(ScaledCurve))]
public class ScaledCurveDrawer : PropertyDrawer
{
const int curveWidth = 50;
const float min = 0.1f;
const float max = 10;
const int fmin = 15;
const int fmax = 120;
const int animFieldWidth = 120;
private const int FPSWidth = 70;
private float wid;
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
SerializedProperty speed = prop.FindPropertyRelative("Speed");
SerializedProperty anim = prop.FindPropertyRelative("Animation");
SerializedProperty fps = prop.FindPropertyRelative("fps");
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginHorizontal();
// Draw Speed
EditorGUI.Slider(
new Rect(pos.x, pos.y, pos.width, pos.height),
speed, min, max, label);
// Draw FPS
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
//EditorGUI.PropertyField(
// new Rect(pos.width - (animFieldWidth) - FPSWidth, pos.y, FPSWidth, pos.height), fps);
EditorGUI.Popup(
new Rect(3, 3, pos.width - 6, 15),
"FPS",3,
fps.enumNames);
EditorGUI.indentLevel++;
// Draw Animation Field
EditorGUI.indentLevel = 0;
EditorGUI.PropertyField(
new Rect(pos.width - animFieldWidth, pos.y, animFieldWidth, pos.height),
anim, GUIContent.none);
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndVertical();
}
}
now, the problem is like this :
1- begin horizontal and vertical gives error
2- the editorGUI.propertyField is not what i’m looking for, EditorGUI.EnumPopup is looking for an enum and i can’t use the serialized fps variable that i’m defining
can anyone help on these?
also i saw this page :
[blog post about property drawer] [1]: Property Drawers in Unity 4 | Unity Blog
would be nice if someone can write those [Popup] and [Angle] functions and share with us
thanks for help