Ejemplo n.º 1
0
        // Render color property.
        public bool RenderColorGroupProperty(ProfileGroupDefinition def)
        {
            EditorGUILayout.BeginHorizontal();

            ColorKeyframeGroup group = m_Profile.GetGroup <ColorKeyframeGroup>(def.propertyKey);

            EditorGUILayout.PrefixLabel(new GUIContent(group.name, def.tooltip));
            bool valueChanged = false;

            if (m_Profile.IsManagedByTimeline(def.propertyKey))
            {
                RenderManagedOnTimlineMessage();
            }
            else
            {
                ColorKeyframe frame = group.GetKeyframe(0);

                EditorGUI.BeginChangeCheck();
                Color selectedColor = EditorGUILayout.ColorField(frame.color);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_Profile, "Changed color keyframe value");
                    frame.color  = selectedColor;
                    valueChanged = true;
                }
            }

            EditorGUILayout.EndHorizontal();
            return(valueChanged);
        }
Ejemplo n.º 2
0
        private void RenderRowTitle(Rect rect, string rowTitle, bool isActive, ProfileGroupDefinition groupDefinition)
        {
            GUILayout.Space(LEFT_INSET);
            m_GroupTitleStyle.fontStyle = isActive ? FontStyle.Bold : FontStyle.Normal;

            const float labelHeight = 18;
            Rect        labelRect   = new Rect(
                5, rect.y + ((rect.height - labelHeight) / 2.0f), NAME_COLUMN_WIDTH, labelHeight);

            EditorGUI.LabelField(labelRect, new GUIContent(rowTitle, groupDefinition.tooltip), m_GroupTitleStyle);

            // Render buttons over the active row.
            if (isActive)
            {
                if (RenderGroupButton(rect, 1, "AddIcon", "Add a keyframe at the current cursor position."))
                {
                    DidClickAddNewKeyframe(m_ActiveTimeController);
                }

                if (RenderGroupButton(rect, 0, "HelpIcon", "Show help information about this group property."))
                {
                    GroupHelpWindow.SetHelpItem(m_ActiveSkyProfile, groupDefinition.propertyKey, true);
                }
            }

            // Draw a divider between rows.
            float dividerYPosition = rect.y + rect.height + (ROW_PADDING / 2.0f) - HORIZONTAL_DIVIDER_HEIGHT;

            RenderHorizontalDivider(new Rect(rect.x, dividerYPosition, rect.width, HORIZONTAL_DIVIDER_HEIGHT));
        }
Ejemplo n.º 3
0
        // Render texture property.
        public bool RenderTextureGroupProperty(ProfileGroupDefinition def)
        {
            EditorGUILayout.BeginHorizontal();

            TextureKeyframeGroup group = m_Profile.GetGroup <TextureKeyframeGroup>(def.propertyKey);

            EditorGUILayout.PrefixLabel(new GUIContent(group.name, def.tooltip));
            bool valueChanged = false;

            if (m_Profile.IsManagedByTimeline(def.propertyKey))
            {
                RenderManagedOnTimlineMessage();
            }
            else
            {
                TextureKeyframe frame = group.GetKeyframe(0);
                EditorGUI.BeginChangeCheck();
                Texture assignedTexture = (Texture)EditorGUILayout.ObjectField(frame.texture, typeof(Texture), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_Profile, "Changed texture keyframe value");
                    frame.texture = assignedTexture;
                    valueChanged  = true;
                }
            }

            EditorGUILayout.EndHorizontal();
            return(valueChanged);
        }
Ejemplo n.º 4
0
        public ProfileGroupDefinition GetGroupDefinitionForKey(string propertyKey)
        {
            ProfileGroupDefinition def = null;

            if (m_KeyToGroupInfo.TryGetValue(propertyKey, out def))
            {
                return(def);
            }

            return(null);
        }
