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); } } } } }
//TODO: add Un Parent Button private void DrawChildObject(Object obj, int index) { using (Disposables.HorizontalScope()) { FoCsGUI.Layout.Label($"[{index}] {obj.GetType().Name.SplitCamelCase()}", GUILayout.Width(Screen.width / 4f)); using (var changeCheckScope = Disposables.ChangeCheck()) { using (Disposables.IndentSet(0)) obj.name = EditorGUILayout.DelayedTextField(obj.name); if (changeCheckScope.changed) { EditorUtility.SetDirty(target); AssetDatabase.ImportAsset(AssetPath(target)); } } var deleteEvent = FoCsGUI.Layout.Button(new GUIContent("X"), FoCsGUI.Styles.CrossCircle, GUILayout.Width(FoCsGUI.Styles.CrossCircle.Style.fixedWidth)); if (deleteEvent) { if (EditorUtility.DisplayDialog("Delete Child", $"Delete {obj.name}", "Yes Delete", "No Cancel")) { DestroyImmediate(obj, true); EditorUtility.SetDirty(target); AssetDatabase.ImportAsset(AssetPath(target)); Repaint(); repaintCalled = true; return; } } } DoPadding(1, false); }
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 static Vector3 DrawVector3(GUIContent label, Vector3 vec, Vector3 defaultValue, Obj objectIAmOn, out bool GUIChanged) { using (Disposables.IndentSet(1)) { using (Disposables.HorizontalScope()) { using (var cc = Disposables.ChangeCheck()) { vec = EditorGUILayout.Vector3Field(label, vec); GUIChanged = cc.changed; } var cachedGuiColor = GUI.color; using (Disposables.HorizontalScope(EditorStyles.toolbar)) { var resetBtn = FoCsGUI.Layout.Button(ResetContent, EditorStyles.toolbarButton, GUILayout.Width(25)); var copyBtn = FoCsGUI.Layout.Button(CopyContent, EditorStyles.toolbarButton, GUILayout.Width(25)); var pasteBtn = FoCsGUI.Layout.Button(PasteContent, EditorStyles.toolbarButton, GUILayout.Width(25)); if (resetBtn) { Undo.RecordObject(objectIAmOn, "Vector 3 Reset"); vec = defaultValue; GUIChanged = true; } else if (copyBtn) { CopyPasteUtility.EditorCopy(vec); } else if (pasteBtn) { Undo.RecordObject(objectIAmOn, "Vector 3 Paste"); vec = CopyPasteUtility.Paste <Vector3>(); GUIChanged = true; } GUI.color = cachedGuiColor; } } } return(vec); }
protected override void DoExtraDraw() { using (Disposables.IndentSet(1)) { FoCsGUI.Layout.Label("Editor Only:"); MyMode = (Mode)EditorGUILayout.EnumPopup(MyMode); resolution = FoCsGUI.Layout.Slider(new GUIContent("Resolution", "The Curve Display Resolution"), resolution, 0.01f, 0.5f); debugTransform = FoCsGUI.Layout.ObjectField(debugTransform, new GUIContent("Example"), true); using (var change = Disposables.ChangeCheck()) { DebugTime = FoCsGUI.Layout.Slider(new GUIContent("Lerp Time: ", "Lerp Time"), DebugTime, 0f, 1f); UseGizmo = FoCsGUI.Layout.ToggleField("Use Gizmos", UseGizmo); if (change.changed && UseGizmo) { SceneView.RepaintAll(); } } if (debugTransform) { debugTransform.SetFromTD(Target.Lerp(DebugTime)); } } }