private static void LayoutAsTypePicker(GenericParameter 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, GenericParameter 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)); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var type = property.GetAs <DerivedType>(); if (type == null) { return; } position.width *= 0.5f; string baseContent = type.BaseType != null && type.BaseType.Type != null ? $"{type.BaseType.Type.Name} (System.Type)" : "None (System.Type)"; if (EditorGUI.DropdownButton(position, new GUIContent(baseContent), FocusType.Keyboard)) { KnownTypeUtils.ShowAddParameterMenu(t => { if (t != type.BaseType) { type.BaseType = t; type.TypeValue = null; } }); } position.x += position.width; string derivedContent = type.DisplayedName; if (EditorGUI.DropdownButton(position, new GUIContent(derivedContent), FocusType.Keyboard)) { ReferenceTypePicker.ShowWindow(type.BaseType.Type, t => { type.TypeValue = new SerializedType(t); }, t => t.IsSubclassOf(type.BaseType.Type)); } }
private void OnAddParameter(Rect buttonrect, ReorderableList list) { Positions.Resize(Parameters.Count); KnownTypeUtils.ShowAddParameterMenu(AddNewParam); }