private void ShowFrameratePopup() { if (GUILayout.Button(VFXToolboxGUIUtility.GetTextAndIcon("Speed", "SpeedScale"), EditorStyles.toolbarDropDown)) { GenericMenu menu = new GenericMenu(); menu.AddItem(VFXToolboxGUIUtility.Get("5 fps"), false, () => { m_PlayFramerate = 5; }); menu.AddItem(VFXToolboxGUIUtility.Get("10 fps"), false, () => { m_PlayFramerate = 10; }); menu.AddItem(VFXToolboxGUIUtility.Get("15 fps"), false, () => { m_PlayFramerate = 15; }); menu.AddItem(VFXToolboxGUIUtility.Get("20 fps"), false, () => { m_PlayFramerate = 20; }); menu.AddItem(VFXToolboxGUIUtility.Get("24 fps (Cine)"), false, () => { m_PlayFramerate = 24; }); menu.AddItem(VFXToolboxGUIUtility.Get("25 fps (PAL)"), false, () => { m_PlayFramerate = 25; }); menu.AddItem(VFXToolboxGUIUtility.Get("29.97 fps (NTSC)"), false, () => { m_PlayFramerate = 29.97f; }); menu.AddItem(VFXToolboxGUIUtility.Get("30 fps"), false, () => { m_PlayFramerate = 30; }); menu.AddItem(VFXToolboxGUIUtility.Get("50 fps"), false, () => { m_PlayFramerate = 50; }); menu.AddItem(VFXToolboxGUIUtility.Get("60 fps"), false, () => { m_PlayFramerate = 60; }); menu.ShowAsContext(); } m_PlayFramerate = EditorGUILayout.FloatField(m_PlayFramerate, VFXToolboxStyles.toolbarTextField, GUILayout.Width(24)); EditorGUILayout.LabelField(VFXToolboxGUIUtility.Get("fps"), GUILayout.Width(24)); }
private void DrawCanvasGUI(Rect rect) { if (previewCanvas.sequence.length > 1) previewCanvas.displayRect = new Rect(m_Splitter.value, Styles.ToolbarHeight, position.width - m_Splitter.value, position.height - 100 - Styles.ToolbarHeight); else previewCanvas.displayRect = new Rect(m_Splitter.value, Styles.ToolbarHeight, position.width - m_Splitter.value, position.height - Styles.ToolbarHeight); previewCanvas.OnGUI(this); // Draw Update Button if(m_CurrentAsset.exportSettings.fileName != "") { Rect exportButtonRect = new Rect(position.width - 100, Styles.ToolbarHeight + 12, 74, 24); if (GUI.Button(exportButtonRect, VFXToolboxGUIUtility.GetTextAndIcon("Update", "SaveActive"), VFXToolboxStyles.TabButtonSingle)) { UpdateExportedAssets(); } } }
private void DrawToolbar() { using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.Height(Styles.ToolbarHeight))) { EditorGUI.BeginChangeCheck(); bool prev; bool bMaskR = m_PreviewCanvas.maskR; bool bMaskG = m_PreviewCanvas.maskG; bool bMaskB = m_PreviewCanvas.maskB; bool bMaskA = m_PreviewCanvas.maskA; bool bMaskRGB = bMaskR && bMaskG && bMaskB; //GUILayout.Space(m_Splitter.value); using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.Width(m_Splitter.value - 1))) { if (GUILayout.Button(VFXToolboxGUIUtility.Get("Current Sequence: " + m_CurrentAsset.name), EditorStyles.toolbarButton)) { PingCurrentAsset(); } GUILayout.FlexibleSpace(); } Rect r = GUILayoutUtility.GetRect(VFXToolboxGUIUtility.GetTextAndIcon(" ", "SceneviewFx"), EditorStyles.toolbarPopup); if (GUI.Button(r, VFXToolboxGUIUtility.GetTextAndIcon(" ", "SceneviewFx"), EditorStyles.toolbarPopup)) { PopupWindow.Show(r, (PopupWindowContent) new CanvasConfigPopupWindowContent(this)); } GUILayout.Space(20); bMaskRGB = GUILayout.Toggle(bMaskRGB, styles.iconRGB, EditorStyles.toolbarButton); if (bMaskRGB != (bMaskR && bMaskG && bMaskB)) { bMaskR = bMaskG = bMaskB = bMaskRGB; m_PreviewCanvas.maskR = bMaskR; m_PreviewCanvas.maskG = bMaskG; m_PreviewCanvas.maskB = bMaskB; } prev = bMaskR; bMaskR = GUILayout.Toggle(bMaskR, VFXToolboxGUIUtility.Get("R"), styles.MaskRToggle, GUILayout.Width(20)); if (bMaskR != prev) { m_PreviewCanvas.maskR = bMaskR; } prev = bMaskG; bMaskG = GUILayout.Toggle(bMaskG, VFXToolboxGUIUtility.Get("G"), styles.MaskGToggle, GUILayout.Width(20)); if (bMaskG != prev) { m_PreviewCanvas.maskG = bMaskG; } prev = bMaskB; bMaskB = GUILayout.Toggle(bMaskB, VFXToolboxGUIUtility.Get("B"), styles.MaskBToggle, GUILayout.Width(20)); if (bMaskB != prev) { m_PreviewCanvas.maskB = bMaskB; } prev = bMaskA; bMaskA = GUILayout.Toggle(bMaskA, VFXToolboxGUIUtility.Get("A"), styles.MaskAToggle, GUILayout.Width(20)); if (bMaskA != prev) { m_PreviewCanvas.maskA = bMaskA; } if (m_PreviewCanvas.sequence != null && m_PreviewCanvas.numFrames > 0 && m_PreviewCanvas.currentFrame != null) { GUILayout.Space(20.0f); if (m_PreviewCanvas.mipMapCount > 0) { int currentMip = m_PreviewCanvas.mipMap; int newMip = currentMip; { Rect mipRect = GUILayoutUtility.GetRect(164, 24); GUI.Box(mipRect, GUIContent.none, VFXToolboxStyles.toolbarButton); GUI.Label(new RectOffset(0, 0, -6, 0).Remove(mipRect), styles.iconMipMapDown); newMip = (int)Mathf.Round(GUI.HorizontalSlider(new RectOffset(24, 64, 1, 0).Remove(mipRect), (float)newMip, 0.0f, (float)m_PreviewCanvas.mipMapCount - 1)); GUI.Label(new RectOffset(100, 0, -6, 0).Remove(mipRect), styles.iconMipMapUp); if (newMip != currentMip) { m_PreviewCanvas.mipMap = newMip; } GUI.Label(new RectOffset(124, 0, 3, 0).Remove(mipRect), (m_PreviewCanvas.mipMap + 1) + "/" + m_PreviewCanvas.mipMapCount, VFXToolboxStyles.toolbarLabelLeft); } } } if (EditorGUI.EndChangeCheck()) { m_PreviewCanvas.UpdateCanvasSequence(); // Reblit if changed the flags. } GUILayout.Space(20); { Rect brightnessRect = GUILayoutUtility.GetRect(160, 24); GUI.Box(brightnessRect, GUIContent.none, VFXToolboxStyles.toolbarButton); GUI.Label(new RectOffset(4, 0, 2, 0).Remove(brightnessRect), VFXToolboxGUIUtility.GetTextAndIcon("Background|Sets the Background Brightness", "CheckerFloor"), VFXToolboxStyles.toolbarLabelLeft); float newBrightness = GUI.HorizontalSlider(new RectOffset(82, 6, 1, 0).Remove(brightnessRect), previewCanvas.BackgroundBrightness, 0.0f, 1.0f); if (previewCanvas.BackgroundBrightness != newBrightness) { previewCanvas.BackgroundBrightness = newBrightness; } } GUILayout.FlexibleSpace(); } }
public void DrawSequenceControls(Rect ViewportArea, ImageSequencer editor) { m_PlayControlsRect = new Rect(ViewportArea.x, (ViewportArea.y + ViewportArea.height), ViewportArea.width, 100); using (new GUILayout.AreaScope(m_PlayControlsRect, GUIContent.none, ImageSequencer.styles.playbackControlWindow)) { Rect area = new Rect(16, 16, m_PlayControlsRect.width - 32, m_PlayControlsRect.height - 32); //GUILayout.BeginArea(area); using (new GUILayout.VerticalScope()) { // TRACKBAR int count = sequence.length; GUILayout.Space(16); // Reserve Layout for labels Rect bar_rect = GUILayoutUtility.GetRect(area.width, 16); EditorGUIUtility.AddCursorRect(bar_rect, MouseCursor.ResizeHorizontal); if (Event.current.type == EventType.MouseDown && bar_rect.Contains(Event.current.mousePosition)) { m_IsScrobbing = true; } if (Event.current.type == EventType.MouseUp || Event.current.rawType == EventType.MouseUp) { m_IsScrobbing = false; } if (m_IsScrobbing && (Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseDown)) { float pos = (Event.current.mousePosition.x - bar_rect.x) / bar_rect.width; int frame = (int)Mathf.Round(pos * numFrames); if (frame != currentFrameIndex) { currentFrameIndex = frame; Invalidate(true); } } EditorGUI.DrawRect(bar_rect, ImageSequencer.styles.CookBarDirty); float width = bar_rect.width / count; Rect textpos; for (int i = 0; i < count; i++) { if (!sequence.frames[i].dirty) { Rect cell = new Rect(bar_rect.x + i * width, bar_rect.y, width, bar_rect.height); EditorGUI.DrawRect(cell, ImageSequencer.styles.CookBarCooked); } if (i == currentFrameIndex) { Rect cursor = new Rect(bar_rect.x + i * width, bar_rect.y, width, bar_rect.height); EditorGUI.DrawRect(cursor, new Color(1.0f, 1.0f, 1.0f, 0.5f)); } // Labels : Every multiple of 10 based on homemade formula int step = 10 * (int)Mathf.Max(1, Mathf.Floor(8 * (float)count / bar_rect.width)); if (((i + 1) % step) == 0) { textpos = new Rect(bar_rect.x + i * width, bar_rect.y - 16, 32, 16); GUI.Label(textpos, (i + 1).ToString(), EditorStyles.largeLabel); Rect cursor = new Rect(bar_rect.x + i * width, bar_rect.y, 1, bar_rect.height); EditorGUI.DrawRect(cursor, new Color(1.0f, 1.0f, 1.0f, 0.2f)); } } // Labels : First textpos = new Rect(bar_rect.x, bar_rect.y - 16, 32, 16); GUI.Label(textpos, VFXToolboxGUIUtility.Get("1"), EditorStyles.largeLabel); GUILayout.Space(16); // PLAY CONTROLS bool lastplay; using (new GUILayout.HorizontalScope(EditorStyles.toolbar)) { lastplay = m_IsPlaying; if (GUILayout.Button(ImageSequencer.styles.iconFirst, VFXToolboxStyles.toolbarButton, GUILayout.Width(32))) { FirstFrame(); } if (GUILayout.Button(ImageSequencer.styles.iconBack, VFXToolboxStyles.toolbarButton, GUILayout.Width(24))) { PreviousFrame(); } bool playing = GUILayout.Toggle(m_IsPlaying, ImageSequencer.styles.iconPlay, VFXToolboxStyles.toolbarButton, GUILayout.Width(24)); if (m_IsPlaying != playing) { TogglePlaySequence(); } if (GUILayout.Button(ImageSequencer.styles.iconForward, VFXToolboxStyles.toolbarButton, GUILayout.Width(24))) { NextFrame(); } if (GUILayout.Button(ImageSequencer.styles.iconLast, VFXToolboxStyles.toolbarButton, GUILayout.Width(32))) { LastFrame(); } if (lastplay != m_IsPlaying) { m_EditorTime = EditorApplication.timeSinceStartup; } GUILayout.FlexibleSpace(); GUILayout.Label(VFXToolboxGUIUtility.GetTextAndIcon("Frame : ", "Profiler.Record"), VFXToolboxStyles.toolbarButton); m_CurrentFrame = Mathf.Clamp(EditorGUILayout.IntField(m_CurrentFrame + 1, VFXToolboxStyles.toolbarTextField, GUILayout.Width(42)) - 1, 0, numFrames - 1); GUILayout.Label(" on " + numFrames + " ( TCR : " + GetTCR(m_CurrentFrame, (int)m_PlayFramerate) + " ) ", VFXToolboxStyles.toolbarButton); GUILayout.FlexibleSpace(); ShowFrameratePopup(); } } //GUILayout.EndArea(); } }