public override void BaseGUI() { BeginBox(); GUILayout.Label(ContentProperties.MainProperties, UEditorStyles.SectionHeaderLabel); GUILayout.Space(7); instance.SetPlayer((Transform)EditorGUILayout.ObjectField(ContentProperties.Player, instance.GetPlayer(), typeof(Transform), true)); if (instance.GetPlayer() == null) { if (MiniButton("Try find Camera")) { Transform player = UEditorInternal.FindPlayer(); if (player != null) { instance.SetPlayer(player); } else { UDisplayDialogs.Message("Searching", "Player not found, try find it manually."); } } UEditorHelpBoxMessages.PlayerError(); } instance.SetOriginalYAxis(EditorGUILayout.Slider(ContentProperties.OriginalYAxis, instance.GetOriginalYAxis(), -360.0f, 360.0f)); instance.SetAnimationEventProperties(ObjectField <AnimationEventProperties>(ContentProperties.EventProperties, instance.GetAnimationEventProperties(), true)); GUILayout.Space(10); GUILayout.Label("Animator", UEditorStyles.SectionHeaderLabel); GUILayout.Space(5); if (clips != null && clips.Length > 0) { GUILayout.BeginHorizontal(); instance.SetTakeTime(EditorGUILayout.FloatField(ContentProperties.TakeTime, instance.GetTakeTime())); if (ListButton()) { GenericMenu menu = new GenericMenu(); for (int i = 0, length = clips.Length; i < length; i++) { AnimationClip clip = clips[i]; menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetTakeTime(), 0.01f), (x) => { instance.SetTakeTime(UMathf.AllocatePart((float)x)); }, clip.length); } menu.ShowAsContext(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); instance.SetPutAwayTime(EditorGUILayout.FloatField(ContentProperties.PutAwayTime, instance.GetPutAwayTime())); if (ListButton()) { GenericMenu menu = new GenericMenu(); for (int i = 0, length = clips.Length; i < length; i++) { AnimationClip clip = clips[i]; menu.AddItem(new GUIContent(clip.name), UMathf.Approximately(clip.length, instance.GetPutAwayTime(), 0.01f), (x) => { instance.SetPutAwayTime(UMathf.AllocatePart((float)x)); }, clip.length); } menu.ShowAsContext(); } GUILayout.EndHorizontal(); } else { instance.SetTakeTime(EditorGUILayout.FloatField(ContentProperties.TakeTime, instance.GetTakeTime())); instance.SetPutAwayTime(EditorGUILayout.FloatField(ContentProperties.PutAwayTime, instance.GetPutAwayTime())); } GUILayout.Space(10); GUILayout.Label("Vector Animations", UEditorStyles.SectionHeaderLabel); GUILayout.Space(5); BeginSubBox(); EditorGUI.BeginDisabledGroup(!instance.UseRotationSway()); IncreaseIndentLevel(); rotationSwayFoldout = EditorGUILayout.Foldout(rotationSwayFoldout, ContentProperties.RotationSway, true); if (rotationSwayFoldout) { instance.SetPositionSensitivity(EditorGUILayout.FloatField(ContentProperties.PositionSensitivity, instance.GetPositionSensitivity())); instance.SetMaxPositionSensitivity(EditorGUILayout.FloatField(ContentProperties.MaxPositionSensitivity, instance.GetMaxPositionSensitivity())); instance.SetSmoothPosition(EditorGUILayout.FloatField(ContentProperties.SmoothPosition, instance.GetSmoothPosition())); instance.SetSmoothRotation(EditorGUILayout.FloatField(ContentProperties.SmoothRotation, instance.GetSmoothRotation())); instance.SetRotationSensitivity(EditorGUILayout.FloatField(ContentProperties.RotationSensitivity, instance.GetRotationSensitivity())); } string rotationSwayToggleName = instance.UseRotationSway() ? "Rotation Sway Enabled" : "Rotation Sway Disabled"; EditorGUI.EndDisabledGroup(); if (rotationSwayFoldout && !instance.UseRotationSway()) { Rect notificationBackgroungRect = GUILayoutUtility.GetLastRect(); Rect notificationTextRect = GUILayoutUtility.GetLastRect(); notificationBackgroungRect.y -= 75; notificationBackgroungRect.height = 93.5f; notificationTextRect.y -= 58.5f; notificationTextRect.height = 60; Notification("Rotation Sway Disabled", notificationBackgroungRect, notificationTextRect); } instance.RotationSwayActive(EditorGUILayout.Toggle(rotationSwayToggleName, instance.UseRotationSway())); EndSubBox(); BeginSubBox(); EditorGUI.BeginDisabledGroup(!instance.UseJumpSway()); jumpSwayFoldout = EditorGUILayout.Foldout(jumpSwayFoldout, ContentProperties.JumpSway, true); if (jumpSwayFoldout) { instance.SetMaxYPosJump(EditorGUILayout.FloatField(ContentProperties.MaxYPosJump, instance.GetMaxYPosJump())); instance.SetSmoothJump(EditorGUILayout.FloatField(ContentProperties.SmoothJump, instance.GetSmoothJump())); instance.SetSmoothLand(EditorGUILayout.FloatField(ContentProperties.SmoothLand, instance.GetSmoothLand())); } string jumpSwayToggleName = instance.UseJumpSway() ? "Jump Sway Enabled" : "Jump Sway Disabled"; EditorGUI.EndDisabledGroup(); if (jumpSwayFoldout && !instance.UseJumpSway()) { Rect notificationBackgroungRect = GUILayoutUtility.GetLastRect(); Rect notificationTextRect = GUILayoutUtility.GetLastRect(); notificationBackgroungRect.y -= 39; notificationBackgroungRect.height = 58; notificationTextRect.y -= 36.5f; notificationTextRect.height = 50; Notification("Jump Sway Disabled", notificationBackgroungRect, notificationTextRect); } instance.JumpSwayActive(EditorGUILayout.Toggle(jumpSwayToggleName, instance.UseJumpSway())); EndSubBox(); DecreaseIndentLevel(); EndBox(); if (GUI.changed) { clips = UEditorInternal.GetAllClips(instance.GetComponent <Animator>()); } }
void OnGUI() { this.titleContent.text = "碰撞体 Mesh读写等检查"; if (!string.IsNullOrEmpty(currentScene) && currentScene != SceneManager.GetActiveScene().name) { Clear(); } GUILayout.BeginHorizontal(); if (GUILayout.Button("搜场景", GUILayout.Width(gridWidth))) { SearchFromScene(); } if (GUILayout.Button("搜已选", GUILayout.Width(gridWidth))) { SearchFromSelection(); } if (GUILayout.Button("△", GUILayout.Width(20))) { Undo.RegisterCompleteObjectUndo(Selection.activeGameObject, ""); Selection.activeGameObject.transform.parent = null; } if (GUILayout.Button("修CubeScale为正", GUILayout.Width(gridWidth + 10))) { FixCubeScale(); } GUILayout.EndHorizontal(); GUILayout.Space(30); GUILayout.Label("结果", GUILayout.Width(gridWidth)); scrollPos = GUILayout.BeginScrollView(scrollPos); if (mySelectionIndex.Count > 0) { GUI.color = new Color(0, 0.5f, 0.5f); for (int i = 0; i < mySelectionIndex.Count; i++) { int id = mySelectionIndex [i]; GUI.DrawTexture(objs[id].rect, Texture2D.whiteTexture); } GUI.color = Color.white; } for (int i = 0; i < objs.Count; i++) { var go = objs [i].go; GUILayout.BeginHorizontal(); if (GUILayout.Button("△", GUILayout.Width(20))) { Undo.RegisterCompleteObjectUndo(objs [i].go, ""); objs [i].go.transform.parent = null; } if (selected == i && selectedSub == 0) { GUI.color = Color.green; } if (GUILayout.Button(objs [i].go.name, GUILayout.Width(gridWidth))) { if (Event.current.shift) { //Multi Add if (selected != -1) { int min = Mathf.Min(selected, i); int max = Mathf.Max(selected, i); for (int j = min; j < max + 1; j++) { AddToSelection(j); } } } else { //Single Select ClearSelection(); selected = i; selectedSub = 0; Selection.activeObject = objs [i].go; AddToSelection(i); } } if (GUILayout.Button("+", GUILayout.Width(20))) { //Add AddToSelection(i); } if (GUILayout.Button("-", GUILayout.Width(20))) { //Add RemoveFromSelection(i); } GUI.color = Color.white; string info = ""; if (objs [i].result == ResultType.Self) { info = "自身"; } else if (objs [i].result == ResultType.Parent) { info = "父级"; } else if (objs [i].result == ResultType.NotActive) { info = "隐藏"; } else if (objs [i].result == ResultType.Cube) { info = "Cube"; } else if (objs [i].result == ResultType.NoMesh) { info = "空Mesh"; } else if (objs [i].result == ResultType.Minus) { info = "缩放为负"; } GUILayout.Label(info, GUILayout.Width(gridWidth * 0.5f)); GUILayout.Label(string.Format("建议:{0}", solutions[(int)objs [i].result]), GUILayout.Width(gridWidth * 2f)); #region parent GUILayout.Label("父级:", GUILayout.Width(gridWidth * 0.5f)); var p = objs [i].go.transform.parent; int index = 1; while (p != null) { if (selected == i && selectedSub == index) { GUI.color = Color.green; } if (GUILayout.Button(string.Format("[{0}]{1}", index, p.name), GUILayout.Width(gridWidth * 2))) { selected = i; selectedSub = index; Selection.activeObject = p.gameObject; } GUI.color = Color.white; p = p.parent; index++; } #endregion GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { var rect = GUILayoutUtility.GetLastRect(); rect = new Rect(0, rect.y, rect.xMax, rect.height + 5); objs [i].rect = rect; } } GUILayout.EndScrollView(); }
private bool DoGUIEntries() { bool requestRepaint = false; var e = Event.current; var visibleWindowRect = GUILayoutUtility.GetRect(GUIContent.none, AndroidLogcatStyles.priorityDefaultStyle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); var totalWindowRect = visibleWindowRect; var maxVisibleItems = (int)(visibleWindowRect.height / AndroidLogcatStyles.kLogEntryFixedHeight); // Extra message count ensures that there's an empty space below when we scrolling all the way down // This way it's easier to see that there's no more messages const int kExtraMessageCount = 5; totalWindowRect.height = AndroidLogcatStyles.kLogEntryFixedHeight * (m_LogEntries.Count + kExtraMessageCount); totalWindowRect.width = Mathf.Max(totalWindowRect.width, m_MaxLogEntryWidth); var controlId = GUIUtility.GetControlID(FocusType.Keyboard); if (m_Autoscroll) { m_ScrollPosition.y = totalWindowRect.height; } EditorGUI.BeginChangeCheck(); m_ScrollPosition = GUI.BeginScrollView(visibleWindowRect, m_ScrollPosition, totalWindowRect, true, false); int startItem = (int)(m_ScrollPosition.y / totalWindowRect.height * (kExtraMessageCount + m_LogEntries.Count)); // Check if we need to enable autoscrolling if (EditorGUI.EndChangeCheck() || (e.type == EventType.ScrollWheel && e.delta.y > 0.0f)) { m_Autoscroll = startItem + maxVisibleItems - kExtraMessageCount >= m_LogEntries.Count; } else if (e.type == EventType.ScrollWheel && e.delta.y < 0.0f) { m_Autoscroll = false; } if (e.type == EventType.Repaint) { // Max Log Entry width is used for calculating horizontal scrollbar m_MaxLogEntryWidth = 0.0f; } // Only draw items which can be visible on the screen // There can be thousands of log entries, drawing them all would kill performance for (int i = startItem; i - startItem < maxVisibleItems && i < m_LogEntries.Count; i++) { bool selected = m_SelectedIndices.Contains(i); var selectionRect = new Rect(visibleWindowRect.x, visibleWindowRect.y + AndroidLogcatStyles.kLogEntryFixedHeight * i, totalWindowRect.width, AndroidLogcatStyles.kLogEntryFixedHeight); if (e.type == EventType.Repaint) { var le = m_LogEntries[i]; if (selected) { AndroidLogcatStyles.background.Draw(selectionRect, false, false, true, false); } else { if (i % 2 == 0) { AndroidLogcatStyles.backgroundEven.Draw(selectionRect, false, false, false, false); } else { AndroidLogcatStyles.backgroundOdd.Draw(selectionRect, false, false, false, false); } } var style = AndroidLogcatStyles.priorityStyles[(int)le.priority]; DoIconLogEntryItem(visibleWindowRect, i, Column.Icon, "", GetIconStyle(le.priority), AndroidLogcatStyles.kSmallIconSize); DoLogEntryItem(visibleWindowRect, i, Column.Time, le.dateTime.ToString(AndroidLogcat.LogEntry.s_TimeFormat), style); DoLogEntryItem(visibleWindowRect, i, Column.ProcessId, le.processId.ToString(), style); DoLogEntryItem(visibleWindowRect, i, Column.ThreadId, le.threadId.ToString(), style); DoLogEntryItem(visibleWindowRect, i, Column.Priority, le.priority.ToString(), style); DoLogEntryItem(visibleWindowRect, i, Column.Tag, le.tag.ToString(), style); DoLogEntryItem(visibleWindowRect, i, Column.Message, le.message, style); m_MaxLogEntryWidth = Mathf.Max(m_MaxLogEntryWidth, AndroidLogcatStyles.priorityDefaultStyle.CalcSize(new GUIContent(le.message)).x + Columns[(int)Column.Message].itemSize.x); } else { requestRepaint |= DoMouseEventsForLogEntry(selectionRect, i, selected, controlId); } } requestRepaint |= DoKeyEvents(); GUI.EndScrollView(); Rect rc = GUILayoutUtility.GetLastRect(); // Decrement horizontal scrollbar height rc.height -= 15.0f; DoColumnBorders(rc, Color.black, 1); return(requestRepaint); }
void OnGUI() { position = new Rect(position.x, position.y, 180, 145); GUILayout.Label("Color preset for heatmap data:"); EditorGUILayout.Space(); Vector2 lastvect = new Vector2(GUILayoutUtility.GetLastRect().x, GUILayoutUtility.GetLastRect().y); GUI.skin.button.alignment = TextAnchor.MiddleLeft; scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); if (GUILayout.Button("Yellow - Red")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.YellowRed; if (OnPicked != null) { OnPicked(this); } Close(); } if (GUILayout.Button("Blue - Red")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.BlueRed; if (OnPicked != null) { OnPicked(this); } Close(); } if (GUILayout.Button("Light Blue - Dark Blue")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.LightBlueDarkBlue; if (OnPicked != null) { OnPicked(this); } Close(); } if (GUILayout.Button("Magenta - Black")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.MagentaBlack; if (OnPicked != null) { OnPicked(this); } Close(); } if (GUILayout.Button("Cyan - Black")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.CyanBlack; if (OnPicked != null) { OnPicked(this); } Close(); } if (GUILayout.Button("Green - Black")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.GreenBlack; if (OnPicked != null) { OnPicked(this); } Close(); } if (GUILayout.Button("White - Black")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.WhiteBlack; if (OnPicked != null) { OnPicked(this); } Close(); } if (GUILayout.Button("Salmon - Black")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.SalmonBlack; if (OnPicked != null) { OnPicked(this); } Close(); } int add = 0; DrawColorBoxes(lastvect + new Vector2(135, -17 + add), lastvect + new Vector2(145, -17 + add), Color.yellow, Color.red, 10, 10, scrollPosition.y, 1); DrawColorBoxes(lastvect + new Vector2(135, 4 + add), lastvect + new Vector2(145, 4 + add), Color.blue, Color.red, 10, 10, scrollPosition.y, 2); DrawColorBoxes(lastvect + new Vector2(135, 25 + add), lastvect + new Vector2(145, 25 + add), new Color(0.75f, 0.75f, 1, 1), new Color(0, 0, 0.5f, 1), 10, 10, scrollPosition.y, 3); DrawColorBoxes(lastvect + new Vector2(135, 46 + add), lastvect + new Vector2(145, 46 + add), Color.magenta, Color.black, 10, 10, scrollPosition.y, 4); DrawColorBoxes(lastvect + new Vector2(135, 67 + add), lastvect + new Vector2(145, 67 + add), Color.cyan, Color.black, 10, 10, scrollPosition.y, 5); DrawColorBoxes(lastvect + new Vector2(135, 88 + add), lastvect + new Vector2(145, 88 + add), Color.green, Color.black, 10, 10, scrollPosition.y, 6); DrawColorBoxes(lastvect + new Vector2(135, 109 + add), lastvect + new Vector2(145, 109 + add), Color.white, Color.black, 10, 10, scrollPosition.y, 7); DrawColorBoxes(lastvect + new Vector2(135, 130 + add), lastvect + new Vector2(145, 130 + add), new Color(1, 0.5f, 0.5f, 1), Color.black, 10, 10, scrollPosition.y, 8); EditorGUILayout.EndScrollView(); GUI.skin.button.alignment = TextAnchor.MiddleCenter; if (GUILayout.Button("Cancel")) { ColorPreset = GA_HeatMapRendererInspector.PresetColorTypes.None; Close(); } }
protected void DrawLightEdit() { float headerWidth = 120f; bool delta = false; float sliderVal; string textVal; GUILayout.Label("<b>Light Parameters</b>"); GUILayout.BeginHorizontal(); GUILayout.Label("Light Color", GUILayout.Width(headerWidth)); GUILayout.Space(10); // Button to set that we are toggling the color picker if (GUILayout.Button("", GUILayout.Width(60))) { colorEdit = !colorEdit; Utils.Log($"[CP] Edit flag state {colorEdit}", LogType.UI); // if yes, open the window if (colorEdit) { WaterfallUI.Instance.OpenColorEditWindow(colorValue); Utils.Log("[CP] Open Window", LogType.UI); } } // If picker open if (colorEdit) { // Close all other pickers var c = WaterfallUI.Instance.GetColorFromPicker(); if (!c.IsEqualTo(colorValue)) { colorValue = c; delta = true; } if (delta) { colorTexture = TextureUtils.GenerateColorTexture(64, 32, colorValue); model.SetLightColor(light, colorValue); } } var tRect = GUILayoutUtility.GetLastRect(); tRect = new(tRect.x + 3, tRect.y + 3, tRect.width - 6, tRect.height - 6); GUI.DrawTexture(tRect, colorTexture); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Light Type", GUILayout.Width(headerWidth)); int newFlag = GUILayout.SelectionGrid(typeFlag, typeOptions, 2, UIResources.GetStyle("radio_text_button")); if (newFlag != typeFlag) { typeFlag = newFlag; if (typeFlag == 1) { model.SetLightType(light, LightType.Point); } if (typeFlag == 0) { model.SetLightType(light, LightType.Spot); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Intensity", GUILayout.Width(headerWidth)); sliderVal = GUILayout.HorizontalSlider(intensityValue, 0f, 10f); if (sliderVal != intensityValue) { intensityValue = sliderVal; intensityString = sliderVal.ToString(); model.SetLightIntensity(light, intensityValue); } textVal = GUILayout.TextArea(intensityString, GUILayout.Width(90f)); if (textVal != intensityString) { float outVal; if (Single.TryParse(textVal, out outVal)) { intensityValue = outVal; model.SetLightIntensity(light, intensityValue); } intensityString = textVal; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Range", GUILayout.Width(headerWidth)); sliderVal = GUILayout.HorizontalSlider(rangeValue, 0f, 100f); if (sliderVal != rangeValue) { rangeValue = sliderVal; rangeString = sliderVal.ToString(); model.SetLightRange(light, rangeValue); } textVal = GUILayout.TextArea(rangeString, GUILayout.Width(90f)); if (textVal != rangeString) { float outVal; if (Single.TryParse(textVal, out outVal)) { rangeValue = outVal; model.SetLightRange(light, rangeValue); } rangeString = textVal; } GUILayout.EndHorizontal(); if (typeFlag == 0) { GUILayout.BeginHorizontal(); GUILayout.Label("Spot Angle", GUILayout.Width(headerWidth)); sliderVal = GUILayout.HorizontalSlider(angleValue, 0f, 100f); if (sliderVal != angleValue) { angleValue = sliderVal; angleString = sliderVal.ToString(); model.SetLightAngle(light, angleValue); } textVal = GUILayout.TextArea(angleString, GUILayout.Width(90f)); if (textVal != angleString) { float outVal; if (Single.TryParse(textVal, out outVal)) { angleValue = outVal; model.SetLightAngle(light, angleValue); } angleString = textVal; } GUILayout.EndHorizontal(); } }
internal static void Display(Vector2 displayViewerPosition) { //float scrollX = WindowControl.Position.x + 20; //float scrollY = WindowControl.Position.y + 50 - displayViewerPosition.y; float scrollX = 20; float scrollY = displayViewerPosition.y; // Reset Tooltip active flag... ToolTipActive = false; SMHighlighter.IsMouseOver = false; GUILayout.BeginVertical(); GUI.enabled = true; //GUILayout.Label("Hatch Control Center ", SMStyle.LabelTabHeader); GUILayout.Label(SmUtils.SmTags["#smloc_control_hatch_000"], SMStyle.LabelTabHeader); GUILayout.Label("____________________________________________________________________________________________", SMStyle.LabelStyleHardRule, GUILayout.Height(10), GUILayout.Width(guiRuleWidth)); string step = "start"; try { // Display all hatches // ReSharper disable once ForCanBeConvertedToForeach for (int x = 0; x < SMAddon.SmVessel.Hatches.Count; x++) { ModHatch iHatch = SMAddon.SmVessel.Hatches[x]; bool isEnabled = true; bool open = false; // get hatch state if (!iHatch.IsDocked) { isEnabled = false; } if (iHatch.HatchOpen) { open = true; } step = "gui enable"; GUI.enabled = isEnabled; bool newOpen = GUILayout.Toggle(open, $"{iHatch.HatchStatus} - {iHatch.Title}", GUILayout.Width(guiToggleWidth)); step = "button toggle check"; if (!open && newOpen) { iHatch.OpenHatch(true); } else if (open && !newOpen) { iHatch.CloseHatch(true); } Rect rect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.Repaint && rect.Contains(Event.current.mousePosition)) { SMHighlighter.SetMouseOverData(rect, scrollY, scrollX, WindowControl.TabBox.height, iHatch.ClsPart.Part, Event.current.mousePosition); } } // Display MouseOverHighlighting, if any SMHighlighter.MouseOverHighlight(); } catch (Exception ex) { SmUtils.LogMessage( $" in Hatches Tab at step {step}. Error: {ex.Message} \r\n\r\n{ex.StackTrace}", SmUtils.LogType.Error, true); } GUI.enabled = true; GUILayout.EndVertical(); }
private void OnContactMaterialsList(GUISkin skin) { ContactMaterial contactMaterialToAdd = null; ContactMaterial contactMaterialToRemove = null; GUILayout.Label(GUI.MakeLabel("Contact Material Manager", 18, true), new GUIStyle(skin.label) { alignment = TextAnchor.MiddleCenter }); GUILayout.Space(4); GUILayout.Label(GUI.MakeLabel("Drag and drop contact materials into the list below to add/enable the contact material in the simulation."), new GUIStyle(skin.textArea) { alignment = TextAnchor.MiddleCenter }); GUILayout.Space(4); GUI.Separator3D(); GUILayout.BeginVertical(); { if (GUI.Foldout(FoldoutDataEntry, GUI.MakeLabel("Contact Materials [" + Manager.ContactMaterialEntries.Length + "]"), skin)) { var contactMaterials = Manager.ContactMaterials; using (new GUI.Indent(12)) { foreach (var contactMaterial in contactMaterials) { GUI.Separator(); bool foldoutActive = false; GUILayout.BeginHorizontal(); { foldoutActive = GUI.Foldout(EditorData.Instance.GetData(Manager, contactMaterial.name), GUI.MakeLabel(contactMaterial.name), skin); using (GUI.NodeListButtonColor) if (GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListEraseElement.ToString(), false, "Erase this element"), skin.button, new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(14) })) { contactMaterialToRemove = contactMaterial; } } GUILayout.EndHorizontal(); if (foldoutActive) { using (new GUI.Indent(12)) BaseEditor <ContactMaterial> .Update(contactMaterial, contactMaterial, skin); } } } } } GUILayout.EndVertical(); // Note that GetLastRect is used here and it's expecting the begin/end vertical rect. GUI.HandleDragDrop <ContactMaterial>(GUILayoutUtility.GetLastRect(), Event.current, (contactMaterial) => { contactMaterialToAdd = contactMaterial; }); GUI.Separator(); GUILayout.BeginHorizontal(); { GUILayout.Label(GUI.MakeLabel("Add:"), skin.label); contactMaterialToAdd = EditorGUILayout.ObjectField(null, typeof(ContactMaterial), false) as ContactMaterial ?? contactMaterialToAdd; } GUILayout.EndHorizontal(); GUI.Separator3D(); if (contactMaterialToAdd != null) { Manager.Add(contactMaterialToAdd); FoldoutDataEntry.Bool = true; } if (contactMaterialToRemove != null) { Manager.Remove(contactMaterialToRemove); } }
public override void OnGUI() { if (refreshConnection) { RefreshConnection(); } Color clr = GUI.backgroundColor; if (isSelected) { GUI.backgroundColor = bgColor; } var content = new GUIContent("Name: " + nodeName, nodeObject.description); GUILayout.BeginArea(GetRect(), content, currentStyle); { CreateTitleBar(); EditorGUILayout.BeginHorizontal(); { NodeType newType = (NodeType)EditorGUILayout.EnumPopup(nodeObject.nodeType); if (newType != nodeObject.nodeType) { nodeObject.ChangeNodeType(newType); } bool newRandom = GUILayout.Toggle(nodeObject.isRandom, "Random"); if (newRandom != nodeObject.isRandom) { treeBlueprint.save = true; nodeObject.isRandom = newRandom; } } EditorGUILayout.EndHorizontal(); if (childNodesReorderable != null) { //try //{ childNodesReorderable.DoLayoutList(); //} //catch (System.Exception) //{// only happens on Repaint after deleting a node. I think we can safely ignore it. //} } else if (Event.current.type == EventType.Repaint) { CreateChildList(); } if (Event.current.type == EventType.Repaint) { Rect lastrect = GUILayoutUtility.GetLastRect(); nodeObject.windowRect.height = lastrect.yMax; } } GUILayout.EndArea(); GUI.backgroundColor = clr; if (inPoint != null) // only a root node would not have an inpoint { inPoint.OnGUI(); } outPoint.OnGUI(); }
// EditorWindow.OnGUI protected void OnGUI() { if (Data == null || Data.layers == null) { return; } if (Data.currentLayer >= Data.layers.Count || Data.layers[Data.currentLayer] == null) { Data.currentLayer = 0; } if (shelfScroll == null) { shelfScroll = new Vector2[Data.layers.Count]; } if (shelfScroll.Length != Data.layers.Count) { var oldArray = shelfScroll; shelfScroll = new Vector2[Data.layers.Count]; Array.Copy(oldArray, shelfScroll, Math.Min(oldArray.Length, shelfScroll.Length)); } var current = Data.layers[Data.currentLayer]; string windowTitle = "Shelf"; // Force repaint if undo is triggered (only works when window has focus) if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") { Repaint(); } // Force displaying all layers when the window is enlargened // to re-fit the highest number of layers into the toolbar if (Math.Abs(position.width - lastWindowWidth) > 5) { if (position.width > lastWindowWidth) { lastWindowWidth = position.width; showLayers = int.MaxValue; } else { lastWindowWidth = position.width; } } // Delay setting of showLayers until the end of the method int nextShowLayers = showLayers; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); { bool draggingOver = false; float width = TOOLBAR_EXTRA_WIDTH + (showLayers < Data.layers.Count ? 12 : 0); for (int i = 0; i < showLayers && i < Data.layers.Count; i++) { var layer = Data.layers[i]; var active = (Data.currentLayer == i); if (GUILayout.Toggle(active, layer.name, EditorStyles.toolbarButton) != active) { Data.currentLayer = i; return; } Rect buttonRect = GUILayoutUtility.GetLastRect(); if (buttonRect.Contains(Event.current.mousePosition)) { // Drag-over layer switching if (Event.current.type == EventType.DragUpdated && DragAndDrop.objectReferences.Length > 0) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; if (dragOverLayer != i) { dragOverLayer = i; dragOverLayerTime = Time.realtimeSinceStartup; } draggingOver = true; // Dropping objects on layer button } else if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); layer.objects.AddRange(DragAndDrop.objectReferences); Data.currentLayer = i; Event.current.Use(); return; } } // Stop showing layers if they don't fit anymore width += buttonRect.width; if (width > position.width) { nextShowLayers = i; break; } } // Reset tracking of toolbar hovering if (!draggingOver && ( Event.current.type == EventType.DragUpdated || Event.current.type == EventType.Repaint) ) { dragOverLayer = -1; } // Put additional layers into dropdown menu if (showLayers < Data.layers.Count) { if (Data.currentLayer >= showLayers) { windowTitle = "Shelf: " + current.name; } if (GUILayout.Button(GUIContent.none, EditorStyles.toolbarDropDown, GUILayout.Width(12))) { var menu = new GenericMenu(); for (int i = showLayers; i < Data.layers.Count; i++) { menu.AddItem( new GUIContent(i + ": " + Data.layers[i].name), (Data.currentLayer == i), SwitchToLayer, i ); } menu.ShowAsContext(); Event.current.Use(); } } } EditorGUILayout.EndHorizontal(); if (reorderable.List != current.objects) { reorderable.List = current.objects; } shelfScroll[Data.currentLayer] = EditorGUILayout.BeginScrollView(shelfScroll[Data.currentLayer]); { if (showInlinePrefs) { EditorGUILayout.Space(); if (GUILayout.Button("Return")) { showInlinePrefs = false; } EditorGUILayout.Space(); inlinePrefs = true; ShelfPreferences(); inlinePrefs = false; } else { if (reorderable.OnGUI()) { Repaint(); } } } EditorGUILayout.EndScrollView(); if (!showInlinePrefs) { // Convert scene references to ShelfSceneReference instances for (int i = 0; i < current.objects.Count; i++) { if (!EditorUtility.IsPersistent(current.objects[i])) { // We're only able to store references to Components or GameObjects if (current.objects[i] is GameObject || current.objects[i] is Component) { current.objects[i] = ShelfSceneReference.Create(current.objects[i]); AssetDatabase.AddObjectToAsset(current.objects[i], Data); EditorUtility.SetDirty(Data); } else { Debug.LogError("Non-asset reference " + current.objects[i].name + " is neither " + "a GameObject nor a Component and cannot be saved on the shelf."); current.objects.RemoveAt(i); i--; } } } // Clear selection if (Event.current.type == EventType.MouseUp && Event.current.clickCount == 1) { ClearSlection(); } // Select all items on current shelf if (Event.current.commandName == "SelectAll") { reorderable.SelectAll(); Event.current.Use(); } } // Apply window title if (titleContent == null || titleContent.text != windowTitle) { titleContent = new GUIContent(windowTitle); } // Save shelf size if (EditorPrefs.GetFloat(SHELF_WIDTH_KEY) != position.width) { EditorPrefs.SetFloat(SHELF_WIDTH_KEY, position.width); } if (EditorPrefs.GetFloat(SHELF_HEIGHT_KEY) != position.height) { EditorPrefs.SetFloat(SHELF_HEIGHT_KEY, position.height); } // Apply showLayers now to avoid layout errors showLayers = nextShowLayers; }
/// <summary> /// Displays the contents of <paramref name="target"/> as a table. /// </summary> /// <param name="target">The <see cref="Localization"/> to show the /// contents of.</param> /// <param name="showAssets">If true, this method will show any /// assets or addressable assets. If false, this method will only /// show the localized text.</param> private void DrawLocalizationContents(Localization target) { var lineKeys = target.GetLineIDs(); // Early out if we don't have any lines if (lineKeys.Count() == 0) { EditorGUILayout.HelpBox($"This {nameof(Localization).ToLowerInvariant()} does not contain any lines.", MessageType.Info); return; } var localizedLineContent = new List <LocalizedLineEntry>(); var anyAssetsFound = false; #if USE_ADDRESSABLES var allAddressEntries = AddressableAssetSettingsDefaultObject.Settings.groups.SelectMany(g => g.entries).ToDictionary(e => e.address); #endif foreach (var key in lineKeys) { var entry = new LocalizedLineEntry(); entry.id = key; // Get the localized text for this line. entry.text = target.GetLocalizedString(key); if (target.ContainsLocalizedAssets && target.UsesAddressableAssets) { #if USE_ADDRESSABLES string address = Localization.GetAddressForLine(key, target.LocaleCode); if (allAddressEntries.TryGetValue(address, out var addressableAssetEntry)) { entry.asset = AssetDatabase.LoadAssetAtPath <Object>(addressableAssetEntry.AssetPath); anyAssetsFound = true; } #endif } else { if (target.ContainsLocalizedObject <Object>(key)) { var o = target.GetLocalizedObject <Object>(key); entry.asset = o; anyAssetsFound = true; } } localizedLineContent.Add(entry); } foreach (var entry in localizedLineContent) { var idContent = new GUIContent(entry.id); // Create a GUIContent that contains the string as its text // and also as its tooltip. This allows the user to mouse // over this line in the inspector and see more of it. var lineContent = new GUIContent(entry.text, entry.text); // Show the line ID and localized text EditorGUILayout.LabelField(idContent, lineContent); if (entry.asset != null) { // Asset references are never editable here - they're // only updated by the Localization Database. Add a // DisabledGroup here to make all ObjectFields be // interactable, but read-only. EditorGUI.BeginDisabledGroup(true); // Show the object field EditorGUILayout.ObjectField(" ", entry.asset, typeof(UnityEngine.Object), false); // for AudioClips, add a little play preview button if (entry.asset.GetType() == typeof(UnityEngine.AudioClip)) { var rect = GUILayoutUtility.GetLastRect(); // Localization assets are displayed in an // Inspector that's always disabled, so we need to // manually set the enabled flag to 'true' in order // to let this button be clickable. We'll restore // it after we handle this button. var wasEnabled = GUI.enabled; GUI.enabled = true; bool isPlaying = IsClipPlaying((AudioClip)entry.asset); if (lastPreviewed == (AudioClip)entry.asset && isPlaying) { rect.width = 54; rect.x += EditorGUIUtility.labelWidth - 56; if (GUI.Button(rect, "▣ Stop")) { StopAllClips(); lastPreviewed = null; } } else { rect.width = 18; rect.x += EditorGUIUtility.labelWidth - 20; if (GUI.Button(rect, "▸")) { PlayClip((AudioClip)entry.asset); lastPreviewed = (AudioClip)entry.asset; } } // Restore the enabled state GUI.enabled = wasEnabled; } EditorGUILayout.Space(); } else if (anyAssetsFound) { // Other entries have assets, but not this one. TODO: // show a warning? probably need to make it really // prominent, and possibly allow filtering this view to // show only lines that have no assets? } } }
protected virtual void DrawOverlay(Flowchart flowchart) { GUILayout.Space(8); GUILayout.BeginHorizontal(); GUILayout.Space(8); if (GUILayout.Button(new GUIContent(addTexture, "Add a new block"))) { Vector2 newNodePosition = new Vector2(50 - flowchart.ScrollPos.x, 50 - flowchart.ScrollPos.y); CreateBlock(flowchart, newNodePosition); } GUILayout.Space(8); flowchart.Zoom = GUILayout.HorizontalSlider(flowchart.Zoom, minZoomValue, maxZoomValue, GUILayout.Width(100)); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.Label(flowchart.name, EditorStyles.whiteBoldLabel); if (flowchart.Description.Length > 0) { GUILayout.Label(flowchart.Description, EditorStyles.helpBox); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(440)); GUILayout.FlexibleSpace(); flowchart.VariablesScrollPos = GUILayout.BeginScrollView(flowchart.VariablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f)); GUILayout.FlexibleSpace(); GUILayout.Space(8); FlowchartEditor flowchartEditor = Editor.CreateEditor(flowchart) as FlowchartEditor; flowchartEditor.DrawVariablesGUI(); DestroyImmediate(flowchartEditor); Rect variableWindowRect = GUILayoutUtility.GetLastRect(); if (flowchart.VariablesExpanded && flowchart.Variables.Count > 0) { variableWindowRect.y -= 20; variableWindowRect.height += 20; } if (Event.current.type == EventType.Repaint) { mouseOverVariables = variableWindowRect.Contains(Event.current.mousePosition); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
private void OnGUI() { if (CurrentScenario != null) { if (_eventActionTypes == null) { _eventActionTypes = (from System.Type type in System.Reflection.Assembly.GetExecutingAssembly().GetTypes() where type.IsSubclassOf(typeof(EventAction)) select type).ToArray(); } var actions = CurrentScenario.Actions; var newBatchSelect = Event.current.command || Event.current.control; if (_batchSelect != newBatchSelect) { _batchSelect = newBatchSelect; Repaint(); } if (Event.current.type == EventType.ScrollWheel) { CurrentScenario.VisibleScale = CurrentScenario.VisibleScale + (Mathf.Sign(Event.current.delta.y) * 0.1f); Repaint(); } GUILayout.BeginHorizontal(); if (Application.isPlaying) { if (!_currentScenario.InProgress) { if (GUILayout.Button("PLAY")) { _currentScenario.Execute(); } } else if (GUILayout.Button("STOP")) { _currentScenario.Stop(); } } GUILayout.BeginHorizontal(); CurrentScenario.VisibleScale = EditorGUILayout.Slider("Scale", CurrentScenario.VisibleScale, 0.1f, 100f); CurrentScenario.MaximumDuration = EditorGUILayout.FloatField("Max duration (seconds)", CurrentScenario.MaximumDuration); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); CurrentScenario.MaximumTracks = EditorGUILayout.IntField("Max tracks", CurrentScenario.MaximumTracks); BoxHeight = EditorGUILayout.IntSlider("Track height", BoxHeight, 20, 50); if (_draggedAction == null) { var newVisibleDuration = CurrentScenario.MaximumDuration / CurrentScenario.VisibleScale; if (Math.Abs(_visibleDuration - newVisibleDuration) > 0) { _visibleDuration = newVisibleDuration; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); CurrentScenario.PlayOnce = EditorGUILayout.Toggle("Play once", CurrentScenario.PlayOnce); GUILayout.EndHorizontal(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.Width(500f)); if (_playTimeChanges.Any()) { if (Application.isPlaying) { GUILayout.Label("UNCOMMITED CHANGES! Stop to save"); if (GUILayout.Button("Stop without saving")) { _playTimeChanges.Clear(); EditorApplication.isPlaying = false; } } else { foreach (var edit in _playTimeChanges) { var action = EditorUtility.InstanceIDToObject(edit.Key) as EventAction; if (action == null) { continue; } action.StartTime = edit.Value.StartTime; action.Duration = edit.Value.Duration; action.EditingTrack = edit.Value.EditingTrack; } _playTimeChanges.Clear(); } } GUILayout.EndHorizontal(); var lastRect = GUILayoutUtility.GetLastRect(); if (lastRect.yMax <= 1f) { return; } var trackOffset = Mathf.FloorToInt(_vScrollPosition / BoxHeight); PerformDrag(lastRect.yMax, _visibleDuration, trackOffset); DrawActions(actions, lastRect.yMax, _visibleDuration, CurrentScenario.VisibleOffset, trackOffset); DrawTimeline(lastRect.yMax); var vScrollVisible = CurrentScenario.MaximumTracks * BoxHeight > position.height; var tempMaxDuration = vScrollVisible ? CurrentScenario.MaximumDuration + 0.1f : CurrentScenario.MaximumDuration; var hScrollVisible = _visibleDuration < tempMaxDuration; if (vScrollVisible) { _vScrollPosition = GUI.VerticalScrollbar( new Rect(position.width - 15f, lastRect.yMax, 15f, position.height - lastRect.yMax - (hScrollVisible ? 15f : 0f)), _vScrollPosition, position.height - lastRect.yMax - BoxHeight, 0f, CurrentScenario.MaximumTracks * BoxHeight); } else { _vScrollPosition = 0f; } if (hScrollVisible) { _hScrollPosition = GUI.HorizontalScrollbar(new Rect(0f, position.height - 15f, position.width - (vScrollVisible ? 15f : 0f), 15f), _hScrollPosition, position.width, 0f, tempMaxDuration * position.width / _visibleDuration); CurrentScenario.VisibleOffset = _hScrollPosition; } else { _hScrollPosition = 0f; } if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { if (_addActionsMenu == null) { _addActionsMenu = new GenericMenu(); foreach (var t in _eventActionTypes) { _addActionsMenu.AddItem(new GUIContent(t.ToString()), false, CreateContextItem, t); } } _addActionsMenu.ShowAsContext(); Event.current.Use(); } } else { if (Selection.gameObjects.Length == 1) { OnSelectionChange(); } else { _eventActionTypes = null; GUILayout.Label("Select scenario"); } } }
static void OnViewMenuGUI(int windowID) { float left_pad = 90f; EditorGUIUtility.labelWidth = 118f; GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.Label("Viewport Settings", EditorStyles.boldLabel); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool lastBrushesHidden = CurrentSettings.BrushesHidden; CurrentSettings.BrushesHidden = EditorGUILayout.Toggle( new GUIContent("Hide Brushes", "Hotkey: " + KeyMappings.Instance.ToggleBrushesHidden), CurrentSettings.BrushesHidden ); if (CurrentSettings.BrushesHidden != lastBrushesHidden) { // Has changed CSGModel.UpdateAllBrushesVisibility(); SceneView.RepaintAll(); } GUILayout.EndHorizontal(); bool lastMeshHidden = CurrentSettings.MeshHidden; CurrentSettings.MeshHidden = EditorGUILayout.Toggle("Hide Meshes", CurrentSettings.MeshHidden); if (CurrentSettings.MeshHidden != lastMeshHidden) { // Has changed CSGModel.UpdateAllBrushesVisibility(); SceneView.RepaintAll(); } EditorGUI.BeginChangeCheck(); CurrentSettings.ShowExcludedPolygons = EditorGUILayout.Toggle("Show excluded faces", CurrentSettings.ShowExcludedPolygons); if (EditorGUI.EndChangeCheck()) { // What's shown in the SceneView has potentially changed, so force it to repaint SceneView.RepaintAll(); } EditorGUI.BeginChangeCheck(); CurrentSettings.ShowBrushBoundsGuideLines = EditorGUILayout.Toggle("Show brush guides", CurrentSettings.ShowBrushBoundsGuideLines); if (EditorGUI.EndChangeCheck()) { // What's shown in the SceneView has potentially changed, so force it to repaint CSGModel.UpdateAllBrushesVisibility(); SceneView.RepaintAll(); } EditorGUI.BeginChangeCheck(); CurrentSettings.ShowBrushesAsWireframes = EditorGUILayout.Toggle("Wireframe", CurrentSettings.ShowBrushesAsWireframes); if (EditorGUI.EndChangeCheck()) { // What's shown in the SceneView has potentially changed, so force it to repaint CSGModel.UpdateAllBrushesVisibility(); SceneView.RepaintAll(); } GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Grid Settings", EditorStyles.boldLabel); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Grid type", EditorStyles.label); GUILayout.FlexibleSpace(); GridMode lastMode = CurrentSettings.GridMode; CurrentSettings.GridMode = (GridMode)EditorGUILayout.EnumPopup(CurrentSettings.GridMode, GUILayout.Width(left_pad)); if (CurrentSettings.GridMode != lastMode) { OnSelectedGridOption(CurrentSettings.GridMode); } GUILayout.EndHorizontal(); // Projected grid bool lastProjectedGridEnabled = CurrentSettings.ProjectedGridEnabled; CurrentSettings.ProjectedGridEnabled = EditorGUILayout.Toggle( new GUIContent("Projected Grid", "Hotkey: " + KeyMappings.Instance.ToggleProjectedGrid.Replace("#", "Shift+")), CurrentSettings.ProjectedGridEnabled ); if (CurrentSettings.ProjectedGridEnabled != lastProjectedGridEnabled) { SceneView.RepaintAll(); } if (Event.current.type == EventType.Repaint) { gridRect = GUILayoutUtility.GetLastRect(); gridRect.width = 100; } // Position snapping UI CurrentSettings.PositionSnappingEnabled = EditorGUILayout.Toggle( new GUIContent("Grid snapping", "Hotkey: " + KeyMappings.Instance.TogglePosSnapping.Replace("#", "Shift+")), CurrentSettings.PositionSnappingEnabled ); // Position snapping UI CurrentSettings.AngleSnappingEnabled = EditorGUILayout.Toggle( new GUIContent("Rotation snapping", "Hotkey: " + KeyMappings.Instance.ToggleAngSnapping.Replace("#", "Shift+")), CurrentSettings.AngleSnappingEnabled ); // Rotation snapping UI GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent( "Rotation size", "Hotkeys: " + KeyMappings.Instance.DecreaseAngSnapping.Replace("#", "Shift+") + " " + KeyMappings.Instance.IncreaseAngSnapping.Replace("#", "Shift+") ), EditorStyles.label); GUILayout.FlexibleSpace(); // CurrentSettings.AngleSnappingEnabled = SabreGUILayout.Toggle(CurrentSettings.AngleSnappingEnabled, "Ang Snapping"); CurrentSettings.AngleSnapDistance = EditorGUILayout.FloatField(CurrentSettings.AngleSnapDistance, GUILayout.Width(50)); if (SabreGUILayout.Button("-", EditorStyles.miniButtonLeft)) { if (CurrentSettings.AngleSnapDistance > 15) { CurrentSettings.AngleSnapDistance -= 15; } else { CurrentSettings.AngleSnapDistance -= 5; } } if (SabreGUILayout.Button("+", EditorStyles.miniButtonRight)) { if (CurrentSettings.AngleSnapDistance >= 15) { CurrentSettings.AngleSnapDistance += 15; } else { CurrentSettings.AngleSnapDistance += 5; } } GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { var importer = serializedObject.targetObject as AseFileImporter; var textureSettings = "textureSettings."; var importTypeProperty = serializedObject.FindProperty("importType"); EditorGUILayout.LabelField("Texture Options", EditorStyles.boldLabel); { EditorGUI.indentLevel++; var importType = importTypeProperty.intValue; EditorGUI.BeginChangeCheck(); importType = EditorGUILayout.Popup("Import Type", importType, importTypes); if (EditorGUI.EndChangeCheck()) { importTypeProperty.intValue = importType; } var transparentColorMask = serializedObject.FindProperty(textureSettings + "transparentMask"); var transparentColor = serializedObject.FindProperty(textureSettings + "transparentColor"); Rect lastRect = GUILayoutUtility.GetLastRect(); Rect resetButton = new Rect(EditorGUIUtility.labelWidth + 50, lastRect.y + EditorGUIUtility.singleLineHeight, 60, 18); if (GUI.Button(resetButton, "Reset")) { transparentColor.colorValue = Color.magenta; } EditorGUILayout.PropertyField(transparentColorMask); if (transparentColorMask.boolValue) { EditorGUILayout.PropertyField(transparentColor); } EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "pixelsPerUnit")); var meshTypeProperty = serializedObject.FindProperty(textureSettings + "meshType"); var meshType = (SpriteMeshType)meshTypeProperty.intValue; EditorGUI.BeginChangeCheck(); meshType = (SpriteMeshType)EditorGUILayout.EnumPopup("Mesh Type", meshType); if (EditorGUI.EndChangeCheck()) { meshTypeProperty.intValue = (int)meshType; } EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "extrudeEdges")); if (importTypeProperty.intValue == (int)AseFileImportType.Sprite) { PivotPopup("Pivot"); } EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "generatePhysics")); EditorGUILayout.Space(); importer.textureSettings.wrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup("Wrap Mode", importer.textureSettings.wrapMode); importer.textureSettings.filterMode = (FilterMode)EditorGUILayout.EnumPopup("Filter Mode", importer.textureSettings.filterMode); EditorGUI.indentLevel--; } EditorGUILayout.Space(); if (importer.animationSettings.Length > 0) { EditorGUILayout.LabelField("Animation Options", EditorStyles.boldLabel); { if (importer.animationSettings != null) { foreach (var animationSetting in importer.animationSettings) { DrawAnimationSetting(importer, animationSetting); } } } } if (importTypeProperty.intValue == (int)AseFileImportType.Tileset) { EditorGUILayout.LabelField("Tileset Options", EditorStyles.boldLabel); { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "tileSize")); EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "tilePadding")); EditorGUILayout.PropertyField(serializedObject.FindProperty(textureSettings + "tileOffset")); PivotPopup("Tile Pivot"); EditorGUI.indentLevel--; } } base.ApplyRevertGUI(); }
/// <summary> /// Set the knob position at the current side next to the last Layout control /// </summary> public void SetPosition() { Vector2 pos = GUILayoutUtility.GetLastRect().center; sidePosition = side == NodeSide.Bottom || side == NodeSide.Top? pos.x : pos.y + 20; }
private bool ShaderMaterialPropertyImpl(MaterialProperty property, string filter = null) { //Filter string displayName = property.displayName; if (filter != null) { if (!displayName.Contains(filter)) { return(false); } displayName = displayName.Remove(displayName.IndexOf(filter), filter.Length + 1); } else if (displayName.Contains("#")) { return(false); } //GUI switch (property.type) { case MaterialProperty.PropType.Color: mMaterialEditor.ColorProperty(property, displayName); break; case MaterialProperty.PropType.Float: mMaterialEditor.FloatProperty(property, displayName); break; case MaterialProperty.PropType.Range: EditorGUILayout.BeginHorizontal(); //Add float field to Range parameters #if UNITY_4 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 float value = RangeProperty(property, displayName); Rect r = GUILayoutUtility.GetLastRect(); r.x = r.width - 160f; r.width = 65f; value = EditorGUI.FloatField(r, value); if (property.floatValue != value) { property.floatValue = value; } #else mMaterialEditor.RangeProperty(property, displayName); #endif EditorGUILayout.EndHorizontal(); break; case MaterialProperty.PropType.Texture: string nameLower = displayName.ToLower(); bool showOffset = !nameLower.Contains("mask"); showOffset &= !nameLower.Contains("matcap"); if (!showOffset) { if (nameLower.Contains("mask 1")) { showOffset = mShaderFeatures.Contains("UVMASK1"); } else if (nameLower.Contains("mask 2")) { showOffset = mShaderFeatures.Contains("UVMASK2"); } else if (nameLower.Contains("mask 3")) { showOffset = mShaderFeatures.Contains("UVMASK3"); } } if (!isGeneratedShader) { showOffset = !nameLower.Contains("cubemap") && !nameLower.Contains("matcap (rgb)"); } mMaterialEditor.TextureProperty(property, displayName, showOffset); break; case MaterialProperty.PropType.Vector: mMaterialEditor.VectorProperty(property, displayName); break; default: EditorGUILayout.LabelField("Unknown Material Property Type: " + property.type.ToString()); break; } return(true); }
/// <summary> Make a field for a serialized property. Manual node port override. </summary> public static void PropertyField(SerializedProperty property, GUIContent label, XNode.NodePort port, bool includeChildren = true, params GUILayoutOption[] options) { if (property == null) { throw new NullReferenceException(); } // If property is not a port, display a regular property field if (port == null) { EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); } else { Rect rect = new Rect(); float spacePadding = 0; SpaceAttribute spaceAttribute; if (NodeEditorUtilities.GetCachedAttrib(port.node.GetType(), property.name, out spaceAttribute)) { spacePadding = spaceAttribute.height; } // If property is an input, display a regular property field and put a port handle on the left side if (port.direction == XNode.NodePort.IO.Input) { // Get data from [Input] attribute XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected; XNode.Node.InputAttribute inputAttribute; bool dynamicPortList = false; if (NodeEditorUtilities.GetCachedAttrib(port.node.GetType(), property.name, out inputAttribute)) { dynamicPortList = inputAttribute.dynamicPortList; showBacking = inputAttribute.backingValue; } //Call GUILayout.Space if Space attribute is set and we are NOT drawing a PropertyField bool useLayoutSpace = dynamicPortList || showBacking == XNode.Node.ShowBackingValue.Never || (showBacking == XNode.Node.ShowBackingValue.Unconnected && port.IsConnected); if (spacePadding > 0 && useLayoutSpace) { GUILayout.Space(spacePadding); spacePadding = 0; } if (dynamicPortList) { Type type = GetType(property); XNode.Node.ConnectionType connectionType = inputAttribute != null ? inputAttribute.connectionType : XNode.Node.ConnectionType.Multiple; DynamicPortList(property.name, type, property.serializedObject, port.direction, connectionType); return; } switch (showBacking) { case XNode.Node.ShowBackingValue.Unconnected: // Display a label if port is connected if (port.IsConnected) { EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName)); } // Display an editable property field if port is not connected else { EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); } break; case XNode.Node.ShowBackingValue.Never: // Display a label EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName)); break; case XNode.Node.ShowBackingValue.Always: // Display an editable property field EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); break; } rect = GUILayoutUtility.GetLastRect(); rect.position = rect.position - new Vector2(16, -spacePadding); // If property is an output, display a text label and put a port handle on the right side } else if (port.direction == XNode.NodePort.IO.Output) { // Get data from [Output] attribute XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected; XNode.Node.OutputAttribute outputAttribute; bool dynamicPortList = false; if (NodeEditorUtilities.GetCachedAttrib(port.node.GetType(), property.name, out outputAttribute)) { dynamicPortList = outputAttribute.dynamicPortList; showBacking = outputAttribute.backingValue; } //Call GUILayout.Space if Space attribute is set and we are NOT drawing a PropertyField bool useLayoutSpace = dynamicPortList || showBacking == XNode.Node.ShowBackingValue.Never || (showBacking == XNode.Node.ShowBackingValue.Unconnected && port.IsConnected); if (spacePadding > 0 && useLayoutSpace) { GUILayout.Space(spacePadding); spacePadding = 0; } if (dynamicPortList) { Type type = GetType(property); XNode.Node.ConnectionType connectionType = outputAttribute != null ? outputAttribute.connectionType : XNode.Node.ConnectionType.Multiple; DynamicPortList(property.name, type, property.serializedObject, port.direction, connectionType); return; } switch (showBacking) { case XNode.Node.ShowBackingValue.Unconnected: // Display a label if port is connected if (port.IsConnected) { EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.OutputPort, GUILayout.MinWidth(30)); } // Display an editable property field if port is not connected else { EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); } break; case XNode.Node.ShowBackingValue.Never: // Display a label EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.OutputPort, GUILayout.MinWidth(30)); break; case XNode.Node.ShowBackingValue.Always: // Display an editable property field EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30)); break; } rect = GUILayoutUtility.GetLastRect(); rect.position = rect.position + new Vector2(rect.width, spacePadding); } rect.size = new Vector2(16, 16); Color backgroundColor = new Color32(90, 97, 105, 255); Color tint; if (NodeEditorWindow.nodeTint.TryGetValue(port.node.GetType(), out tint)) { backgroundColor *= tint; } Color col = NodeEditorWindow.current.graphEditor.GetPortColor(port); DrawPortHandle(rect, backgroundColor, col); // Register the handle position Vector2 portPos = rect.center; NodeEditor.portPositions[port] = portPos; } }
void DrawGUI_Android(P.Params currentParams) { int opt = currentParams.platformOption; //bool fold; //using( new GUILayout.VerticalScope( s_styles.HelpBox ) ) { // using( new GUILayout.HorizontalScope() ) { // EditorGUI.BeginChangeCheck(); // fold = EditorGUILayout.Foldout( BuildManagerSettingsEditor.i.fold.Has( BuildManagerSettingsEditor.FoldPlatform ), "Player Settings", s_styles.Foldout ); // BuildManagerSettingsEditor.i.fold.Toggle( BuildManagerSettingsEditor.FoldPlatform, fold ); // if( EditorGUI.EndChangeCheck() ) s_changed = true; // GUILayout.FlexibleSpace(); // var r = GUILayoutUtility.GetRect( 20, 18 ); // GUI.Label( r, s_styles.Settings, s_styles.Icon ); // if( EditorHelper.HasMouseClick( GUILayoutUtility.GetLastRect() ) ) { // Selection.activeObject = AssetDatabase.LoadAssetAtPath<UnityObject>( AssetDatabase.GUIDToAssetPath( "00000000000000004000000000000000" ) ); // EditorUtils.InspectorWindow().Focus(); // Event.current.Use(); // } // } // EditorGUI.BeginChangeCheck(); // if( fold ) { // EditorGUI.indentLevel++; // currentParams.scriptingBackend = (ScriptingImplementation) EditorGUILayout.Popup( L.Tr( "ScriptingBackend" ), (int) currentParams.scriptingBackend, s_scriptingBackend ); // using( new EditorGUI.DisabledGroupScope( currentParams.scriptingBackend == ScriptingImplementation.Mono2x ) ) { // currentParams.il2CppCompilerConfiguration = (Il2CppCompilerConfiguration) EditorGUILayout.EnumPopup( L.Tr( "C++ Compiler Configuration" ), currentParams.il2CppCompilerConfiguration ); // } // EditorGUILayout.LabelField( $"{L.Tr( "Scripting Define Symbols" )} ({L.Tr( "Additional" )})" ); // currentParams.scriptingDefineSymbols = EditorGUILayout.TextField( currentParams.scriptingDefineSymbols ); // EditorGUILayout.LabelField( $"{L.Tr( "Scripting Define Symbols" )} ({L.Tr( "Current" )})" ); // EditorGUI.BeginDisabledGroup( true ); // EditorGUILayout.TextField( B.scriptingDefineSymbols ); // EditorGUI.EndDisabledGroup(); // EditorGUI.indentLevel--; // GUILayout.Space( 4 ); // } // if( EditorGUI.EndChangeCheck() ) { // currentParams.platformOption = opt; // s_changed = true; // } //} GUILayout.Space(4); DrawGUI_3rdpartySettings(); #if false //保留 currentParams.DEBUG_LOG = EGL.Toggle("DEBUG_LOG", currentParams.DEBUG_LOG); BuildManagerPreference.i.adb_exe = EGL.TextField("adb.exe", BuildManagerPreference.i.adb_exe); BuildManagerPreference.i.bundletool_jar = EGL.TextField("bundletool", BuildManagerPreference.i.bundletool_jar); using (new GL.HorizontalScope()) { GL.FlexibleSpace(); GL.Button("Install on device"); GL.Button("Launch on device"); } #endif GUILayout.Space(4); EditorGUI.BeginChangeCheck(); using (new GUILayout.HorizontalScope()) { GUILayout.Label($"Version", EditorStyles.label); GUILayout.Label($"{PlayerSettings.bundleVersion}", EditorStyles.label); var a = GUILayoutUtility.GetLastRect(); a.x += a.width; a.width = 8; a.height = 8; //a.x -= 6; var rcU = a; rcU.y -= 0; var rcD = a; rcD.y += 0 + a.height; if (GUI.Button(rcU, EditorIcon.allowUp, Styles.icon)) { var f = float.Parse(PlayerSettings.bundleVersion); int i = (int)((f * 100.0f + 0.5f)); i += 100; f = i / 100.0f; PlayerSettings.bundleVersion = f.ToString("F2"); } if (GUI.Button(rcD, EditorIcon.allowUp, Styles.icon)) { var f = float.Parse(PlayerSettings.bundleVersion); int i = (int)((f * 100.0f + 0.5f)); i -= 100; f = i / 100.0f; PlayerSettings.bundleVersion = f.ToString("F2"); } rcU.x += 8; rcD.x += 8; if (GUI.Button(rcU, EditorIcon.allowUp, Styles.icon)) { var f = float.Parse(PlayerSettings.bundleVersion); int i = (int)((f * 100.0f + 0.5f)); i++; f = i / 100.0f; PlayerSettings.bundleVersion = f.ToString("F2"); } if (GUI.Button(rcD, EditorIcon.allowUp, Styles.icon)) { var f = float.Parse(PlayerSettings.bundleVersion); int i = (int)((f * 100.0f + 0.5f)); i--; f = i / 100.0f; PlayerSettings.bundleVersion = f.ToString("F2"); } GUILayout.Space(20); GUILayout.Label($"Bundle Version Code", EditorStyles.label); GUILayout.Label($"{PlayerSettings.Android.bundleVersionCode}", EditorStyles.label); a = GUILayoutUtility.GetLastRect(); a.x += a.width; a.width = 8; a.height = 8; rcU = a; rcU.y -= 0; rcD = a; rcD.y += 0 + a.height; if (GUI.Button(rcU, EditorIcon.allowUp, Styles.icon)) { PlayerSettings.Android.bundleVersionCode++; } if (GUI.Button(rcD, EditorIcon.allowUp, Styles.icon)) { PlayerSettings.Android.bundleVersionCode--; } GUILayout.FlexibleSpace(); } if (EditorGUI.EndChangeCheck()) { Utils.s_changed = true; } bool once = false; void errorLabel(string s, string icon = "") { var c = EditorStyles.label.normal.textColor; EditorStyles.label.normal.textColor = Color.red; EditorStyles.label.fontStyle = FontStyle.Bold; GUILayout.Label(EditorHelper.TempContent(s, Icon.Get(icon)), EditorStyles.label); EditorStyles.label.fontStyle = FontStyle.Normal; EditorStyles.label.normal.textColor = c; } void errorTitle() { if (once) { return; } errorLabel(S._PlayerSettings_Androidsettingsareincomplete, "console.erroricon.sml"); once = true; } if (PlayerSettings.Android.bundleVersionCode == 0) { errorTitle(); errorLabel(S._IfBundleVersionCodeis0_abuilderroroccurs); } if (B.applicationIdentifier.IsEmpty()) { errorTitle(); errorLabel(S._PackageNameofIdentificationisempty); } else if (B.applicationIdentifier == "com.Company.ProductName") { errorTitle(); errorLabel(S._AnerroroccursifPackageNameis_com_Company_ProductName_); } else if (!B.applicationIdentifier.Contains(".")) { errorTitle(); errorLabel(S._PackageNamemustbeseparatedbyatleastone__Dot_); } else if (B.applicationIdentifier[0] == '.') { errorTitle(); errorLabel(S._AnerroroccursifPackageNamestartswitha__Dot_); } else if (B.applicationIdentifier[B.applicationIdentifier.Length - 1] == '.') { errorTitle(); errorLabel(S._AnerroroccursiftheendofPackageNameis__Dot_); } }
void DrawPaintGUI() { GUILayout.Box("Brush Settings", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(20) }); var oldBM = brushMode; brushMode = (BrushTarget)EditorGUILayout.EnumPopup("Target Channel", brushMode); if (oldBM != brushMode) { UpdateDisplayMode(); } if (brushMode == BrushTarget.Color || brushMode == BrushTarget.RGB || brushMode == BrushTarget.UV0_AsColor || brushMode == BrushTarget.UV1_AsColor || brushMode == BrushTarget.UV2_AsColor || brushMode == BrushTarget.UV3_AsColor) { brushColorMode = (BrushColorMode)EditorGUILayout.EnumPopup("Blend Mode", (System.Enum)brushColorMode); if (brushColorMode == BrushColorMode.Overlay || brushColorMode == BrushColorMode.Normal) { bool showAlpha = brushMode != BrushTarget.RGB; brushColor = EditorGUILayout.ColorField(new GUIContent("Brush Color"), brushColor, true, showAlpha, false, null); if (GUILayout.Button("Reset Palette", EditorStyles.miniButton, GUILayout.Width(80), GUILayout.Height(16))) { if (swatches != null) { DestroyImmediate(swatches); } swatches = ColorSwatches.CreateInstance <ColorSwatches>(); EditorPrefs.SetString(sSwatchKey, JsonUtility.ToJson(swatches, false)); } GUILayout.BeginHorizontal(); for (int i = 0; i < swatches.colors.Length; ++i) { if (GUILayout.Button("", EditorStyles.textField, GUILayout.Width(16), GUILayout.Height(16))) { brushColor = swatches.colors[i]; } EditorGUI.DrawRect(new Rect(GUILayoutUtility.GetLastRect().x + 1, GUILayoutUtility.GetLastRect().y + 1, 14, 14), swatches.colors[i]); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); for (int i = 0; i < swatches.colors.Length; i++) { if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(16), GUILayout.Height(12))) { swatches.colors[i] = brushColor; EditorPrefs.SetString(sSwatchKey, JsonUtility.ToJson(swatches, false)); } } GUILayout.EndHorizontal(); } } else if (brushMode == BrushTarget.ValueR || brushMode == BrushTarget.ValueG || brushMode == BrushTarget.ValueB || brushMode == BrushTarget.ValueA) { brushValue = (int)EditorGUILayout.Slider("Brush Value", (float)brushValue, 0.0f, 256.0f); } else { floatBrushValue = EditorGUILayout.FloatField("Brush Value", floatBrushValue); var oldUVRange = uvVisualizationRange; uvVisualizationRange = EditorGUILayout.Vector2Field("Visualize Range", uvVisualizationRange); if (oldUVRange != uvVisualizationRange) { UpdateDisplayMode(); } } DrawBrushSettingsGUI(); //GUILayout.Box("", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(1)}); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Fill")) { if (OnBeginStroke != null) { OnBeginStroke(jobs); } for (int i = 0; i < jobs.Length; ++i) { Undo.RecordObject(jobs[i].stream, "Vertex Painter Fill"); FillMesh(jobs[i]); } if (OnEndStroke != null) { OnEndStroke(); } Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); } if (GUILayout.Button("Random")) { for (int i = 0; i < jobs.Length; ++i) { Undo.RecordObject(jobs[i].stream, "Vertex Painter Fill"); RandomMesh(jobs[i]); } } EditorGUILayout.EndHorizontal(); }
private void DrawList(AdvancedDropdownItem item) { // Start of scroll view list m_State.SetScrollState(item, GUILayout.BeginScrollView(m_State.GetScrollState(item), GUIStyle.none, GUI.skin.verticalScrollbar)); EditorGUIUtility.SetIconSize(m_Gui.iconSize); Rect selectedRect = new Rect(); for (var i = 0; i < item.children.Count(); i++) { var child = item.children.ElementAt(i); bool selected = m_State.GetSelectedIndex(item) == i; if (child.IsSeparator()) { m_Gui.DrawLineSeparator(); } else { m_Gui.DrawItem(child, child.displayName, child.icon, child.enabled, child.children.Any(), selected, hasSearch); } var r = GUILayoutUtility.GetLastRect(); if (selected) { selectedRect = r; } // Skip input handling for the tree used for animation if (item != m_CurrentlyRenderedTree) { continue; } // Select the element the mouse cursor is over. // Only do it on mouse move - keyboard controls are allowed to overwrite this until the next time the mouse moves. if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag) { if (!selected && r.Contains(Event.current.mousePosition)) { m_State.SetSelectedIndex(item, i); Event.current.Use(); } } if (Event.current.type == EventType.MouseUp && r.Contains(Event.current.mousePosition)) { m_State.SetSelectedIndex(item, i); var selectedChild = m_State.GetSelectedChild(item); if (selectedChild.children.Any()) { GoToChild(); } else { if (!selectedChild.IsSeparator() && selectionChanged != null) { selectionChanged(selectedChild); } if (closeOnSelection) { CloseWindow(); GUIUtility.ExitGUI(); } } Event.current.Use(); } } EditorGUIUtility.SetIconSize(Vector2.zero); GUILayout.EndScrollView(); // Scroll to selected on windows creation if (m_ScrollToSelected && m_InitialSelectionPosition != 0) { float diffOfPopupAboveTheButton = m_ButtonRectScreenPos.y - position.y; diffOfPopupAboveTheButton -= m_Gui.searchHeight + m_Gui.headerHeight; m_State.SetScrollState(item, new Vector2(0, m_InitialSelectionPosition - diffOfPopupAboveTheButton)); m_ScrollToSelected = false; m_InitialSelectionPosition = 0; } // Scroll to show selected else if (m_ScrollToSelected && Event.current.type == EventType.Repaint) { m_ScrollToSelected = false; Rect scrollRect = GUILayoutUtility.GetLastRect(); if (selectedRect.yMax - scrollRect.height > m_State.GetScrollState(item).y) { m_State.SetScrollState(item, new Vector2(0, selectedRect.yMax - scrollRect.height)); Repaint(); } if (selectedRect.y < m_State.GetScrollState(item).y) { m_State.SetScrollState(item, new Vector2(0, selectedRect.y)); Repaint(); } } }
//Adds a bullet point before the label that has just been added. void addBulletPoint() { Rect rect = GUILayoutUtility.GetLastRect(); EditorGUI.LabelField(new Rect(17, rect.yMin - 1, 10, rect.height), "•"); }
public override void OnInspectorGUI() { serializedObject.Update(); MaterialOverrideAsset overrideAsset = (target as MaterialOverrideAsset); if (GUILayout.Button("Add Material Override")) { if (overrideAsset != null) { PopupWindow.Show(_buttonRect, new MaterialPropPopup(overrideAsset, serializedObject)); if (Event.current.type == EventType.Repaint) { _buttonRect = GUILayoutUtility.GetLastRect(); } } } EditorGUILayout.PropertyField(serializedObject.FindProperty("shader"), new GUIContent("shader")); SerializedProperty overrideListProp = serializedObject.FindProperty("overrideList"); for (int i = 0; i < overrideListProp.arraySize; i++) { SerializedProperty overrideProp = overrideListProp.GetArrayElementAtIndex(i); string strName = overrideProp.FindPropertyRelative("name").stringValue; ShaderPropertyType type = (ShaderPropertyType)overrideProp.FindPropertyRelative("type").intValue; switch (type) { case (ShaderPropertyType.Color): { SerializedProperty colorProp = overrideProp.FindPropertyRelative("colorValue"); EditorGUILayout.PropertyField(colorProp, new GUIContent(strName)); break; } case (ShaderPropertyType.Vector): { SerializedProperty vector4Prop = overrideProp.FindPropertyRelative("vector4Value"); EditorGUILayout.PropertyField(vector4Prop, new GUIContent(strName)); break; } case (ShaderPropertyType.Float): { SerializedProperty floatProp = overrideProp.FindPropertyRelative("floatValue"); EditorGUILayout.PropertyField(floatProp, new GUIContent(strName)); break; } //TODO(atheisen): add support for vector1,2,3 and find out about Texture and Range overrides //case (ShaderPropertyType.Range): //{ // Debug.Log("Property " + strName + " is of unsupported type " + type + " for material override."); // break; //} //case (ShaderPropertyType.Texture): //{ // Debug.Log("Property " + strName + " is of unsupported type " + type + " for material override."); // break; //} default: { Debug.Log("Property " + strName + " is of unsupported type " + type + " for material override."); break; } } } serializedObject.ApplyModifiedProperties(); }
void OnGUI() { DoContextMenu(); GUILayout.Label("Quick Material", EditorStyles.boldLabel); Rect r = GUILayoutUtility.GetLastRect(); int left = (int)position.width - 68; GUILayout.BeginHorizontal(GUILayout.MaxWidth(position.width - 74)); GUILayout.BeginVertical(); m_QueuedMaterial = (Material)EditorGUILayout.ObjectField(m_QueuedMaterial, typeof(Material), true); GUILayout.Space(2); if (GUILayout.Button("Apply (Ctrl+Shift+Click)")) { ApplyMaterial(MeshSelection.topInternal, m_QueuedMaterial); } GUI.enabled = editor != null && MeshSelection.selectedFaceCount > 0; if (GUILayout.Button("Match Selection")) { m_QueuedMaterial = EditorMaterialUtility.GetActiveSelection(); } GUI.enabled = true; GUILayout.EndVertical(); GUI.Box(new Rect(left, r.y + r.height + 2, 64, 64), ""); var previewTexture = EditorMaterialUtility.GetPreviewTexture(m_QueuedMaterial); if (previewTexture != null) { GUI.Label(new Rect(left + 2, r.y + r.height + 4, 60, 60), previewTexture); } else { GUI.Box(new Rect(left + 2, r.y + r.height + 4, 60, 60), ""); GUI.Label(new Rect(left + 2, r.height + 28, 120, 32), "None\n(Texture)"); } GUILayout.EndHorizontal(); GUILayout.Space(4); GUI.backgroundColor = PreferenceKeys.proBuilderDarkGray; UI.EditorGUIUtility.DrawSeparator(2); GUI.backgroundColor = Color.white; GUILayout.Label("Material Palette", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); m_CurrentPaletteIndex = EditorGUILayout.Popup("", m_CurrentPaletteIndex, m_AvailablePalettes_Str); if (EditorGUI.EndChangeCheck()) { MaterialPalette newPalette = null; // Add a new material palette if (m_CurrentPaletteIndex >= m_AvailablePalettes.Length) { string path = AssetDatabase.GenerateUniqueAssetPath("Assets/Material Palette.asset"); newPalette = FileUtility.LoadRequired <MaterialPalette>(path); EditorGUIUtility.PingObject(newPalette); } else { newPalette = m_AvailablePalettes[m_CurrentPaletteIndex]; } SetMaterialPalette(newPalette); } EditorGUI.BeginChangeCheck(); s_CurrentPalette = (MaterialPalette)EditorGUILayout.ObjectField(s_CurrentPalette, typeof(MaterialPalette), false); if (EditorGUI.EndChangeCheck()) { SetMaterialPalette(s_CurrentPalette); } GUILayout.Space(4); Material[] materials = CurrentPalette; m_ViewScroll = GUILayout.BeginScrollView(m_ViewScroll); for (int i = 0; i < materials.Length; i++) { if (i == 10) { GUILayout.Space(2); GUI.backgroundColor = PreferenceKeys.proBuilderLightGray; UI.EditorGUIUtility.DrawSeparator(1); GUI.backgroundColor = Color.white; GUILayout.Space(2); } GUILayout.BeginHorizontal(); if (i < 10) { if (GUILayout.Button("Alt + " + (i == 9 ? 0 : (i + 1)).ToString(), EditorStyles.miniButton, GUILayout.MaxWidth(58))) { ApplyMaterial(MeshSelection.topInternal, materials[i]); } } else { if (GUILayout.Button("Apply", EditorStyles.miniButtonLeft, GUILayout.MaxWidth(44))) { ApplyMaterial(MeshSelection.topInternal, materials[i]); } GUI.backgroundColor = Color.red; if (GUILayout.Button("", EditorStyles.miniButtonRight, GUILayout.MaxWidth(14))) { Material[] temp = new Material[materials.Length - 1]; System.Array.Copy(materials, 0, temp, 0, materials.Length - 1); materials = temp; SaveUserMaterials(materials); return; } GUI.backgroundColor = Color.white; } EditorGUI.BeginChangeCheck(); materials[i] = (Material)EditorGUILayout.ObjectField(materials[i], typeof(Material), false); if (EditorGUI.EndChangeCheck()) { SaveUserMaterials(materials); } GUILayout.EndHorizontal(); } if (GUILayout.Button("Add")) { Material[] temp = new Material[materials.Length + 1]; System.Array.Copy(materials, 0, temp, 0, materials.Length); materials = temp; SaveUserMaterials(materials); } GUILayout.EndScrollView(); }
public override void OnInspectorGUI() { ((Component)this.target).transform.hideFlags = HideFlags.HideInInspector; GUILayoutExt.CollectEditors <IDebugViewGUIEditor <InitializerBase>, ViewProviderCustomEditorAttribute>(ref this.viewsDebugEditors); GUILayoutExt.CollectEditors <IJobsViewGUIEditor <InitializerBase>, ViewProviderCustomEditorAttribute>(ref this.viewsJobsEditors); var target = this.target as InitializerBase; if (target.featuresList == null) { target.featuresList = new FeaturesList(); } if (target.featuresList.features == null) { target.featuresList.features = new System.Collections.Generic.List <FeaturesList.FeatureData>(); } if (this.list == null) { this.list = new UnityEditorInternal.ReorderableList(target.featuresList.features, typeof(FeaturesList.FeatureData), true, true, true, true); this.list.drawElementCallback = this.OnDrawListItem; this.list.drawHeaderCallback = this.OnDrawHeader; this.list.onChangedCallback = this.OnChanged; this.list.elementHeightCallback = this.GetElementHeight; } GUILayoutExt.Box(15f, 0f, () => { var isDirty = false; this.definesFoldOut = GUILayoutExt.BeginFoldoutHeaderGroup(this.definesFoldOut, new GUIContent("Defines"), EditorStyles.foldoutHeader); if (this.definesFoldOut == true) { GUILayout.Space(10f); EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling == true || EditorApplication.isPlaying == true || EditorApplication.isPaused == true /* || InitializerEditor.isCompilingManual == true*/); foreach (var defineInfo in InitializerEditor.defines) { if (defineInfo.showInList == false) { continue; } var value = defineInfo.isActive.Invoke(); if (GUILayoutExt.ToggleLeft( ref value, ref isDirty, defineInfo.define, defineInfo.description) == true) { //InitializerEditor.isCompilingManual = true; if (value == true) { this.CompileWithDefine(defineInfo.define); } else { this.CompileWithoutDefine(defineInfo.define); } } } EditorGUI.EndDisabledGroup(); } this.settingsFoldOut = GUILayoutExt.BeginFoldoutHeaderGroup(this.settingsFoldOut, new GUIContent("Settings"), EditorStyles.foldoutHeader); if (this.settingsFoldOut == true) { GUILayout.Space(10f); GUILayoutExt.ToggleLeft( ref target.worldSettings.turnOffViews, ref isDirty, "Turn off views module", "If you want to run ME.ECS on server, you don't need to use Views at all. Turn off views module to avoid updating view instances overhead."); GUILayoutExt.ToggleLeft( ref target.worldSettings.useJobsForSystems, ref isDirty, "Use jobs for Systems", "Each system with filter has `jobs` flag which determine AdvanceTick behavior. If checked, jobs will be enabled and AdvanceTick will run asynchronously."); GUILayoutExt.ToggleLeft( ref target.worldSettings.useJobsForViews, ref isDirty, "Use jobs for Views", "Some view providers have jobs implementation. Turn it on to enable them update views inside jobs. Please note that some providers could lose some method calls."); if (this.viewsJobsEditors != null) { GUILayout.BeginHorizontal(); GUILayout.Space(10f); { GUILayout.BeginVertical(); foreach (var editor in this.viewsJobsEditors) { GUILayoutExt.Separator(); editor.Value.target = this.target as InitializerBase; if (editor.Value.OnDrawGUI() == true) { isDirty = true; } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } } this.settingsDebugFoldOut = GUILayoutExt.BeginFoldoutHeaderGroup(this.settingsDebugFoldOut, new GUIContent("Debug Settings"), EditorStyles.foldoutHeader); if (this.settingsDebugFoldOut == true) { GUILayout.Space(10f); GUILayoutExt.ToggleLeft( ref target.worldDebugSettings.createGameObjectsRepresentation, ref isDirty, "Create GameObject representation", "Editor-only feature. If checked, all entities will be represented by GameObject with debug information."); GUILayoutExt.ToggleLeft( ref target.worldDebugSettings.showViewsOnScene, ref isDirty, "Show Views in Hierarchy", "Editor-only feature. If checked, views module always show views on scene."); if (this.viewsDebugEditors != null) { GUILayout.BeginHorizontal(); GUILayout.Space(10f); { GUILayout.BeginVertical(); foreach (var editor in this.viewsDebugEditors) { GUILayoutExt.Separator(); editor.Value.target = this.target as InitializerBase; if (editor.Value.OnDrawGUI() == true) { isDirty = true; } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } } { var editor = Editor.CreateEditor(target); var field = editor.serializedObject.GetIterator(); editor.serializedObject.Update(); var baseClassEnd = false; while (field.NextVisible(true) == true) { if (baseClassEnd == true) { EditorGUILayout.PropertyField(field); } if (field.type == "EndOfBaseClass") { baseClassEnd = true; } } editor.serializedObject.ApplyModifiedProperties(); } if (isDirty == true) { EditorUtility.SetDirty(this.target); } }); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying == true || EditorApplication.isPaused == true); this.drawWidth = GUILayoutUtility.GetLastRect().width; this.list.DoLayoutList(); EditorGUI.EndDisabledGroup(); }
private void DrawSideWindow() { GUILayout.Label("Shadero Sprite v1.9.6", NodeEditorGUI.nodeLabelBold); if (NodeEditor._Shadero_Material == null) { Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_material.jpg"); GUI.DrawTexture(new Rect(5, 30, 196, 196), preview); } else { if (!NodeEditor.NoBuildShader) { Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_buildshader.jpg"); GUI.DrawTexture(new Rect(5, 30, 196, 196), preview); } else { if (!NodeEditor.FlagIsSaved) { Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_shader.jpg"); GUI.DrawTexture(new Rect(5, 30, 196, 196), preview); } else { if (!NodeEditor.RGBAonBuildShader) { Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_rgba_buildshader.jpg"); GUI.DrawTexture(new Rect(5, 30, 196, 196), preview); } else { NodeEditor._Shadero_Material.shader = Shader.Find("Shadero Customs/" + Node.ShaderNameX); Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_Shader.jpg"); GUI.DrawTexture(new Rect(5, 30, 196, 196), preview); Texture tex = NodeEditor._Shadero_Material.mainTexture; if (tex == null) { tex = ResourceManager.LoadTexture("Textures/previews/Preview_Shader.jpg"); } float x = Event.current.mousePosition.x - 8; float y = Event.current.mousePosition.y - 33; x = x / 190; y = y / 190; if ((x > 0 && x < 1) && (y > 0 && y < 1)) { EditorGUI.DrawPreviewTexture(new Rect(8, 33, 190, 190), tex, NodeEditor._Shadero_Material); if (FullScreenSet > 3) { EditorGUI.DrawPreviewTexture(new Rect(-(Screen.width / 2) - Screen.height / 4, 10, Screen.height, Screen.height), tex, NodeEditor._Shadero_Material); } FullScreenSet += Time.deltaTime; } else { FullScreenSet = 0; EditorGUI.DrawPreviewTexture(new Rect(8, 33, 190, 190), tex, NodeEditor._Shadero_Material); } } } } } GUILayout.Space(200); GUIStyle g = new GUIStyle(); if (NodeEditor._Shadero_Material != null) { int ms = g.fontSize; g.fontSize = 10; g.alignment = TextAnchor.UpperRight; g.normal.textColor = Color.white; GUILayout.Label("*Preview Material", g); g.fontSize = ms; } else { GUILayout.Label("Preview Material"); } PreviewLiveAnimation = GUILayout.Toggle(PreviewLiveAnimation, "Active live animation"); if (PreviewLiveAnimation) { NodeEditor.RepaintClients(); } g = new GUIStyle(); g.fontSize = 12; g.normal.textColor = Color.white; UseOwnMaterial = GUILayout.Toggle(UseOwnMaterial, "Use your own Material"); if (!UseOwnMaterial) { NodeEditor._Shadero_Material = AssetDatabase.LoadAssetAtPath("Assets/ShaderoSprite/Plugins/EditorResources/Preview/PreviewMaterial.mat", typeof(Material)) as Material; } else { GUILayout.Space(25); NodeEditor._Shadero_Material = (Material)EditorGUI.ObjectField(new Rect(5, 285, 200, 18), NodeEditor._Shadero_Material, typeof(Material), true); if (NodeEditor._Shadero_Material == null) { UseOwnMaterial = false; } } if (MaterialChange == null) { MaterialChange = AssetDatabase.GetAssetPath(NodeEditor._Shadero_Material); } if (MaterialChange != AssetDatabase.GetAssetPath(NodeEditor._Shadero_Material)) { NodeEditor.FlagIsMaterialChanged = true; NodeEditor.ShaderToNull = true; } MaterialChange = AssetDatabase.GetAssetPath(NodeEditor._Shadero_Material); GUILayout.Space(10); if (NodeEditor.RecalculateFlag) { NodeEditor.ForceWriteFlag = true; NodeEditor.RecalculateAll(canvasCache.nodeCanvas); NodeEditor.RecalculateFlag = false; } if (GUILayout.Button(new GUIContent("New Shader Project", "Loads an Specified Empty Shadero project"))) { _ShaderoShaderEditorFramework.Utilities.GenericMenu menu = new _ShaderoShaderEditorFramework.Utilities.GenericMenu(); NodeCanvasManager.FillCanvasTypeMenu(ref menu, canvasCache.NewNodeCanvas); menu.Show(createCanvasUIPos.position, createCanvasUIPos.width); } if (NodeEditor.NewCanvasWasCalled) { UseOwnMaterial = false; NodeEditor._Shadero_Material = null; NodeEditor.NewCanvasWasCalled = false; } if (Event.current.type == EventType.Repaint) { Rect popupPos = GUILayoutUtility.GetLastRect(); createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0); } GUILayout.Space(6); if (GUILayout.Button(new GUIContent("Save Shader Project", "Saves the project to a project Save File in the Assets Folder"))) { string path = EditorUtility.SaveFilePanelInProject("Save Shadero Shader Project", "Shadero Shader Project", "asset", "", NodeEditor.editorPath + "Shadero_Projects/"); if (!string.IsNullOrEmpty(path)) { canvasCache.SaveNodeCanvas(path); // NodeEditor.FlagIsSavedMaterial = true; } } if (GUILayout.Button(new GUIContent("Load Shader Project", "Loads the project from a project Save File in the Assets Folder"))) { string path = EditorUtility.OpenFilePanel("Load Shadero Shader Project", NodeEditor.editorPath + "Shadero_Projects/", "asset"); if (!path.Contains(Application.dataPath)) { if (!string.IsNullOrEmpty(path)) { ShowNotification(new GUIContent("You should select an asset inside your project folder!")); } } else { UseOwnMaterial = false; canvasCache.LoadNodeCanvas(path); } } GUILayout.Space(6); g = new GUIStyle(); g.fontSize = 12; g.alignment = TextAnchor.LowerLeft; g.normal.textColor = Color.white; if (!NodeEditor.NoBuildShader) { GUILayout.Label(" ", g); GUILayout.Label("What to do ?", g); GUILayout.Label(" ", g); GUILayout.Label("- You need to create a ", g); GUILayout.Label(" Build Shader \"Node Shader\"", g); GUILayout.Label(" , Right Click on the", g); GUILayout.Label(" Node Canvas and Select ", g); GUILayout.Label(" \"Add Build Shader\".", g); } else { GUILayout.Label(" ", g); GUILayout.Label("What to do ?", g); GUILayout.Label(" ", g); GUILayout.Label("-If you want to use your ", g); GUILayout.Label(" own material, active ", g); GUILayout.Label(" the \"Use your own material\" )", g); GUILayout.Label(" button. ", g); GUILayout.Label("", g); GUILayout.Label(" We recommand you to always ", g); GUILayout.Label(" active the \"Active live animation\"", g); GUILayout.Label(" for a better experience.", g); } if (canvasCache.editorState.selectedNode != null && Event.current.type != EventType.Ignore) { canvasCache.editorState.selectedNode.DrawNodePropertyEditor(); } }
public void OnGUI() { if (!IsVisible) { return; } // Chat messages if (boxStyle == null) { boxStyle = new GUIStyle(GUI.skin.box); Texture2D flat = new Texture2D(1, 1); flat.SetPixel(0, 0, new Color(0.125f, 0.125f, 0.125f, 0.6f)); flat.Apply(); boxStyle.normal.background = flat; } GUI.SetNextControlName(string.Empty); GUILayout.BeginArea(MessagesRect, boxStyle); GUILayout.FlexibleSpace(); ScrollPosition = GUILayout.BeginScrollView(ScrollPosition); if (labelStyle == null) { labelStyle = new GUIStyle(GUI.skin.label) { margin = new RectOffset(0, 0, 0, 0), padding = new RectOffset(0, 0, 0, 0), border = new RectOffset(0, 0, 0, 0) }; } foreach (Message message in Messages) { try { GUILayout.Label(message.ToString(), labelStyle); if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type != EventType.Repaint && GUI.GetNameOfFocusedControl().Equals(TextFieldName)) { if (Input.GetMouseButtonDown(0)) // Mouse1/Left Click { Mod.Commands.Find("translate").Execute(this, message.Content.Split(' ')); } else if (Input.GetMouseButtonDown(1)) // Mouse2/Right Click { TextEditor te = new TextEditor(); te.content = new GUIContent(message.Content); te.SelectAll(); te.Copy(); } } } catch { } } GUILayout.EndScrollView(); GUILayout.EndArea(); // Sends chat messages KeyCode rcChatKey = FengGameManagerMKII.InputRC.humanKeys[InputCodeRC.Chat]; if (Event.current.type == EventType.KeyUp && Event.current.keyCode == rcChatKey && rcChatKey != KeyCode.None && !GUI.GetNameOfFocusedControl().Equals(TextFieldName)) { GUI.FocusControl(TextFieldName); inputLine = "\t"; } else if (Event.current.type == EventType.KeyDown) { if ((Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t') && rcChatKey != KeyCode.Tab && !IN_GAME_MAIN_CAMERA.IsPausing) { Event.current.Use(); } else if (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return) { if (GUI.GetNameOfFocusedControl().Equals(TextFieldName)) { if (!string.IsNullOrEmpty(inputLine) && inputLine != "\t") { if (FengGameManagerMKII.RCEvents.ContainsKey("OnChatInput")) { string key = (string)FengGameManagerMKII.RCVariableNames["OnChatInput"]; if (FengGameManagerMKII.StringVariables.ContainsKey(key)) { FengGameManagerMKII.StringVariables[key] = inputLine; } else { FengGameManagerMKII.StringVariables.Add(key, inputLine); } RCEvent rcEvent = (RCEvent)FengGameManagerMKII.RCEvents["OnChatInput"]; rcEvent.CheckEvent(); } if (!inputLine.StartsWith("/")) { string name = GExtensions.AsString(PhotonNetwork.player.customProperties[PhotonPlayerProperty.Name]).Colored(); if (name.Uncolored().Length <= 0) { name = GExtensions.AsString(PhotonNetwork.player.customProperties[PhotonPlayerProperty.Name]); } FengGameManagerMKII.Instance.photonView.RPC("Chat", PhotonTargets.All, Mod.HandleChat(inputLine, name)); } else { Guardian.Mod.Commands.HandleCommand(this); } } GUI.FocusControl(string.Empty); inputLine = string.Empty; } else { GUI.FocusControl(TextFieldName); inputLine = "\t"; } } } // Chat text-field if (textboxStyle == null) { textboxStyle = new GUIStyle(GUI.skin.textField); Texture2D flat = new Texture2D(1, 1); flat.SetPixel(0, 0, new Color(0.125f, 0.125f, 0.125f, 0.2f)); flat.Apply(); textboxStyle.normal.background = flat; Texture2D flatFocused = new Texture2D(1, 1); flatFocused.SetPixel(0, 0, new Color(0.125f, 0.125f, 0.125f, 0.6f)); flatFocused.Apply(); textboxStyle.focused.background = flatFocused; } GUILayout.BeginArea(ChatBoxRect); GUILayout.BeginHorizontal(); GUI.SetNextControlName(TextFieldName); inputLine = GUILayout.TextField(inputLine, textboxStyle, GUILayout.MaxWidth(300)); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
public void Draw(int windowWidth, tk2dSpriteAnimationClip clip, List <ClipEditor.FrameGroup> frameGroups, float clipTimeMarker) { int space = clipLeftHeaderSpace; int requiredWidth = space + (clip.frames.Length + 1) * frameWidth; int clipHeightTotal = (requiredWidth > windowWidth) ? clipHeightScrollBar : clipHeight; clipScrollbar = GUILayout.BeginScrollView(clipScrollbar, GUILayout.Height(clipHeightTotal), GUILayout.ExpandWidth(true)); GUILayout.BeginVertical(); // Draw timeline axis GUILayout.Box("", EditorStyles.toolbar, GUILayout.ExpandWidth(true)); Rect timelineRect = GUILayoutUtility.GetLastRect(); DrawAxis(clip, new Rect(timelineRect.x + space, timelineRect.y, timelineRect.width - space, timelineRect.height), frameWidth); // Draw background and derive trigger rect GUILayout.Box("", tk2dEditorSkin.Anim_BG, GUILayout.ExpandWidth(true), GUILayout.Height(16)); Rect triggerRect = GUILayoutUtility.GetLastRect(); // Trigger helpbox Rect triggerHelpBox = new Rect(triggerRect.x, triggerRect.y, triggerRect.height, triggerRect.height); if (GUIUtility.hotControl == 0 && triggerHelpBox.Contains(Event.current.mousePosition)) { GUI.Label(new Rect(triggerHelpBox.x, triggerHelpBox.y, 150, triggerHelpBox.height), "Double click to add triggers", EditorStyles.whiteMiniLabel); } else { GUI.Label(triggerHelpBox, "?", EditorStyles.whiteMiniLabel); } // Control IDs int triggerControlId = "tk2d.DrawClip.Triggers".GetHashCode(); int frameGroupControlId = "tk2d.DrawClip.FrameGroups".GetHashCode(); // Draw triggers DrawTriggers(triggerControlId, triggerRect, clip); // Draw frames GUILayout.BeginHorizontal(); int framesWidth = clipLeftHeaderSpace + (clip.frames.Length + 1) * frameWidth; Rect frameGroupRect = GUILayoutUtility.GetRect(framesWidth, 1, GUILayout.ExpandHeight(true)); DrawFrameGroups(frameGroupControlId, frameGroupRect, clip, frameGroups, clipTimeMarker); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (Event.current.type == EventType.ScrollWheel && (Event.current.alt || Event.current.control)) { frameWidth = Mathf.Clamp((int)(Event.current.delta.y + frameWidth), minFrameWidth, maxFrameWidth); Repaint(); } GUILayout.EndScrollView(); Rect scrollRect = GUILayoutUtility.GetLastRect(); DrawFrameGroupsOverlay(frameGroupControlId, new Rect(scrollRect.x + frameGroupRect.x, scrollRect.y + frameGroupRect.y, frameGroupRect.width, frameGroupRect.height), clip, frameGroups, clipTimeMarker); }
/// <summary> /// Draw the player prefs entries /// </summary> private void DrawKeyEntries() { var normalbackgroundColor = GUI.backgroundColor; EditorGUILayout.BeginHorizontal(); _scrollPositionKeys = EditorGUILayout.BeginScrollView(_scrollPositionKeys, GUILayout.Width(_leftPanelWidth), GUILayout.MinWidth(100)); var keys = LocaliseText.Localisations.Keys.ToList(); keys.Sort(); for (var i = 0; i < keys.Count; i++) { var k = keys[i]; var s = new GUIStyle(); s.normal.background = MakeColoredTexture(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.1f)); GUI.backgroundColor = SelectedKeyIndex == i ? Color.blue : normalbackgroundColor; GUILayout.BeginHorizontal(s); GUILayout.Label(k, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); if (Event.current.button == 0 && Event.current.type == EventType.MouseUp) { if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { SelectedKeyIndex = i; ClearFocus(); Repaint(); } // Handle events here } } GUI.backgroundColor = normalbackgroundColor; EditorGUILayout.EndScrollView(); var lastrect = GUILayoutUtility.GetLastRect(); lastrect.x = lastrect.xMax + 5; lastrect.width = 3; GUILayout.Space(5); HandleResize(lastrect); GUILayout.Space(5); //var drawnLines = 0; _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.Width(position.width - _leftPanelWidth)); LocaliseText.LoadDictionary(); var key = LocaliseText.Localisations.Keys.ToList()[SelectedKeyIndex]; //var boldGUIStyle = new GUIStyle(EditorStyles.numberField); //boldGUIStyle.fontStyle = FontStyle.Bold; for (var i = 0; i < LocaliseText.Languages.Length; i++) { var languageEntry = LocaliseText.Languages[i]; string stringValue = LocaliseText.Get(key, languageEntry); float num = EditorStyles.textArea.CalcHeight(new GUIContent(stringValue), EditorGUIUtility.currentViewWidth); int num2 = Mathf.CeilToInt(num / 13f); num2 = Mathf.Clamp(num2, 1, int.MaxValue); var height = 32f + (float)((num2 - 1) * 13); //Debug.Log(num2 + ", " + height); EditorGUILayout.LabelField(languageEntry, EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); stringValue = EditorGUILayout.TextArea(LocaliseText.Get(key, languageEntry), EditorStyles.textArea, GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth), GUILayout.MinHeight(height), GUILayout.MaxHeight(height)); if (EditorGUI.EndChangeCheck()) { LocaliseText.Localisations[key][i] = stringValue; } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); }
public static float OffsetSlider(float value, float increment, float incrementLarge, float range, string name, out bool changed, Color backgroundColor, int valueType, ref int delta, bool allowFine = true) { if (!WingProceduralManager.uiStyleConfigured) { WingProceduralManager.ConfigureStyles(); } GUILayout.BeginHorizontal(); value += range / 2; int newDelta = (int)(value / range); if (newDelta != delta & newDelta != delta + 1) { delta = newDelta; } //double value01 = (value - limits.x) / range; // rescaling value to be 0-100% of range for convenience double value01 = (value - delta * range) / range; double increment01 = increment / range; double valueOld = value01; float buttonWidth = 12, spaceWidth = 3; GUILayout.Label("", WingProceduralManager.uiStyleLabelHint); Rect rectLast = GUILayoutUtility.GetLastRect(); Rect rectSlider = new Rect(rectLast.xMin + buttonWidth + spaceWidth, rectLast.yMin, rectLast.width - 2 * (buttonWidth + spaceWidth), rectLast.height); Rect rectSliderValue = new Rect(rectSlider.xMin, rectSlider.yMin, rectSlider.width * (float)value01, rectSlider.height - 3f); Rect rectButtonL = new Rect(rectLast.xMin, rectLast.yMin, buttonWidth, rectLast.height); Rect rectButtonR = new Rect(rectLast.xMin + rectLast.width - buttonWidth, rectLast.yMin, buttonWidth, rectLast.height); Rect rectLabelValue = new Rect(rectSlider.xMin + rectSlider.width * 0.75f, rectSlider.yMin, rectSlider.width * 0.25f, rectSlider.height); //Debug.Log("Slider created."); if (GUI.Button(rectButtonL, "", WingProceduralManager.uiStyleButton)) { if (delta == 0 & value01 > 0.5) { value01 = 0.5; } else if (value01 == 0) { delta -= 1; } else { value01 = 0; } } if (GUI.Button(rectButtonR, "", WingProceduralManager.uiStyleButton)) { if (delta == 0 & value01 < 0.5) { value01 = 0.5; } else if (value01 == 1) { delta += 1; } else { value01 = 1; } } if (rectLast.Contains(Event.current.mousePosition) && (Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseDown) && // right click drag doesn't work properly without the event check Event.current.type != EventType.MouseUp) // drag event covers this, but don't want it to { value01 = GUI.HorizontalSlider(rectSlider, (float)value01, 0f, 1f, WingProceduralManager.uiStyleSlider, WingProceduralManager.uiStyleSliderThumb); if (valueOld != value01) { if (Input.GetMouseButton(0) || !allowFine) // normal control { double excess = value01 / increment01; value01 -= (excess - Math.Round(excess)) * increment01; //Debug.Log("Normal: value01 => " + value01); } else if (Input.GetMouseButton(1) && allowFine) // fine control { double excess = valueOld / increment01; value01 = (valueOld - (excess - Math.Round(excess)) * increment01) + Math.Min(value01 - 0.5, 0.4999) * increment01; //Debug.Log("Fine: value01 => " + value01); } } } else { GUI.HorizontalSlider(rectSlider, (float)value01, 0f, 1f, WingProceduralManager.uiStyleSlider, WingProceduralManager.uiStyleSliderThumb); } value = (float)(value01 * range + range * delta - range / 2); // lower limit is halved so the fine control can reduce it further but the normal tweak still snaps. Min makes -ve values work //value = (float)(value01 * range + limits.x); //releases clamp changed = valueOld != value ? true : false; GUI.DrawTexture(rectSliderValue, backgroundColor.GetTexture2D()); GUI.Label(rectSlider, " " + name, WingProceduralManager.uiStyleLabelHint); GUI.Label(rectLabelValue, GetValueTranslation(value, valueType), WingProceduralManager.uiStyleLabelHint); GUILayout.EndHorizontal(); //Vector2 value1 = new Vector2(value, delta); //Debug.Log("B9PW: Value changed to " + value + ", delta = " + delta); //log it //return value1; return(value); }
public override void OnGUI() { // History toolbar GUILayout.BeginHorizontal(EditorStyles.toolbar); { GUILayout.FlexibleSpace(); if (hasRemote) { EditorGUI.BeginDisabledGroup(currentRemoteName == null); { // Fetch button var fetchClicked = GUILayout.Button(FetchButtonText, Styles.HistoryToolbarButtonStyle); if (fetchClicked) { Fetch(); } // Pull button var pullButtonText = statusBehind > 0 ? String.Format(PullButtonCount, statusBehind) : PullButton; var pullClicked = GUILayout.Button(pullButtonText, Styles.HistoryToolbarButtonStyle); if (pullClicked && EditorUtility.DisplayDialog(PullConfirmTitle, String.Format(PullConfirmDescription, currentRemoteName), PullConfirmYes, PullConfirmCancel) ) { Pull(); } } EditorGUI.EndDisabledGroup(); // Push button EditorGUI.BeginDisabledGroup(currentRemoteName == null || statusBehind != 0); { var pushButtonText = statusAhead > 0 ? String.Format(PushButtonCount, statusAhead) : PushButton; var pushClicked = GUILayout.Button(pushButtonText, Styles.HistoryToolbarButtonStyle); if (pushClicked && EditorUtility.DisplayDialog(PushConfirmTitle, String.Format(PushConfirmDescription, currentRemoteName), PushConfirmYes, PushConfirmCancel) ) { Push(); } } EditorGUI.EndDisabledGroup(); } else { // Publishing a repo var publishedClicked = GUILayout.Button(PublishButton, Styles.HistoryToolbarButtonStyle); if (publishedClicked) { PopupWindow.OpenWindow(PopupWindow.PopupViewType.PublishView); } } } GUILayout.EndHorizontal(); var rect = GUILayoutUtility.GetLastRect(); if (historyControl != null) { var historyControlRect = new Rect(0f, 0f, Position.width, Position.height - rect.height); var requiresRepaint = historyControl.Render(historyControlRect, entry => { selectedEntry = entry; BuildTree(); }, entry => { }, entry => { }); if (requiresRepaint) { Redraw(); } } if (!selectedEntry.Equals(GitLogEntry.Default)) { // Top bar for scrolling to selection or clearing it GUILayout.BeginHorizontal(EditorStyles.toolbar); { if (GUILayout.Button(CommitDetailsTitle, Styles.HistoryToolbarButtonStyle)) { historyControl.ScrollTo(historyControl.SelectedIndex); } if (GUILayout.Button(ClearSelectionButton, Styles.HistoryToolbarButtonStyle, GUILayout.ExpandWidth(false))) { selectedEntry = GitLogEntry.Default; historyControl.SelectedIndex = -1; } } GUILayout.EndHorizontal(); // Log entry details - including changeset tree (if any changes are found) detailsScroll = GUILayout.BeginScrollView(detailsScroll, GUILayout.Height(250)); { HistoryDetailsEntry(selectedEntry); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); GUILayout.Label("Files changed", EditorStyles.boldLabel); GUILayout.Space(-5); rect = GUILayoutUtility.GetLastRect(); GUILayout.BeginHorizontal(Styles.HistoryFileTreeBoxStyle); GUILayout.BeginVertical(); { var borderLeft = Styles.Label.margin.left; var treeControlRect = new Rect(rect.x + borderLeft, rect.y, Position.width - borderLeft * 2, Position.height - rect.height + Styles.CommitAreaPadding); var treeRect = Rect.zero; if (treeChanges != null) { treeChanges.FolderStyle = Styles.Foldout; treeChanges.TreeNodeStyle = Styles.TreeNode; treeChanges.ActiveTreeNodeStyle = Styles.ActiveTreeNode; treeChanges.FocusedTreeNodeStyle = Styles.FocusedTreeNode; treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode; treeRect = treeChanges.Render(treeControlRect, detailsScroll, node => { }, node => { }, node => { }); if (treeChanges.RequiresRepaint) { Redraw(); } } GUILayout.Space(treeRect.y - treeControlRect.y); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); } GUILayout.EndScrollView(); } }