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; 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); } } } }
/// <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); } } } }
private static int DoLessThen4Draw(Rect position, SerializedProperty property, int buttonsIntValue, float labelWidth, int enumLength, bool[] buttonPressed) { using (var scope = Disposables.RectHorizontalScope(enumLength, position.Edit(RectEdit.SetWidth(position.width - labelWidth), RectEdit.AddX(labelWidth)))) { for (var i = 0; i < enumLength; i++) { // Check if the button is/was pressed if ((property.intValue & 1 << i) == (1 << i)) { buttonPressed[i] = true; } buttonPressed[i] = GUI.Toggle(scope.GetNext(), buttonPressed[i], property.enumNames[i], "Button"); if (buttonPressed[i]) { buttonsIntValue += 1 << i; } } } return(buttonsIntValue); }