public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; //check if the property we want to draw should be enabled var enabled = GetConditionalHideAttributeResult(GetAttribute, property); //Enable/disable the property var wasEnabled = GUI.enabled; GUI.enabled = enabled; //Check if we should draw the property if (!GetAttribute.HideInInspector || enabled) { property.isExpanded = true; using (Disposables.Indent()) EditorGUI.PropertyField(position, property, label, true); } else { property.isExpanded = false; } //Ensure that the next property that is being drawn uses the correct settings GUI.enabled = wasEnabled; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { var rect = position; label = propScope.content; property.isExpanded = true; if (GetAttribute.ShowVariableName) { rect.height = SingleLine; EditorGUI.LabelField(rect, label); rect.y += SingleLine; } property.NextVisible(true); using (Disposables.Indent()) { foreach (var child in property.GetChildren()) { FoCsGUI.PropertyField(rect, child, true, FoCsGUI.AttributeCheck.DoCheck); rect.y += FoCsGUI.GetPropertyHeight(child, GUIContent.none, true, FoCsGUI.AttributeCheck.DoCheck); } } } }
public static void DoDraw(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { position.height = SingleLine; label = propScope.content; var labelPos = position.Edit(RectEdit.SetWidth(EditorGUIUtility.labelWidth)); FoCsGUI.Label(labelPos, label); using (var scope = Disposables.RectHorizontalScope(6, position.Edit(RectEdit.AddX(labelPos.width), RectEdit.SetWidth(position.width - labelPos.width)))) { using (Disposables.IndentSet(0)) { using (var innerScope = Disposables.RectHorizontalScope(3, scope.GetNext(2))) { FoCsGUI.Label(innerScope.GetNext(), KEY_LABEL); FoCsGUI.PropertyField(innerScope.GetNext(2), property.FindPropertyRelative(KEY), GUIContent.none); } using (var innerScope = Disposables.RectHorizontalScope(5, scope.GetNext(2))) { FoCsGUI.Label(innerScope.GetNext(2), KEY_TYPE_LABEL); FoCsGUI.PropertyField(innerScope.GetNext(3), property.FindPropertyRelative(KEY_TYPE), GUIContent.none); } using (var innerScope = Disposables.RectHorizontalScope(5, scope.GetNext(2))) { var key = property.GetTargetObjectOfProperty <AnimatorKey>(); var typeStr = GetDisplayString(key); FoCsGUI.Label(innerScope.GetNext(2), LABEL); FoCsGUI.PropertyField(innerScope.GetNext(3), property.FindPropertyRelative(typeStr), GUIContent.none); } } } } }
public static void Draw(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; position.height = SingleLine; ShowAngles = FoCsGUI.DrawActionWithMenu(position, rect => DoDraw(rect, property), label, Options, ShowAngles? 0 : 1) == 0; } }
/// <inheritdoc /> public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var prop = Disposables.PropertyScope(position, label, property)) { var owner = GetTargetObject(property); FoCsGUI.Label(position.Edit(RectEdit.SetHeight(SingleLine)), prop.content); DoDragDrop(position.Edit(RectEdit.MultiplyWidth(0.5f)), property); using (Disposables.Indent()) { var Position = property.FindPropertyRelative("Position"); var Rotation = property.FindPropertyRelative("Rotation"); var Scale = property.FindPropertyRelative("Scale"); using (var horizontalScope = Disposables.RectHorizontalScope(5, position.Edit(RectEdit.SetHeight(SingleLine - 2), RectEdit.DivideWidth(2), RectEdit.AddX(position.width * 0.5f)))) { var copyBtn = FoCsGUI.Button(horizontalScope.GetNext(2), CopyContent); var isType = CopyPasteUtility.IsTypeInBuffer(owner); FoCsGUI.GUIEventBool pasteBtn; using (Disposables.ColorChanger(isType? GUI.color : Color.red)) pasteBtn = FoCsGUI.Button(horizontalScope.GetNext(2), PasteContent); var resetBtn = FoCsGUI.Button(horizontalScope.GetNext(1), ResetContent); if (copyBtn) { CopyPasteUtility.Copy(GetTargetObject(property)); } else if (pasteBtn) { var tD = CopyPasteUtility.Paste <TransformData>(); Undo.RecordObject(property.serializedObject.targetObject, "Paste TD"); Position.vector3Value = tD.Position; Scale.vector3Value = tD.Scale; Rotation.quaternionValue = tD.Rotation; } else if (resetBtn) { Undo.RecordObject(property.serializedObject.targetObject, "Reset TD"); var tD = TransformData.Empty; Position.vector3Value = tD.Position; Scale.vector3Value = tD.Scale; Rotation.quaternionValue = tD.Rotation; } } using (var vertScope = Disposables.RectVerticalScope(3, position.Edit(RectEdit.SetHeight(SingleLine * 3), RectEdit.AddY(SingleLine)))) { Vector3PropEditor.Draw(vertScope.GetNext(), Position, PositionContent); QuaternionPropertyDrawer.Draw(vertScope.GetNext(), Rotation, RotationContent); Vector3PropEditor.Draw(vertScope.GetNext(), Scale, ScaleContent); } } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var showLabel = ShowLabel(label.text); using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; if (EditorGUI.indentLevel <= 1) { position = position.Edit(RectEdit.ChangeX(16f)); } var axisProp = property.FindPropertyRelative("Axis"); var ValueInverted = new EditorEntry("Invert Result", property.FindPropertyRelative("ValueInverted")); var OnlyButtonEvents = new EditorEntry("Only Button Events", property.FindPropertyRelative("OnlyButtonEvents")); var UseSmoothInput = new EditorEntry("Use Smooth Input", property.FindPropertyRelative("UseSmoothInput")); var Axis = new EditorEntry($"Axis: {axisProp.stringValue}", axisProp); var value = new EditorEntry($"{(ValueInverted.Property.boolValue? "Non Inverted " : "")}Value", property.FindPropertyRelative(UseSmoothInput.Property.boolValue? "valueSmooth" : "valueRaw")); var deadZone = new EditorEntry("DeadZone", property.FindPropertyRelative("deadZone")); using (var horizontalScope = Disposables.RectHorizontalScope(2, position)) { using (Disposables.LabelFieldSetWidth(horizontalScope.FirstRect.width * LABEL_SIZE)) { using (var verticalScope = Disposables.RectVerticalScope(showLabel? 5 : 4, horizontalScope.GetNext())) { if (showLabel) { FoCsGUI.Label(verticalScope.GetNext(RectEdit.SetHeight(SingleLine), RectEdit.SubtractX(16f)), label); } DrawDropDown(Axis, verticalScope.GetNext(RectEdit.SetHeight(SingleLine))); ProgressBar(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)), value); deadZone.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine))); OnlyButtonEvents.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine))); } using (var verticalScope = Disposables.RectVerticalScope(showLabel? 5 : 4, horizontalScope.GetNext(RectEdit.ChangeX(SingleLine)))) { if (showLabel) { verticalScope.GetNext(); } Axis.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine))); value.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine))); ValueInverted.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine))); UseSmoothInput.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine))); } } } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; var fieldPosition = position; fieldPosition.height = textHeight; DrawTextField(fieldPosition, property, label); var helpPosition = EditorGUI.IndentedRect(position); helpPosition.y += textHeight; helpPosition.height = helpHeight; DrawHelpBox(helpPosition, property); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; // First get the attribute since it contains the range for the scrollbar var range = attribute as RangeAttribute; var pos = position; pos.height = SingleLine; // Now draw the property as a Slider or an IntSlider based on whether it's a float or integer. switch (property.propertyType) { case SerializedPropertyType.Float: DoFloat(position, property, label, range); break; case SerializedPropertyType.String: DoNamedString(position, property, label, range); break; case SerializedPropertyType.Integer: DoInt(position, property, label, range); break; case SerializedPropertyType.Vector2: DoVector2(position, property, label, range, pos); break; case SerializedPropertyType.Vector3: DoVector3(position, property, label, range, pos); break; case SerializedPropertyType.Generic: foldout = DoGeneric(position, property, label, range, foldout); break; default: DrawErrorMessage(position, label); break; } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; using (Disposables.LabelFieldSetWidth((position.width / GetAttribute.totalAmount) * 0.5f)) { using (var scope = Disposables.RectHorizontalScope(GetAttribute.totalAmount, position)) { for (var i = 0; i < GetAttribute.index; i++) { scope.GetNext(); } FoCsGUI.PropertyField(scope.GetNext(RectEdit.SubtractY(SingleLinePlusPadding * GetAttribute.index), RectEdit.SetHeight(SingleLine)), property, label); } } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; if (GetAttribute.AllowConfirmedEdit) { GetAttribute.CurrentlyEditable = FoCsGUI.DrawDisabledPropertyWithMenu(!GetAttribute.CurrentlyEditable, position, property, label, OPTIONS_ARRAY, GetAttribute.CurrentlyEditable? 0 : 1) .Value == 0; } else { using (Disposables.DisabledScope()) FoCsGUI.PropertyField(position, property, label, true, false); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; using (var cc = Disposables.ChangeCheck()) { GetAttribute.CallSetter = FoCsGUI.DrawPropertyWithMenu(position, property, label, OPTIONS_ARRAY, GetAttribute.CallSetter? 0 : 1).Value == 0; if (cc.changed) { GetAttribute.dirty = true; } } if (GetAttribute.dirty) { ElseLogic(property); } } }
public static void Draw(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; position.height = SingleLine; if (string.IsNullOrEmpty(label.text)) { DoFieldsDraw(position, property); } else { EditorGUI.LabelField(position, label); using (Disposables.IndentSet(0)) { var pos = position.Edit(RectEdit.AddX(EditorGUIUtility.labelWidth), RectEdit.SubtractWidth(EditorGUIUtility.labelWidth)); DoFieldsDraw(pos, property); } } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; var useGlobalSpaceProp = property.FindPropertyRelative("useGlobalSpace"); var positionsProp = property.FindPropertyRelative("Positions"); var useGlobalBoolRect = position.Edit(RectEdit.SetHeight(SingleLine)); position = position.Edit(RectEdit.ChangeY(SingleLine)); EditorGUI.PropertyField(useGlobalBoolRect, useGlobalSpaceProp); var targ = property.GetTargetObjectOfProperty <ITDCurve>(); if (targ.IsFixedLength) { if (positionsProp.arraySize != targ.Length) { positionsProp.arraySize = targ.Length; } } ListNullCheck(property); list.HandleDrawing(position.Edit(RectEdit.ChangeX(16))); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { using (var propScope = Disposables.PropertyScope(position, label, property)) { label = propScope.content; var rect = position; rect.height = SingleLine; rect.y += 1; var colour = GetTargetObject(property); if (colour == null) { return; } var rect2 = rect; rect2.width = IndentSize; property.isExpanded = EditorGUI.Foldout(rect2, property.isExpanded, ""); rect2 = rect; using (var ChangeCheck = Disposables.ChangeCheck()) { var col = EditorGUI.ColorField(rect2, new GUIContent(property.displayName, property.displayName), colour); colour.SetColor(col); if (!property.isExpanded) { return; } using (Disposables.Indent()) { rect.y += 1 + SingleLine; var A = EditorGUI.IntField(rect, new GUIContent("Alpha", "Alpha"), colour.A); rect.y += 1 + SingleLine; var R = EditorGUI.IntField(rect, new GUIContent("Red", "Red"), colour.R); rect.y += 1 + SingleLine; var G = EditorGUI.IntField(rect, new GUIContent("Green", "Green"), colour.G); rect.y += 1 + SingleLine; var B = EditorGUI.IntField(rect, new GUIContent("Blue", "Blue"), colour.B); rect.y += 1 + SingleLine; if (GUI.Button(rect, new GUIContent("Randomize Colour", "Randomizes the Colour"))) { var colHSV = Random.ColorHSV(); colour.SetColor(colHSV); return; } if (A >= 255) { colour.A = 255; } else if (A <= 0) { colour.A = 0; } else { colour.A = (byte)A; } if (R >= 255) { colour.R = 255; } else if (R <= 0) { colour.R = 0; } else { colour.R = (byte)R; } if (G >= 255) { colour.G = 255; } else if (G <= 0) { colour.G = 0; } else { colour.G = (byte)G; } if (B >= 255) { colour.B = 255; } else if (B <= 0) { colour.B = 0; } else { colour.B = (byte)B; } if (ChangeCheck.changed) { Undo.RecordObject(property.serializedObject.targetObject, "ColourChange"); } } } } }