private static void LayoutAsDerivedTypePicker(GenericParameter 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 void AddCondition(Rect buttonrect, ReorderableList list) { ReferenceTypePicker.ShowWindow(typeof(Condition), t => { OnConditionAdded(list, t); }, t => t.IsSubclassOf(typeof(Condition))); }
private void OnAddNewParameter(Type type) { if (type.IsSubclassOf(typeof(UnityEngine.Object)) && type != typeof(GameObject)) { ReferenceTypePicker.ShowWindow(type, OnObjectReferenceTypeSelected, t => t.IsSubclassOf(type)); } else { AddNewParam(type); } }
private static void OnAddNewParameter(System.Type type, System.Action <SerializedType> callback) { if (type == typeof(DerivedType)) { ReferenceTypePicker.ShowWindow(KnownType.ObjectType, t => callback(new SerializedType(type, t.AssemblyQualifiedName)), t => t.IsSubclassOf(KnownType.ObjectType)); } else if (type.IsSubclassOf(typeof(UnityEngine.Object)) && type != typeof(GameObject)) { ReferenceTypePicker.ShowWindow(type, t => callback(new SerializedType(t)), t => t.IsSubclassOf(type)); } else { callback(new SerializedType(type)); } }
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)); } }