Ejemplo n.º 5
0
 // Blacklist some groups from being on the timeline.
 public bool CanGroupBeOnTimeline(ProfileGroupDefinition definition)
 {
     if (definition.type == ProfileGroupDefinition.GroupType.Texture ||
         (definition.propertyKey.Contains("Star") && definition.propertyKey.Contains("Density")) ||
         definition.propertyKey.Contains("Sprite") ||
         definition.type == ProfileGroupDefinition.GroupType.Boolean)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        public static ProfileGroupDefinition BoolGroupDefinition(
            string groupName, string propKey, bool value, string dependsOnKeyword, bool dependsOnValue, string tooltip)
        {
            ProfileGroupDefinition def = new ProfileGroupDefinition();

            def.type             = GroupType.Boolean;
            def.groupName        = groupName;
            def.propertyKey      = propKey;
            def.dependsOnFeature = dependsOnKeyword;
            def.dependsOnValue   = dependsOnValue;
            def.tooltip          = tooltip;
            def.boolValue        = value;

            return(def);
        }
        public static ProfileGroupDefinition SpherePointGroupDefinition(string groupName, string propKey,
                                                                        float horizontalRotation, float verticalRotation, RebuildType rebuildType, string dependsOnKeyword, bool dependsOnValue, string tooltip)
        {
            ProfileGroupDefinition def = new ProfileGroupDefinition();

            def.type             = GroupType.SpherePoint;
            def.propertyKey      = propKey;
            def.groupName        = groupName;
            def.tooltip          = tooltip;
            def.rebuildType      = rebuildType;
            def.dependsOnFeature = dependsOnKeyword;
            def.dependsOnValue   = dependsOnValue;
            def.spherePoint      = new SpherePoint(horizontalRotation, verticalRotation);

            return(def);
        }
        public static ProfileGroupDefinition TextureGroupDefinition(
            string groupName, string propKey, Texture2D texture, RebuildType rebuildType,
            string dependsOnKeyword, bool dependsOnValue, string tooltip)
        {
            ProfileGroupDefinition def = new ProfileGroupDefinition();

            def.type             = GroupType.Texture;
            def.groupName        = groupName;
            def.propertyKey      = propKey;
            def.texture          = texture;
            def.tooltip          = tooltip;
            def.rebuildType      = rebuildType;
            def.dependsOnFeature = dependsOnKeyword;
            def.dependsOnValue   = dependsOnValue;

            return(def);
        }
Ejemplo n.º 9
0
        public List <ProfileGroupDefinition> GetGroupDefinitionsManagedByTimeline()
        {
            List <ProfileGroupDefinition> groups = new List <ProfileGroupDefinition>();

            foreach (string groupKey in timelineManagedKeys)
            {
                ProfileGroupDefinition groupDefinition = GetGroupDefinitionForKey(groupKey);
                if (groupDefinition == null)
                {
                    continue;
                }

                groups.Add(groupDefinition);
            }

            return(groups);
        }
Ejemplo n.º 10
0
        // Render numeric properties with a slider.
        public bool RenderNumericGroupProperty(ProfileGroupDefinition def)
        {
            EditorGUILayout.BeginHorizontal();
            NumberKeyframeGroup group = m_Profile.GetGroup <NumberKeyframeGroup>(def.propertyKey);

            EditorGUILayout.PrefixLabel(new GUIContent(group.name, def.tooltip));
            bool valueChanged = false;

            if (m_Profile.IsManagedByTimeline(def.propertyKey))
            {
                RenderManagedOnTimlineMessage();
            }
            else
            {
                NumberKeyframe frame = group.GetKeyframe(0);

                if (def.formatStyle == ProfileGroupDefinition.FormatStyle.Integer)
                {
                    EditorGUI.BeginChangeCheck();
                    int value = EditorGUILayout.IntField((int)frame.value);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(m_Profile, "Changed int keyframe value");
                        frame.value  = (int)Mathf.Clamp(value, group.minValue, group.maxValue);
                        valueChanged = true;
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    float value = EditorGUILayout.Slider(frame.value, group.minValue, group.maxValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(m_Profile, "Changed float keyframe value");
                        frame.value  = value;
                        valueChanged = true;
                    }
                }
            }

            EditorGUILayout.EndHorizontal();

            return(valueChanged);
        }
        public static ProfileGroupDefinition NumberGroupDefinition(
            string groupName, string propKey, float minimumValue, float maximumValue, float value,
            RebuildType rebuildType, FormatStyle formatStyle, string dependsOnKeyword, bool dependsOnValue, string tooltip)
        {
            ProfileGroupDefinition def = new ProfileGroupDefinition();

            def.type             = GroupType.Number;
            def.formatStyle      = formatStyle;
            def.groupName        = groupName;
            def.propertyKey      = propKey;
            def.value            = value;
            def.minimumValue     = minimumValue;
            def.maximumValue     = maximumValue;
            def.tooltip          = tooltip;
            def.rebuildType      = rebuildType;
            def.dependsOnFeature = dependsOnKeyword;
            def.dependsOnValue   = dependsOnValue;

            return(def);
        }
Ejemplo n.º 12
0
        private void RebuildTimelineDefinitions(SkyProfile profile)
        {
            if (m_TimelineDefinitions == null)
            {
                m_TimelineDefinitions = new List <ProfileGroupDefinition>();
            }

            m_TimelineDefinitions.Clear();

            foreach (string groupKey in profile.timelineManagedKeys)
            {
                ProfileGroupDefinition groupDefinition = profile.GetGroupDefinitionForKey(groupKey);
                if (groupDefinition == null)
                {
                    //Debug.LogError("Failed to get group definition for key: " + groupKey);
                    continue;
                }

                m_TimelineDefinitions.Add(groupDefinition);
            }
        }
Ejemplo n.º 13
0
        private bool RenderSpherePointPropertyGroup(ProfileGroupDefinition def)
        {
            EditorGUILayout.BeginHorizontal();
            bool valueChanged = false;

            SpherePointKeyframeGroup group = m_Profile.GetGroup <SpherePointKeyframeGroup>(def.propertyKey);

            if (m_Profile.IsManagedByTimeline(def.propertyKey))
            {
                EditorGUILayout.PrefixLabel(new GUIContent(def.groupName, def.tooltip));
                RenderManagedOnTimlineMessage();
            }
            else
            {
                SpherePointKeyframe frame = group.GetKeyframe(0);

                EditorGUILayout.BeginVertical();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent(group.name, def.tooltip));
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                EditorGUI.BeginChangeCheck();
                EditorGUI.indentLevel += 1;
                SpherePoint selectedPoint = SpherePointGUI.SpherePointField(
                    frame.spherePoint, true, frame.id);
                EditorGUI.indentLevel -= 1;
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_Profile, "Changed sphere point");
                    frame.spherePoint = selectedPoint;
                }

                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndHorizontal();
            return(valueChanged);
        }
