コード例 #1
0
        private void OnGUI()
        {
            LoadStyles();

            TimeOfDayController timeController = FindObjectOfType <TimeOfDayController>() as TimeOfDayController;

            // Render a setup helper UI.
            if (timeController == null)
            {
                RenderNeedsSkySetupLayout();
                return;
            }

            // Render a profile help message UI.
            if (timeController.skyProfile == null)
            {
                RenderNeedsProfileLayout();
                return;
            }

            m_ActiveTimeController = timeController;
            m_ActiveSkyProfile     = timeController ? timeController.skyProfile : null;

            RebuildTimelineDefinitions(timeController.skyProfile);
            float contentHeight  = CalculateWindowContentHeight(timeController.skyProfile);
            float scrollbarInset = 0;

            // Select the first colorGroup if one isn't selected.
            if (TimelineSelection.selectedGroupUUID == null &&
                timeController.skyProfile.timelineManagedKeys.Count > 0)
            {
                IKeyframeGroup group = timeController.skyProfile.GetGroup(timeController.skyProfile.timelineManagedKeys[0]);
                if (group != null)
                {
                    TimelineSelection.selectedGroupUUID = group.id;
                }
            }

            // Inset content on the right to make room for scroll bar.
            if (contentHeight > position.height)
            {
                scrollbarInset = CONTENT_INSET;
            }

            // Timeline rect.
            Rect contentRect = new Rect(
                0,
                0,
                position.width - scrollbarInset,
                position.height);

            // Check if mouse left the window, and cancel drag operations.
            if (Event.current.type == EventType.MouseLeaveWindow ||
                contentRect.Contains(Event.current.mousePosition) == false)
            {
                SkyEditorUtility.CancelTimelineDrags();
            }

            // Loads the list of timeline groups to render.
            RenderTimelineEditor(contentRect, timeController, contentHeight);

            // Save the edits to the profile object.
            if (timeController != null)
            {
                EditorUtility.SetDirty(timeController.skyProfile);

                // Keep the scene view rendering in sync for live editing.
                timeController.UpdateSkyForCurrentTime();
            }
        }
コード例 #2
0
        private void RenderTimelineEditor(Rect rect, TimeOfDayController timeController, float contentHeight)
        {
            float nameColMinX   = rect.x;
            float valueColMinX  = nameColMinX + NAME_COLUMN_WIDTH;
            float valueColMaxX  = rect.xMax;
            float valueColWidth = rect.width - NAME_COLUMN_WIDTH;

            // Check for the end of a timeline drag.
            if (TimelineSelection.isDraggingTimeline && Event.current.type == EventType.MouseUp)
            {
                TimelineSelection.isDraggingTimeline = false;
            }

            // If we're busy dragging the timeline, consume the events so child views don't see them.
            if (Event.current.type == EventType.MouseDrag && TimelineSelection.isDraggingTimeline)
            {
                Event.current.Use();
            }

            // Check if user dragged in the time ruler so we don't click things behind it.
            if (DidDragTimeRuler())
            {
                SkyEditorUtility.CancelTimelineDrags();
                TimelineSelection.isDraggingTimeline = true;
                Event.current.Use();
            }

            float fullContentHeight = Mathf.Max(position.height, contentHeight);

            // Background style.
            RenderBackground();

            // Render timeline buttons at header.
            Rect toolbarRect = new Rect(nameColMinX,
                                        rect.y, NAME_COLUMN_WIDTH, TIME_HEADER_HEIGHT);

            RenderHeaderButtons(toolbarRect, timeController);

            // Render Scrubber.
            Rect timeScrubberRect = new Rect(valueColMinX, rect.y,
                                             valueColWidth - VALUE_COLUMN_INSET, TIME_HEADER_HEIGHT);

            RenderTimeRuler(timeScrubberRect, timeController.timeOfDay);

            // Show an empty content help message.
            if (timeController.skyProfile.timelineManagedKeys.Count == 0)
            {
                RenderEmptyTimelineMessage();
            }

            Rect innerScrollViewContent = new Rect(
                0,
                0,
                rect.width,
                contentHeight - TIME_HEADER_HEIGHT);

            Rect scrollWindowPosition = new Rect(0, TIME_HEADER_HEIGHT, position.width, rect.height - TIME_HEADER_HEIGHT);

            m_ScrollPosition = GUI.BeginScrollView(scrollWindowPosition, m_ScrollPosition, innerScrollViewContent, false, false);

            // Render all the content rows.
            Rect rowsRect = new Rect(rect.x, 0, rect.width, 0);

            RenderAllRows(rowsRect, timeController.skyProfile);
            RenderSpherePointGroupDebugPointsIfSelected();

            GUI.EndScrollView();

            // Draw the cursor, which overlaps the other content.
            Rect cursorRect = new Rect(
                valueColMinX, rect.y, valueColWidth - VALUE_COLUMN_INSET, fullContentHeight);

            RenderTimelineCursor(cursorRect, timeController);
        }