private static void LayoutAsDerivedTypePicker(Variant parameter, bool label) { EditorGUILayout.BeginHorizontal(); { if (label) { parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth)); } var type = parameter.GetAs <DerivedType>(); string content = "None"; if (type.BaseType != null && type.BaseType.Type != null) { if (type.TypeValue != null && type.TypeValue.Type != null) { content = $"{type.TypeValue.Type.Name} ({type.BaseType.Type.Name})"; } else { content = "None ({type.BaseType.Type.Name})"; } } if (EditorGUILayout.DropdownButton(new GUIContent(content), FocusType.Keyboard)) { SerializedType sysType = type.BaseType ?? new SerializedType(parameter.HoldType.Metadata); ReferenceTypePicker.ShowWindow(sysType.Type, BuildDerivedTypeCallback(parameter, sysType.Type), t => t.IsSubclassOf(sysType.Type)); } } EditorGUILayout.EndHorizontal(); }
private static void DrawAsDerivedTypePicker(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 type = parameter.GetAs <DerivedType>(); string content = type.DisplayedName; if (EditorGUI.DropdownButton(rect, new GUIContent(content), FocusType.Keyboard)) { SerializedType sysType = type.BaseType ?? new SerializedType(parameter.HoldType.Metadata); ReferenceTypePicker.ShowWindow(sysType.Type, BuildDerivedTypeCallback(parameter, sysType.Type), t => t.IsSubclassOf(sysType.Type)); } }
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 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 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 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 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 LayoutAsTypePicker(Variant parameter, bool label) { EditorGUILayout.BeginHorizontal(); { if (label) { parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth)); } var type = parameter.GetAs <SerializedType>(); string content = type.Type != null ? $"{type.Type.Name} (System.Type)" : "None (System.Type)"; if (EditorGUILayout.DropdownButton(new GUIContent(content), FocusType.Keyboard)) { KnownTypeUtils.ShowAddParameterMenu(BuildSerializedTypeCallback(parameter)); } } EditorGUILayout.EndHorizontal(); }
private static void DrawAsTypePicker(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 type = parameter.GetAs <SerializedType>(); string content = type.Type != null ? $"{type.Type.Name} (System.Type)" : "None (System.Type)"; if (EditorGUI.DropdownButton(rect, new GUIContent(content), FocusType.Keyboard)) { KnownTypeUtils.ShowAddParameterMenu(BuildSerializedTypeCallback(parameter)); } }
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 GetFrom(Variant parameter) { value = parameter.GetAs <T>(); }