Ejemplo n.º 14
0
        // Render all properties in a group.
        public bool RenderProfileGroup(ProfileGroupDefinition groupDefinition)
        {
            if (groupDefinition.dependsOnFeature != null &&
                m_Profile.IsFeatureEnabled(groupDefinition.dependsOnFeature) != groupDefinition.dependsOnValue)
            {
                return(false);
            }

            bool valueChanged = false;

            if (groupDefinition.type == ProfileGroupDefinition.GroupType.Color)
            {
                valueChanged = RenderColorGroupProperty(groupDefinition);
            }
            else if (groupDefinition.type == ProfileGroupDefinition.GroupType.Number)
            {
                valueChanged = RenderNumericGroupProperty(groupDefinition);
            }
            else if (groupDefinition.type == ProfileGroupDefinition.GroupType.Texture)
            {
                valueChanged = RenderTextureGroupProperty(groupDefinition);
            }
            else if (groupDefinition.type == ProfileGroupDefinition.GroupType.SpherePoint)
            {
                valueChanged = RenderSpherePointPropertyGroup(groupDefinition);
            }
            else if (groupDefinition.type == ProfileGroupDefinition.GroupType.Boolean)
            {
                valueChanged = RenderBooleanPropertyGroup(groupDefinition);
            }

            // Check if this property needs to rebuild the sky.
            if (valueChanged && groupDefinition.rebuildType == ProfileGroupDefinition.RebuildType.Stars)
            {
                RebuildSkySystem();
            }

            return(valueChanged);
        }
