private void DrawField(ReflectionInfo info, SerializedProperty property) { if (!info.IsVisible) { return; } var result = info.CheckValidate(target, property); if (!result) { ValidatorWindow.GetInstance().RegisterValidation(result, target); GUILayout.BeginVertical(EditorStyles.helpBox); } if (!property.isArray || property.type == "string") { // Somehow check if this type can be drawn other way // Is it defined with attribute? EditorGUILayout.PropertyField(property, true); } else { Pair <bool, ReorderableList> list = ReorderableDrawer.GetList(property); if (property.arrayElementType.Equals(typeof(GenericParameter).Name) && list.First) { list.Second.drawElementCallback += GenericParameterDrawer; list.Second.onAddDropdownCallback += GenericParameterAdd; list.Second.getElementHeightCallback += (e, i) => 16; } list.Second.DoLayoutList(); } if (!result) { GUILayout.BeginVertical(); using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) { GUILayout.Box(SpaceEditorStyles.GetValidationIcon(result.Status), GUIStyle.none, GUILayout.Width(24)); GUILayout.Label(result.Message, EditorStyles.wordWrappedMiniLabel); } GUILayout.EndVertical(); GUILayout.EndVertical(); } }
public void DrawList(ICollection <ValidatorPresenter.ValidationEntry> entries) { ListScroll = EditorGUILayout.BeginScrollView(ListScroll); foreach (var entry in entries) { if (entry.Result) { continue; } if (!ShowErrors && entry.Result.Status == ValidationStatus.Error) { continue; } if (!ShowWarnings && entry.Result.Status == ValidationStatus.Warning) { continue; } GUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); { GUILayout.Box(SpaceEditorStyles.GetValidationIcon(entry.Result.Status), GUIStyle.none, GUILayout.Width(24)); string label = $"{(entry.Target ? entry.Target + " - " : string.Empty)} {entry.Result.Message}"; if (GUILayout.Button(label, EditorStyles.wordWrappedMiniLabel, GUILayout.ExpandWidth(true))) { if (entry.Target) { EditorGUIUtility.PingObject(entry.Target); Selection.activeObject = entry.Target; } } } EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); }
private void DrawField(ReflectionInfo info, SerializedProperty property) { if (!info.IsVisible) { return; } var result = info.CheckValidate(target, property); if (!result) { ValidatorWindow.GetInstance().RegisterValidation(result, target); GUILayout.BeginVertical(EditorStyles.helpBox); } if (!property.isArray || property.type == "string") { // Somehow check if this type can be drawn other way // Is it defined with attribute? EditorGUILayout.PropertyField(property, true); } else { ReorderableList list = ReorderableDrawer.GetList(property); list.DoLayoutList(); } if (!result) { GUILayout.BeginVertical(); using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) { GUILayout.Box(SpaceEditorStyles.GetValidationIcon(result.Status), GUIStyle.none, GUILayout.Width(24)); GUILayout.Label(result.Message, EditorStyles.wordWrappedMiniLabel); } GUILayout.EndVertical(); GUILayout.EndVertical(); } }
private void DrawField(ReflectionInfo info, SerializedProperty property) { if (!info.IsVisible) { return; } var result = info.CheckValidate(target, property); if (!result) { ValidatorWindow.GetInstance().RegisterValidation(result, target); var rect = GUILayoutUtility.GetLastRect(); var spacedPadding = (info.Spaced ? 24 : 0); var notSpacedPadding = (info.Spaced ? 0 : 0); rect.y += rect.height + spacedPadding + notSpacedPadding; rect.height = EditorGUI.GetPropertyHeight(property) - spacedPadding; rect.y += 1; rect.width += rect.x + 4; rect.x = 0; rect.height += 2; GUI.color = new Color(0.6f, 0f, 0f, 0.6f); GUI.Box(rect, GUIContent.none, SpaceEditorStyles.LightBox); GUI.color = Color.white; GUILayout.BeginVertical(); } if (!property.isArray || property.type == "string") { // Somehow check if this type can be drawn other way // Is it defined with attribute? EditorGUILayout.PropertyField(property, true); } else { var(initialize, list) = ReorderableDrawer.GetList(property); if (initialize) { if (property.arrayElementType.Equals(typeof(Variant).Name)) { list.drawElementCallback += GenericParameterDrawer; list.onAddDropdownCallback += GenericParameterAdd; list.getElementHeightCallback += (e, i) => 16; } else if (property.arrayElementType.Equals(typeof(Framework.Parameter).Name)) { list.drawElementCallback += ParameterDraw; list.onAddDropdownCallback += ParameterAdd; list.getElementHeightCallback += (e, i) => 16; } } list.DoLayoutList(); } if (!result) { GUILayout.BeginVertical(); using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) { GUILayout.Box(SpaceEditorStyles.GetValidationIcon(result.Status), GUIStyle.none, GUILayout.Width(24)); GUILayout.Label(result.Message, EditorStyles.wordWrappedMiniLabel); } GUILayout.EndVertical(); GUILayout.EndVertical(); } }