Beispiel #1
0
        // Use vertex shader to fix aspect ratio.
        public static void RenderNumberGroup(Rect rect, SkyProfile profile, NumberKeyframeGroup group)
        {
            lock (profile) {
                bool sortKeyFrames = false;

                RenderLinePath(rect, group);

                for (int i = 0; i < group.keyframes.Count; i++)
                {
                    NumberKeyframe currentKey = group.GetKeyframe(i);

                    int            nextIndex = (i + 1) % group.keyframes.Count;
                    NumberKeyframe nextKey   = group.GetKeyframe(nextIndex);

                    // Clamp time if we're wrapping around.
                    float nextTime = nextKey.time;
                    if (nextTime <= currentKey.time)
                    {
                        nextTime = 1.0f;
                    }

                    bool didSingleClick  = false;
                    bool isDragging      = false;
                    bool keyframeUpdated = false;

                    SkyEditorUtility.DrawNumericKeyMarker(rect, currentKey, group, profile,
                                                          out didSingleClick, out isDragging, out keyframeUpdated);

                    if (keyframeUpdated)
                    {
                        sortKeyFrames = true;
                    }

                    if (didSingleClick || isDragging)
                    {
                        KeyframeInspectorWindow.SetKeyframeData(
                            currentKey, group, KeyframeInspectorWindow.KeyType.Numeric, profile);

                        if (didSingleClick && KeyframeInspectorWindow.inspectorEnabled == false)
                        {
                            KeyframeInspectorWindow.ShowWindow();
                        }
                    }
                }

                if (sortKeyFrames)
                {
                    group.SortKeyframes();
                }
            }
        }
        // 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);
        }