Ejemplo n.º 15
0
        private void RenderHelpItem(string helpKey)
        {
            GUIStyle titleStyle = new GUIStyle(GUI.skin.label);

            titleStyle.fontStyle = FontStyle.Bold;

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

            textStyle.wordWrap = true;

            if (ContainsHelpForKey(helpKey) == false)
            {
                EditorGUILayout.HelpBox("There is no help entry for property key: " + helpKey, MessageType.Info);
                return;
            }

            ProfileGroupDefinition groupDefinition = m_HelpItems[helpKey];

            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField(groupDefinition.groupName, titleStyle);
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(groupDefinition.tooltip, textStyle);

            string imageName = ImageNameForHelpPropertyKey();

            if (imageName != null)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                // TODO - Draw image.

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 16
0
        // Render a timeline of sphere point keyframes.
        private void RenderSpherePointRowAndAdvance(ref Rect rect, SkyProfile profile, SpherePointKeyframeGroup group, ProfileGroupDefinition groupDefinition)
        {
            rect.height = SPHERE_POINT_ROW_HEIGHT;
            UpdateActiveSelectedRow(rect, group.id, groupDefinition.propertyKey);

            Rect valueRowRect;
            Rect nameRowRect;
            bool isActive;

            LoadRowInformation(ref rect, group.id, SPHERE_POINT_ROW_HEIGHT, out valueRowRect, out nameRowRect, out isActive);

            // Render debug points if this is active.
            if (isActive)
            {
                ShowSpherePointKeyframesInSkybox(group);
            }

            RenderRowTitle(nameRowRect, group.name, isActive, groupDefinition);
            SpherePointTimelineRow.RenderSpherePointRow(valueRowRect, profile, group);
        }
Ejemplo n.º 17
0
        // Render a timeline of numeric keyframe positions.
        private void RenderNumericRowAndAdvance(ref Rect rect, SkyProfile profile, NumberKeyframeGroup group, ProfileGroupDefinition groupDefinition)
        {
            rect.height = NUMBER_ROW_HEIGHT;
            UpdateActiveSelectedRow(rect, group.id, groupDefinition.propertyKey);

            Rect valueRowRect;
            Rect nameRowRect;
            bool isActive;

            LoadRowInformation(ref rect, group.id, NUMBER_ROW_HEIGHT, out valueRowRect, out nameRowRect, out isActive);

            RenderRowTitle(nameRowRect, group.name, isActive, groupDefinition);
            NumberTimelineRow.RenderNumberGroup(valueRowRect, profile, group);
        }
Ejemplo n.º 18
0
        // Render a timeline of gradient keyframes.
        private void RenderGradientRowAndAdvance(ref Rect rect, SkyProfile profile, ColorKeyframeGroup group, ProfileGroupDefinition groupDefinition)
        {
            rect.height = COLOR_ROW_HEIGHT;
            UpdateActiveSelectedRow(rect, group.id, groupDefinition.propertyKey);

            Rect valueRowRect;
            Rect nameRowRect;
            bool isActive;

            LoadRowInformation(ref rect, group.id, COLOR_ROW_HEIGHT, out valueRowRect, out nameRowRect, out isActive);

            RenderRowTitle(nameRowRect, group.name, isActive, groupDefinition);
            ColorTimelineRow.RenderColorGroupRow(valueRowRect, profile, group);
        }