private void RenderSectionTitle(string title, string iconName)
        {
            GUIStyle bgStyle = new GUIStyle();

            bgStyle.normal.background = m_SectionHeaderBg;
            bgStyle.margin            = new RectOffset(0, 0, 20, 7);
            bgStyle.padding           = new RectOffset(0, 0, 0, 0);

            GUIStyle titleStyle = new GUIStyle(GUI.skin.label);

            titleStyle.normal.textColor = Color.black;
            titleStyle.fontStyle        = FontStyle.Bold;
            titleStyle.fontSize         = k_TitleSize;
            titleStyle.margin           = new RectOffset(0, 0, 0, 0);
            titleStyle.padding          = new RectOffset(0, 0, 3, 0);

            GUIStyle iconStyle = new GUIStyle();

            iconStyle.margin  = new RectOffset(0, 0, 0, 0);
            iconStyle.padding = new RectOffset(0, 0, 0, 0);

            EditorGUILayout.BeginHorizontal(bgStyle, GUILayout.Height(k_HeaderHeight));

            // Default to a placeholder icon if we don't have one.
            string  loadIconFile = iconName != null ? iconName : "UnknownSectionIcon";
            Texture icon         = SkyEditorUtility.LoadEditorResourceTexture(loadIconFile);

            EditorGUILayout.LabelField(new GUIContent(icon), iconStyle, GUILayout.Width(k_IconSize), GUILayout.Height(k_IconSize));
            EditorGUILayout.LabelField(new GUIContent(title), titleStyle);

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
        }
Esempio n. 2
0
        private bool RenderGroupButton(Rect rowRect, int buttonIndex, string iconName, string tooltip)
        {
            Texture2D texIcon = SkyEditorUtility.LoadEditorResourceTexture(iconName);

            if (texIcon == null)
            {
                Debug.LogError("Failed to load icon for group button.");
                return(false);
            }

            Color originalColor = GUI.color;

            GUI.contentColor = GUI.skin.label.normal.textColor;

            const float buttonPadding    = 2.0f;
            const float buttonEndPadding = 5.0f;
            Rect        btnRect          = new Rect(
                NAME_COLUMN_WIDTH - buttonEndPadding - ((buttonIndex + 1) * ICON_BUTTON_SIZE) - ((buttonIndex) * buttonPadding),
                rowRect.y + (rowRect.height - ICON_BUTTON_SIZE) / 2.0f,
                ICON_BUTTON_SIZE,
                ICON_BUTTON_SIZE
                );

            bool didClickButton = GUI.Button(
                btnRect,
                new GUIContent(null, texIcon, tooltip),
                m_ButtonStyle);

            GUI.contentColor = originalColor;
            return(didClickButton);
        }
