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 OnInspectorGUI() { using (Disposables.Indent()) { DoDrawHeader(); VerifyHandler(); using (var changeCheckScope = Disposables.ChangeCheck()) { serializedObject.Update(); foreach (var serializedProperty in serializedObject.Properties()) { if (serializedProperty.name == "storedValue") { DoTextBox(serializedProperty); } else { DrawProperty(serializedProperty); } } if (changeCheckScope.changed) { serializedObject.ApplyModifiedProperties(); } } FoCsGUI.Layout.GetControlRect(false, FoCsGUI.Padding); } }
private static Action <Rect> GetStringAction(SerializedProperty property, RangeAttribute range) { return(rect => { using (Disposables.Indent(-1)) RangeAttributeDrawer.DoString(rect, property.FindPropertyRelative("LocalValue"), GUIContent.none, range); }); }
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); } } } }
/// <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 OnInspectorGUI() { serializedObject.Update(); using (Disposables.Indent()) { using (var cc = Disposables.ChangeCheck()) { AnimatorKeyDrawer.DoDraw(FoCsGUI.Layout.GetControlRect(true, FoCsGUI.SingleLine), serializedObject.FindProperty("storedValue"), ValueContent); if (cc.changed) { serializedObject.ApplyModifiedProperties(); } } } }
private void DrawChildrenGUI() { using (Disposables.Indent()) { var assets = AssetDatabase.LoadAllAssetsAtPath(AssetPath()); if (assets.Length <= 1) { return; } using (Disposables.HorizontalScope(FoCsGUI.Styles.Toolbar)) showChildrenSettings = FoCsGUI.Layout.Foldout(showChildrenSettings, $"Children [{assets.Length - 1}]"); if (!showChildrenSettings) { return; } using (Disposables.VerticalScope(GUI.skin.box)) { for (var i = 0; i < assets.Length; i++) { var obj = assets[i]; if (!obj) { continue; } if (AssetDatabase.IsSubAsset(obj)) { DrawChildObject(obj, i); } if (repaintCalled) { return; } } } } }
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"); } } } } }