public override void OnGUI(Rect area, SerializedProperty property, GUIContent label) { EditorUI.Reset(); AttributeTransition transition = property.GetObject <AttributeTransition>(); var spacing = area.height = EditorGUIUtility.singleLineHeight; if (!transition.time.isSetup) { return; } if ("Transition".ToLabel().DrawFoldout(area, transition.path, null, true)) { GUI.changed = false; EditorGUI.indentLevel += 1; transition.time.Set(transition.time.Get().Draw(area.AddY(spacing + 2), "Time")); transition.speed.Set(transition.speed.Get().Draw(area.AddY(spacing * 2 + 4), "Speed")); transition.acceleration = transition.acceleration.Draw(area.AddY(spacing * 3 + 6), "Acceleration"); transition.deceleration = transition.deceleration.Draw(area.AddY(spacing * 4 + 8), "Deceleration"); EditorGUI.indentLevel -= 1; if (GUI.changed) { property.serializedObject.targetObject.DelayEvent("On Validate", 1); transition.Setup(transition.path, transition.parent); } } }
public void DrawProfileSelect() { if (this.uiState == InputUIState.SelectProfile) { //var path = "@Main/InputUI/ProfileSelect/"; //Locate.Find(path).SetActive(true); var buttonWidth = Screen.width * 0.5f; var buttonHeight = Screen.height * 0.09f; var area = new Rect((Screen.width / 2) - buttonWidth / 2, 10, buttonWidth, buttonHeight); var style = GUI.skin.button.Font("Bombardier.otf").FontSize((int)(buttonHeight * 0.7f)); GUI.Label(area, this.selectionHeader, style.Background("")); area = area.AddY(buttonHeight + 8); foreach (var profile in this.profiles.Copy()) { bool usable = this.devices.Select(x => x.name).ContainsAll(profile.requiredDevices); if (!usable) { GUI.enabled = false; } if (GUI.Button(area, profile.name, style)) { this.activeProfile = profile; this.uiState = InputUIState.None; InputState.disabled = false; this.DelayEvent("On Profile Selected", 0); } GUI.enabled = true; area = area.AddY(buttonHeight + 5); } } }
public override void OnGUI(Rect p, SerializedProperty prop, GUIContent label) { p = p.SetHeight(20); EditorGUI.LabelField(p, label); EditorGUI.indentLevel += 1; EditorGUI.PropertyField(p.AddY(20), prop.FindPropertyRelative("X")); EditorGUI.PropertyField(p.AddY(40), prop.FindPropertyRelative("Y")); EditorGUI.indentLevel -= 1; }
public override void OnGUI(Rect area, SerializedProperty property, GUIContent label) { EditorUI.Reset(); float singleLine = EditorGUIUtility.singleLineHeight; area = area.SetHeight(singleLine); bool expanded = EditorPref.Get <bool>("layerDistancesExpanded"); expanded = EditorGUI.Foldout(area, expanded, "Layer Cull Distances"); EditorPref.Set <bool>("layerDistancesExpanded", expanded); if (expanded) { EditorGUI.indentLevel += 1; this.drawn = 0; float[] values = property.FindPropertyRelative("values").GetObject <float[]>(); for (int index = 0; index < 32; index++) { string layerName = LayerMask.LayerToName(index); //if(layerName.IsEmpty()){layerName = "[Unnamed]";} if (!layerName.IsEmpty()) { area = area.AddY(singleLine + 2); values[index] = values[index].Draw(area, new GUIContent(layerName)); this.drawn += 1; } } EditorGUI.indentLevel -= 1; } }
public override void DrawGroupRow(AttributeData data, int index, bool drawAdvanced) { float lineHeight = EditorGUIUtility.singleLineHeight + 2; Rect original = this.fullRect; this.operatorOverride = null; this.SetupAreas(this.fullRect.AddY(lineHeight).Scale(0.48f, 1)); this.labelRect = this.labelRect.SetWidth(1); this.valueRect = this.fullRect.Add(this.labelRect.width, 0, -labelRect.width, 0); if (data.usage == AttributeUsage.Direct) { data.usage = AttributeUsage.Shaped; } this.attribute.canDirect = false; this.DrawFormulaPart(data, index); if (GUI.changed) { this.dirty = true; GUI.changed = false; } int dataIndex = this.attribute.data.IndexOf(data); AttributeData[] dataB = this.attribute.info.dataB; this.SetupAreas(this.fullRect.AddX(this.fullRect.width + 3)); this.labelRect = this.labelRect.SetWidth(1); this.valueRect = this.fullRect.Add(this.labelRect.width, 0, -labelRect.width, 0); this.activeDataset = dataB; this.attribute.defaultSet = "B"; if (dataIndex < dataB.Length && dataB[dataIndex] != null) { string dataType = data.GetType().Name.Remove("Data", "Attribute").Replace("Int", "Number").Replace("Float", "Number"); string compareType = dataB[dataIndex].GetType().Name.Remove("Data", "Attribute").Replace("Int", "Number").Replace("Float", "Number"); if (!AttributeBool.comparers.ContainsKey(dataType + compareType)) { string warning = "Cannot compare <b>" + dataType + "</b> and <b>" + compareType + "</b>."; if (this.valueRect.Clicked(0) || this.valueRect.Clicked(1)) { this.DrawTypeMenu(dataB[dataIndex]); } warning.Draw(this.valueRect, "", this.skin.GetStyle("WarningLabel")); } else { this.operatorOverride = AttributeBool.comparers[dataType + compareType].ToList(); if (AttributeBool.comparers.ContainsKey(dataType + compareType)) { this.attribute.canDirect = true; this.DrawFormulaPart(dataB[dataIndex], index + 1); } } } else if (GUI.Button(this.valueRect.SetWidth(120), "Add Comparison")) { this.DrawAddMenu(); } this.attribute.defaultSet = "A"; this.activeDataset = this.attribute.info.data; this.fullRect = original.AddY(lineHeight); this.drawer.overallHeight += lineHeight; }
public bool IsVisible(Rect area, Rect region, Vector2 scroll) { bool fixedX = area.AddX(-scroll.x).Overlaps(region); bool fixedY = area.AddY(-scroll.y).Overlaps(region); bool fixedXY = area.AddXY(-scroll).Overlaps(region); bool normal = area.Overlaps(region); return(normal || fixedX || fixedY || fixedXY); }
public override void OnGUI(Rect p, MaterialProperty prop, GUIContent label, MaterialEditor editor) { p = p.SetHeight(18); var val = prop.vectorValue; val.x = EditorGUI.FloatField(p, "Distort Power", val.x); val.w = EditorGUI.Slider(p.AddY(20), "Distort Blur", val.w, 0, 1f); switch (_type) { case "Mesh": val.y = EditorGUI.FloatField(p.AddY(40), "Distort Rim Fade", val.y); val.z = EditorGUI.FloatField(p.AddY(60), "Distort Scale", val.z); break; case "Plane": val.y = EditorGUI.FloatField(p.AddY(40), "Distort Texture Scroll U", val.y); val.z = EditorGUI.FloatField(p.AddY(60), "Distort Texture Scroll V", val.z); break; } prop.vectorValue = val; }
public override void OnGUI(Rect p, SerializedProperty property, GUIContent label) { var min = property.FindPropertyRelative("Min"); var max = property.FindPropertyRelative("Max"); var minVal = min.floatValue; var maxVal = max.floatValue; EditorGUI.BeginChangeCheck(); EditorGUI.MinMaxSlider(p = p.SetHeight(18), label, ref minVal, ref maxVal, 0, 10); p = p.AddY(20); p = EditorGUI.PrefixLabel(p, new GUIContent(" ")); minVal = EditorGUI.FloatField(p.AddX(-15).SetWidth(100), minVal); maxVal = EditorGUI.FloatField(p.AddX(p.width - 100).SetWidth(100), maxVal); if (EditorGUI.EndChangeCheck()) { min.floatValue = Mathf.Min(minVal, maxVal); max.floatValue = Mathf.Max(minVal, maxVal); } }
protected override void DrawPropertyLayout(GUIContent label) { // Save menuTreeWidth. this.menuTreeWidth.Value = this.columns[0].ColWidth; // Bottom Slide Toggle Bits: var overviewSlideRect = new Rect(); var toggleOverviewBtnRect = new Rect(); Rect topRect; GUILayout.BeginHorizontal(GUILayoutOptions.ExpandHeight()); { topRect = GUIHelper.GetCurrentLayoutRect(); GUITableUtilities.ResizeColumns(topRect, this.columns); // Bottom Slide Toggle Bits: // The bottom slide-rect toggle needs to be drawn above, but is placed below. overviewSlideRect = topRect.AlignBottom(4).AddY(4); overviewSlideRect.width += 4; toggleOverviewBtnRect = overviewSlideRect.AlignCenter(100).AlignBottom(14); EditorGUIUtility.AddCursorRect(toggleOverviewBtnRect, MouseCursor.Arrow); if (SirenixEditorGUI.IconButton(toggleOverviewBtnRect.AddY(-2), this.overviewToggle.Value ? EditorIcons.TriangleDown : EditorIcons.TriangleUp)) { this.overviewToggle.Value = !this.overviewToggle.Value; } if (this.overviewToggle.Value) { this.overviewHeight -= SirenixEditorGUI.SlideRect(overviewSlideRect.SetXMax(toggleOverviewBtnRect.xMin), MouseCursor.SplitResizeUpDown).y; this.overviewHeight -= SirenixEditorGUI.SlideRect(overviewSlideRect.SetXMin(toggleOverviewBtnRect.xMax), MouseCursor.SplitResizeUpDown).y; } // Left menu tree GUILayout.BeginVertical(GUILayoutOptions.Width(this.columns[0].ColWidth).ExpandHeight()); { EditorGUI.DrawRect(GUIHelper.GetCurrentLayoutRect(), SirenixGUIStyles.EditorWindowBackgroundColor); this.validationProfileTree.Draw(); } GUILayout.EndVertical(); // Draw selected GUILayout.BeginVertical(); { this.DrawTopBarButtons(); this.DrawSelectedTests(); } GUILayout.EndVertical(); GUITableUtilities.DrawColumnHeaderSeperators(topRect, this.columns, SirenixGUIStyles.BorderColor); } GUILayout.EndHorizontal(); // Bottom Slide Toggle Bits: if (this.overviewToggle.Value) { GUILayoutUtility.GetRect(0, 4); // Slide Area. } EditorGUI.DrawRect(overviewSlideRect, SirenixGUIStyles.BorderColor); EditorGUI.DrawRect(toggleOverviewBtnRect.AddY(-overviewSlideRect.height), SirenixGUIStyles.BorderColor); SirenixEditorGUI.IconButton(toggleOverviewBtnRect.AddY(-2), this.overviewToggle.Value ? EditorIcons.TriangleDown : EditorIcons.TriangleUp); // Overview if (this.overviewToggle.Value) { GUILayout.BeginVertical(GUILayout.Height(this.overviewHeight)); { this.overview.DrawOverview(); } GUILayout.EndVertical(); if (Event.current.type == EventType.Repaint) { this.overviewHeight = Mathf.Max(50, this.overviewHeight); var height = GUIHelper.CurrentWindow.position.height - overviewSlideRect.yMax; this.overviewHeight = Mathf.Min(this.overviewHeight, height); } } }
/// <summary> /// 显示在Inspector界面里面 /// </summary> public void OnInspectorGUI() { var currentEvent = Event.current; var userEvent = false; Rect rect = EditorGUILayout.GetControlRect(); //Rect rect = EditorGUILayout.BeginVertical(); //Debug.Log(rect); var controllId = GUIUtility.GetControlID(0); //Debug.Log(controllId); switch (currentEvent.type) { case EventType.DragExited: HandleUtility.Repaint(); break; case EventType.DragUpdated: case EventType.DragPerform: if (rect.Contains(currentEvent.mousePosition) && GUI.enabled) { if (DragAndDrop.objectReferences != null && DragAndDrop.objectReferences.Length > 0) { bool acceptObj = false; foreach (var obj in DragAndDrop.objectReferences) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (currentEvent.type == EventType.DragPerform) { var temp = obj as Object; this.m_listObjs.Add(temp); acceptObj = true; DragAndDrop.activeControlID = 0; } else { DragAndDrop.activeControlID = controllId; } } if (acceptObj) { GUI.enabled = true; DragAndDrop.AcceptDrag(); userEvent = true; } } } break; case EventType.ValidateCommand: Debug.Log("Validate:" + currentEvent.commandName); userEvent = true; break; case EventType.ExecuteCommand: Debug.Log("ExcuteCommand:" + currentEvent.commandName); //ExcuteCommand:ObjectSelectorUpdated if (currentEvent.commandName == "ObjectSelectorClosed") { //选择结束 var obj = EditorGUIUtility.GetObjectPickerObject(); if (obj != null && this.m_funcFilterObject(obj)) { Debug.Log(obj.name); if (this.m_bAddButton) { //说明是添加 this.m_bAddButton = false; this.m_listObjs.Add(obj); } else { //说明是改变 if (this.m_selectItemIndex != null) { this.m_listObjs[this.m_selectItemIndex.Value] = obj; this.m_selectItemIndex = null; } else { this.m_listObjs[0] = obj; } } } } userEvent = true; break; } if (this.m_labelObjectList != null) { rect.x = 0; rect.y = 0; this.m_bPackableListExpanded = EditorGUI.Foldout(rect, this.m_bPackableListExpanded, this.m_labelObjectList, true); } if (userEvent) { currentEvent.Use(); } if (this.m_bPackableListExpanded) { EditorGUI.indentLevel++; //this.m_packableList.DoLayoutList(); var foldRect = rect.AddY(this.m_packableList.headerHeight); this.m_packableList.DoList(foldRect); EditorGUI.indentLevel--; } //EditorGUILayout.EndVertical(); }