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); } }
//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 override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (!GetAttribute.DrawButtons) { property.intValue = EditorGUI.MaskField(position, label, property.intValue, property.enumNames); return; } var buttonsIntValue = 0; var labelWidth = EditorGUIUtility.labelWidth; var enumLength = property.enumNames.Length; var buttonPressed = new bool[enumLength]; FoCsGUI.Label(new Rect(position.x, position.y, labelWidth, position.height), label); using (var cc = Disposables.ChangeCheck()) { //if(property.enumNames.Length <= 4) buttonsIntValue = DoLessThen4Draw(position, property, buttonsIntValue, labelWidth, enumLength, buttonPressed); //else // buttonsIntValue = DoMoreThen4Draw(position, property, buttonsIntValue, labelWidth, enumLength, buttonPressed); if (cc.changed) { property.intValue = buttonsIntValue; } } }
private void DrawMenuTabs() { FoCsGUI.Layout.LabelField("Categories of Scriptable Objects that can be added", FoCsGUI.Styles.Unity.BoldLabel); var width = (Screen.width / 200) + 1; var nameList = typeDictionary.Keys.ToList(); if (!nameList.InRange(ActiveTab)) { ActiveTab = 0; } for (var i = 0; i < nameList.Count; i += width) { if (!nameList.InRange(i)) { break; } using (Disposables.HorizontalScope(FoCsGUI.Styles.Toolbar)) { for (var j = 0; j < width; j += 1) { var index = i + j; if (!nameList.InRange(index)) { break; } var key = nameList[index]; if (ActiveTab == index) { ActiveTabName = key; } using (var cc = Disposables.ChangeCheck()) { var @event = FoCsGUI.Layout.Toggle(key.ToggleName.SplitCamelCase(), ActiveTab == index, FoCsGUI.Styles.Unity.ToolbarButton); if (cc.changed && @event) { if (ActiveTab == index) { continue; } ActiveTab = index; ActiveTabName = key; Repaint(); repaintCalled = true; return; } } } } } }
public void OnSceneGUI() { if (UseGizmo && !debugTransform) { var data = Target.Lerp(DebugTime); Handles.DrawWireCube(data, Vector3.one); } using (var cc = Disposables.ChangeCheck()) { if ((Curve == null) || Curve.CurvePositions.IsNullOrEmpty()) { return; } if (MyMode == Mode.Move) { var pos = Curve.CurvePositions; for (var i = 0; i < pos.Count; i++) { using (var undoCheck = Disposables.ChangeCheck()) { if (!Curve.UseGlobalSpace) { pos[i] = Target.transform.TransformPoint(pos[i]); } pos[i] = Handles.DoPositionHandle(Curve.CurvePositions[i], Quaternion.identity); Handles.Label(pos[i], new GUIContent($"Index: {i}")); if (!Curve.UseGlobalSpace) { pos[i] = Target.transform.InverseTransformPoint(pos[i]); } if (undoCheck.changed) { Undo.RecordObject(Curve, "Changed Curve Position"); } } } Curve.CurvePositions = pos; } for (float i = 0; i < 1f; i += resolution) { Handles.DrawLine(Target.Lerp(i), Target.Lerp((i + resolution).Clamp())); } if (cc.changed) { EditorUtility.SetDirty(target); } } }
private static void DrawExpanded(Rect position, SerializedProperty property) { var val = property.quaternionValue; using (var cc = Disposables.ChangeCheck()) { using (Disposables.SetIndent(0)) val.eulerAngles = EditorGUI.Vector3Field(position.Edit(RectEdit.SetHeight(SingleLine), RectEdit.SubtractWidth(2)), GUIContent.none, val.eulerAngles); if (cc.changed) { property.quaternionValue = val; } } }
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(); } } } }
protected override void OnGUI() { FoCsGUI.Layout.Label(Heading); using (Disposables.HorizontalScope()) { using (var cc = Disposables.ChangeCheck()) { versionNumber = FoCsGUI.Layout.DelayedTextField(versionNumber); if (cc.changed) { BundleVersion.stringValue = versionNumber; SerializedObject.ApplyModifiedProperties(); } } } }
private static void DrawDropDown(SerializedProperty Axis, Rect pos) { var array = ReadInputManager.GetAxisNames(); var num = -1; if (array.Contains(Axis.stringValue)) { num = array.ToList().IndexOf(Axis.stringValue); } using (var cc = Disposables.ChangeCheck()) { var index = EditorGUI.Popup(pos, PopupContent, num, array.Select(a => new GUIContent(a)).ToArray()); if (cc.changed && array.InRange(index)) { Axis.stringValue = array[index]; } } }
protected override void OnGUI() { if (ObjectsToEditors.IsNullOrEmpty()) { ObjectsToEditors = new Dictionary <Object, UEditor>(); } if (Object.IsNullOrEmpty()) { Object = new List <Object>(); } using (var scroll = Disposables.ScrollViewScope(scrollPos, true, FoCsGUI.LayoutOptions.Expand())) { scrollPos = scroll.scrollPosition; using (Disposables.HorizontalScope()) { foreach (var o in Object) { if (!ObjectsToEditors.ContainsKey(o)) { GenerateEditor(o); } using (Disposables.VerticalScope(FoCsGUI.LayoutOptions.Width(500))) ObjectsToEditors[o].OnInspectorGUI(); } } } using (var cc = Disposables.ChangeCheck()) { var obj = FoCsGUI.Layout.ObjectField <Object>(null, Label, true); if (cc.changed) { if (obj != null) { Object.AddWithDuplicateCheck(obj); GenerateEditor(obj); } } } }
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 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)); } } }
public override void DrawTab(FoCsWindow <AdvancedUnitySettingsWindow> owner) { //if(storage == null) // storage = new UnityReorderableListStorage(owner); using (Disposables.HorizontalScope(GUI.skin.box)) EditorGUILayout.LabelField(TabName); using (Disposables.HorizontalScope()) { DrawSpace(LEFT_BORDER * 0.5f); Search = FoCsGUI.Layout.TextField(SearchGuiContent, Search); } using (Disposables.LabelAddWidth(EXTRA_LABEL_WIDTH)) { using (Disposables.SetIndent(1)) { //if(handlerControllers.IsNullOrEmpty()) //{ // handlerControllers = new HandlerController[Assets.Length]; // // for(var i = 0; i < handlerControllers.Length; i++) // handlerControllers[i] = new HandlerController(); //} for (var i = 0; i < Assets.Length; i++) { var asset = Assets[i]; //var handlerController = handlerControllers[i]; asset.Update(); //handlerController.VerifyIPropertyLayoutHandlerArrayNoObject(storage); //handlerController.VerifyHandlingDictionary(asset); using (Disposables.HorizontalScope()) { DrawSpace(LEFT_BORDER); using (var scrollViewScope = Disposables.ScrollViewScope(vector2, true)) { vector2 = scrollViewScope.scrollPosition; using (var changeCheckScope = Disposables.ChangeCheck()) { foreach (var property in asset.Properties()) { if (Search.IsNullOrEmpty()) { FoCsGUI.Layout.PropertyField(property); } else if (property.name.ToLower().Contains(Search.ToLower())) { FoCsGUI.Layout.PropertyField(property); } } if (changeCheckScope.changed) { asset.ApplyModifiedProperties(); } } } DrawSpace(RIGHT_BORDER); } } } } DrawFooter(); }
public void OnSceneGUI() { if (UseGizmo && !debugTransform) { var data = Target.Lerp(DebugTime); var matrix = Handles.matrix; var rotationMatrix = Matrix4x4.TRS(data.Position, data.Rotation, data.Scale); Handles.matrix = rotationMatrix; Handles.DrawWireCube(Vector3.zero, Vector3.one); Handles.matrix = matrix; } using (var cc = Disposables.ChangeCheck()) { if ((Curve == null) || Curve.CurvePositions.IsNullOrEmpty()) { return; } var pos = Curve.CurvePositions; for (var i = 0; i < pos.Count; i++) { using (var undoCheck = Disposables.ChangeCheck()) { var tdPos = Curve.CurvePositions[i].Position; if (!Target.UseGlobalSpace) { tdPos = Target.transform.TransformPoint(tdPos); } var tdScl = Curve.CurvePositions[i].Scale; var tdRot = Curve.CurvePositions[i].Rotation; switch (MyMode) { case Mode.Move: tdPos = Handles.DoPositionHandle(tdPos, tdRot); break; case Mode.Rotate: tdRot = Handles.DoRotationHandle(tdRot, tdPos); break; case Mode.Scale: tdScl = Handles.ScaleHandle(tdScl, tdPos, tdRot, HandleUtility.GetHandleSize(tdPos)); break; case Mode.MoveRotate: tdPos = Handles.DoPositionHandle(tdPos, tdRot); tdRot = Handles.DoRotationHandle(tdRot, tdPos); break; case Mode.RotateShowMoveArrows: Handles.DoPositionHandle(tdPos, tdRot); tdRot = Handles.DoRotationHandle(tdRot, tdPos); break; } Handles.Label(tdPos, new GUIContent($"Index: {i}")); if (!Target.UseGlobalSpace) { tdPos = Target.transform.InverseTransformPoint(tdPos); } //pos[i].UpdateData(tdPos, tdRot, tdScl); pos[i] = new TransformData(tdPos, tdRot, tdScl); if (undoCheck.changed) { Undo.RecordObject(Curve, "Changed Curve Position"); } } } Curve.CurvePositions = pos; for (float i = 0; i < 1f; i += resolution) { Handles.DrawLine(Target.Lerp(i).Position, Target.Lerp((i + resolution).Clamp()).Position); } if (cc.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); } } }
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"); } } } } }