private static System.Action <SerializedType> BuildSerializedTypeCallback(Variant param) { return(type => { param.SetAs <SerializedType>(type); }); }
private static System.Action <System.Type> BuildDerivedTypeCallback(Variant param, System.Type baseType) { return(type => { param.SetAs <DerivedType>(new DerivedType(baseType, type)); }); }
private static void LayoutAsVec2(Variant parameter, bool label) { EditorGUILayout.BeginHorizontal(); { if (label) { parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth)); } var result = EditorGUILayout.Vector2Field(GUIContent.none, parameter.GetAs <Vector2>(), GUILayout.Width(FieldWidth)); parameter.SetAs(result); } EditorGUILayout.EndHorizontal(); }
private static void LayoutAsCurve(Variant parameter, bool label) { EditorGUILayout.BeginHorizontal(); { if (label) { parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth)); } var result = EditorGUILayout.CurveField(parameter.GetAs <AnimationCurve>(), GUILayout.Width(FieldWidth)); parameter.SetAs(result); } EditorGUILayout.EndHorizontal(); }
private static void LayoutAsObject <T>(Variant parameter, bool label) where T : UnityEngine.Object { EditorGUILayout.BeginHorizontal(); { if (label) { parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth)); } T result = (T)EditorGUILayout.ObjectField(parameter.GetAs <T>(), parameter.HoldType.Type, true, GUILayout.Width(FieldWidth)); parameter.SetAs(result); } EditorGUILayout.EndHorizontal(); }
private static void LayoutAsGenericObject(Variant parameter, bool label) { EditorGUILayout.BeginHorizontal(); { if (label) { parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth)); } var result = EditorGUILayout.ObjectField(parameter.GetAs <Object>(), parameter.HoldType.Type, true, GUILayout.Width(FieldWidth)); parameter.SetAs(result); } EditorGUILayout.EndHorizontal(); }
private static void DrawAsVec2(Rect rect, Variant parameter, bool label) { if (label) { var width = rect.width; rect.width = width * 0.45f; parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel); rect.width = width * 0.5f; rect.x += rect.width; } var result = EditorGUI.Vector2Field(rect, GUIContent.none, parameter.GetAs <Vector2>()); parameter.SetAs(result); }
private static void DrawAsCurve(Rect rect, Variant parameter, bool label) { if (label) { var width = rect.width; rect.width = width * 0.45f; parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel); rect.width = width * 0.5f; rect.x += rect.width; } var result = EditorGUI.CurveField(rect, parameter.GetAs <AnimationCurve>()); parameter.SetAs(result); }
private static void DrawAsGenericObject(Rect rect, Variant parameter, bool label) { if (label) { var width = rect.width; rect.width = width * 0.45f; parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel); rect.width = width * 0.5f; rect.x += rect.width; } var result = EditorGUI.ObjectField(rect, parameter.GetAs <Object>(), parameter.HoldType.Type, true); parameter.SetAs(result); }
private static void DrawAsObject <T>(Rect rect, Variant parameter, bool label) where T : UnityEngine.Object { if (label) { var width = rect.width; rect.width = width * 0.45f; parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel); rect.width = width * 0.5f; rect.x += rect.width; } T result = (T)EditorGUI.ObjectField(rect, parameter.GetAs <T>(), parameter.HoldType.Type, true); parameter.SetAs(result); }
private static void DrawAsFloat(Rect rect, Variant parameter, bool label) { if (label) { var width = rect.width; rect.width = width * 0.45f; parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel); rect.width = width * 0.5f; rect.x += rect.width; } var oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 13; var result = EditorGUI.FloatField(rect, new GUIContent("F"), parameter.GetAs <float>()); parameter.SetAs(result); EditorGUIUtility.labelWidth = oldWidth; }
private static void DrawAsBool(Rect rect, Variant parameter, bool label) { if (label) { var width = rect.width; rect.width = rect.width * 0.45f; parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel); rect.width = width * 0.5f; rect.x += rect.width + 2; } rect.width *= 0.5f; rect.y -= 1; var result = EditorGUI.Toggle(rect, GUIContent.none, parameter.GetAs <bool>()); parameter.SetAs(result); rect.y += 1; rect.x += 20; GUI.Label(rect, result.ToString(), EditorStyles.label); }
public void SetTo(Variant parameter) { parameter.SetAs <T>(value); }