Esempio n. 3
0
        // These are the buttons next to the current time of day at the top.
        private void RenderGlobalTimelineButtons(Rect rect, TimeOfDayController tc)
        {
            GUILayout.BeginArea(rect);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            float buttonSize           = 20.0f;
            Color originalContentColor = GUI.contentColor;

            GUI.contentColor = GUI.skin.label.normal.textColor;

            GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);

            buttonStyle.padding = new RectOffset(2, 2, 2, 2);


            Texture2D addTexture = SkyEditorUtility.LoadEditorResourceTexture("AddIcon");

            bool didClickAddButton = GUILayout.Button(
                new GUIContent(addTexture, "Add a sky property to the timeline."),
                buttonStyle, GUILayout.Width(buttonSize), GUILayout.Height(buttonSize));

            GUILayout.Space(LEFT_INSET);
            if (didClickAddButton)
            {
                SkyGUITimelineMenu.ShowAddTimelinePropertyMenu(m_ActiveSkyProfile);
            }

            GUI.contentColor = originalContentColor;
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
Esempio n. 4
0
        private void RenderTimelineCursor(Rect rect, TimeOfDayController timeController)
        {
            // Flag the start of a timeline drag.
            if (TimelineSelection.isDraggingTimeline == false &&
                (Event.current.type == EventType.MouseDrag) &&
                rect.Contains(Event.current.mousePosition))
            {
                TimelineSelection.isDraggingTimeline = true;
            }

            if (TimelineSelection.isDraggingTimeline)
            {
                float percent = Mathf.Clamp((Event.current.mousePosition.x - rect.x) / rect.width, 0, MAX_TIME_VALUE);
                timeController.skyTime = percent;
                EditorUtility.SetDirty(timeController);
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            float playHeadHeight = PLAYHEAD_WIDTH / 2.0f;

            float xCursorPos = SkyEditorUtility.GetXPositionForPercent(rect, timeController.timeOfDay);

            // Draw the line that overlaps all the content rows.
            const float extensionSize = 5.0f;
            Rect        lineRect      = new Rect(
                xCursorPos - (CURSOR_LINE_WIDTH / 2.0f),
                rect.y + TIME_HEADER_HEIGHT - extensionSize,
                CURSOR_LINE_WIDTH,
                rect.height - TIME_HEADER_HEIGHT + extensionSize);

            GUI.DrawTexture(lineRect, SkyEditorUtility.LoadEditorResourceTexture("CursorLine"));

            // Draw the playhead arrow.
            if (m_PlayheadTexture == null)
            {
                m_PlayheadTexture = SkyEditorUtility.LoadEditorResourceTexture("PlayheadArrow");
            }

            Rect headRect = new Rect(
                xCursorPos - (PLAYHEAD_WIDTH / 2.0f),
                rect.y + TIME_HEADER_HEIGHT - playHeadHeight,
                PLAYHEAD_WIDTH,
                playHeadHeight);

            GUI.DrawTexture(headRect, m_PlayheadTexture, ScaleMode.StretchToFill, true);
        }
Esempio n. 5
0
        private void ApplyDefaultSettings(SkyProfile profile)
        {
            // Lightning art.
            if (profile.lightningArtSet == null)
            {
                profile.lightningArtSet = GetDefaultArtStyleWithName <LightningArtSet>("DefaultLightningArtSet");
            }

            // Splash art.
            if (profile.rainSplashArtSet == null)
            {
                profile.rainSplashArtSet = GetDefaultArtStyleWithName <RainSplashArtSet>("DefaultRainSplashArtSet");
            }

            // Rain near texture.
            TextureKeyframeGroup group = profile.GetGroup <TextureKeyframeGroup>(ProfilePropertyKeys.RainNearTextureKey);

            if (group.keyframes.Count == 1 && group.keyframes[0].texture == null)
            {
                group.keyframes[0].texture = SkyEditorUtility.LoadEditorResourceTexture("RainDownfall-1");
                if (group.keyframes[0].texture == null)
                {
                    Debug.LogWarning("Failed to locate default near rain texture");
                }
            }

            // Rain far texture.
            group = profile.GetGroup <TextureKeyframeGroup>(ProfilePropertyKeys.RainFarTextureKey);
            if (group.keyframes.Count == 1 && group.keyframes[0].texture == null)
            {
                group.keyframes[0].texture = SkyEditorUtility.LoadEditorResourceTexture("RainDownfall-3");
                if (group.keyframes[0].texture == null)
                {
                    Debug.LogWarning("Failed to locate default far rain texture");
                }
            }
        }
Esempio n. 6
0
        // Returns the index
        public static bool RenderTableList(
            List <string> list, out int deleteIndex, out bool didSwapRows, out int swapIndex1, out int swapIndex2)
        {
            bool didModifyList = false;

            deleteIndex = -1;

            didSwapRows = false;
            swapIndex1  = -1;
            swapIndex2  = -1;


            EditorGUILayout.BeginVertical(GUI.skin.box);
            GUIStyle    rowStyle     = new GUIStyle(GUI.skin.label);
            const float buttonHeight = 15.0f;

            for (int i = 0; i < list.Count; i++)
            {
                string item = list[i];

                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal(rowStyle);

                EditorGUILayout.LabelField(item, GUI.skin.label);

                GUILayout.FlexibleSpace();

                if (_deleteRowIcon == null)
                {
                    _deleteRowIcon = SkyEditorUtility.LoadEditorResourceTexture("RowDelete");
                }

                if (_upRowIcon == null)
                {
                    _upRowIcon = SkyEditorUtility.LoadEditorResourceTexture("RowUp");
                }

                if (_downRowIcon == null)
                {
                    _downRowIcon = SkyEditorUtility.LoadEditorResourceTexture("RowDown");
                }

                // Tint our images to match the editor skin text.
                Color originalColor = GUI.contentColor;
                GUI.contentColor = GUI.skin.label.normal.textColor;

                // Move row up.
                if (i - 1 >= 0)
                {
                    EditorGUI.BeginChangeCheck();
                    GUILayout.Button(new GUIContent(_upRowIcon), GUILayout.Height(buttonHeight));
                    if (EditorGUI.EndChangeCheck())
                    {
                        // Swap with row above.
                        swapIndex1    = i;
                        swapIndex2    = i - 1;
                        didSwapRows   = true;
                        didModifyList = true;
                    }
                }

                // Move row down.
                if (i + 1 < list.Count)
                {
                    EditorGUI.BeginChangeCheck();
                    GUILayout.Button(new GUIContent(_downRowIcon), GUILayout.Height(buttonHeight));
                    if (EditorGUI.EndChangeCheck())
                    {
                        swapIndex1    = i;
                        swapIndex2    = i + 1;
                        didSwapRows   = true;
                        didModifyList = true;
                    }
                }


                // Delete this row.
                EditorGUI.BeginChangeCheck();
                GUILayout.Button(new GUIContent(_deleteRowIcon), GUILayout.Height(buttonHeight));
                if (EditorGUI.EndChangeCheck())
                {
                    didModifyList = true;
                    deleteIndex   = i;
                }

                GUI.contentColor = originalColor;

                EditorGUILayout.EndHorizontal();

                // Draw a divider between rows.
                if (i != list.Count - 1)
                {
                    Rect dividerRect = EditorGUILayout.GetControlRect(false, 1.0f);
                    EditorGUI.DrawRect(dividerRect, Color.gray);
                }

                EditorGUILayout.EndVertical();
            }

            GUILayout.EndVertical();

            GUI.changed = didModifyList;
            return(didModifyList);
        }
Esempio n. 7
0
        private static void RenderLinePath(Rect rect, NumberKeyframeGroup group)
        {
            if ((int)rect.width <= 0 || (int)rect.height <= 0 || Event.current.type != EventType.Repaint)
            {
                return;
            }

            int squareSize = 2048;

            if (m_LineRenderTexture == null)
            {
                m_LineRenderTexture = new RenderTexture(
                    squareSize,
                    squareSize,
                    16,
                    RenderTextureFormat.ARGB32,
                    RenderTextureReadWrite.sRGB);
                m_LineRenderTexture.antiAliasing = 2;
                m_LineRenderTexture.filterMode   = FilterMode.Bilinear;
            }

            if (!m_LineRenderTexture.IsCreated())
            {
                m_LineRenderTexture.Create();
            }

            if (m_LineMesh == null)
            {
                m_LineMesh = new Mesh()
                {
                    hideFlags = HideFlags.HideAndDontSave
                };
                m_LineMesh.MarkDynamic();
            }

            List <Vector3> points = GetLinePoints(group);

            // Background color.
            Color bgColor = new Color(k_BackgroundShade, k_BackgroundShade, k_BackgroundShade);

            // Line shader.
            if (m_LineMaterial == null)
            {
                m_LineMaterial = new Material(Shader.Find("Hidden/Funly/Sky/SoftLine"))
                {
                    hideFlags = HideFlags.HideInHierarchy
                };
            }

            m_LineMaterial.SetColor("_LineColor", ColorHelper.ColorWithHexAlpha(0x2AFBFFFF));
            m_LineMaterial.SetFloat("_EdgeFeathering", k_LineEdgeFeathering);
            m_LineMaterial.SetColor("_BackgroundColor", bgColor);
            m_LineMaterial.SetTexture("_MainTex", SkyEditorUtility.LoadEditorResourceTexture("NumberShadowLine", false));

            if (m_LineShadowMaterial == null)
            {
                m_LineShadowMaterial = new Material(Shader.Find("Hidden/Funly/Sky/LineShadow"))
                {
                    hideFlags = HideFlags.HideInHierarchy
                };
            }

            Color shadowColor = new Color(k_ShadowShade, k_ShadowShade, k_ShadowShade, 1.0f);

            m_LineShadowMaterial.SetColor("_BackgroundColor", bgColor);
            m_LineShadowMaterial.SetColor("_ShadowColor", shadowColor);

            // Setup tmp texture to render into.
            RenderTexture oldRenderTexture = RenderTexture.active;

            RenderTexture.active = m_LineRenderTexture;

            GL.PushMatrix();
            GL.LoadPixelMatrix(0, m_LineRenderTexture.width, 0, m_LineRenderTexture.height);
            GL.Clear(true, true, bgColor);

            float lineInset     = 5.0f;
            float heightScale   = rect.height / rect.width;
            float lineThickness = k_LineThickness * heightScale;

            BuildLineMesh(
                m_LineMesh, points,
                m_LineRenderTexture.width,
                m_LineRenderTexture.width * heightScale - (lineInset * 2),
                lineThickness);

            // Line shadow.
            m_LineShadowMaterial.SetPass(0);
            Graphics.DrawMeshNow(m_LineMesh, new Vector3(0, lineInset - 8, 0), Quaternion.identity);

            // Actual line.
            m_LineMaterial.SetPass(0);
            Graphics.DrawMeshNow(m_LineMesh, new Vector3(0, lineInset, 0), Quaternion.identity);

            GL.PopMatrix();

            RenderTexture.active = oldRenderTexture;

            // Pull out just the snippet section we want to use.
            Rect textureRect = new Rect(
                0, 0, 1, heightScale);

            GUI.DrawTextureWithTexCoords(rect, m_LineRenderTexture, textureRect);
        }
Esempio n. 8
0
        private void RenderVerticalDivider(Rect dividerRect, string imageName = "VerticalDividerOverlay")
        {
            Texture2D dividerTexture = SkyEditorUtility.LoadEditorResourceTexture(imageName);

            GUI.DrawTexture(dividerRect, dividerTexture);
        }