/// <summary>
        /// Changes the displayed values for each field.
        /// </summary>
        /// <param name="values">Values to assign to the fields. Must match the number of displayed fields. </param>
        public void SetDisplayValues(GUIAnimFieldPathValue[] values)
        {
            for (int i = 0; i < fields.Length; i++)
            {
                string path = fields[i].Path;

                for (int j = 0; j < values.Length; j++)
                {
                    if(path == values[j].path)
                        fields[i].SetValue(values[j].value);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Changes the currently selected frame in the curve display.
        /// </summary>
        /// <param name="frameIdx">Index of the frame to select.</param>
        private void SetCurrentFrame(int frameIdx)
        {
            currentFrameIdx = Math.Max(0, frameIdx);

            frameInputField.Value = currentFrameIdx;
            guiCurveEditor.SetMarkedFrame(currentFrameIdx);

            float time = guiCurveEditor.GetTimeForFrame(currentFrameIdx);

            List<GUIAnimFieldPathValue> values = new List<GUIAnimFieldPathValue>();
            foreach (var kvp in clipInfo.curves)
            {
                GUIAnimFieldPathValue fieldValue = new GUIAnimFieldPathValue();
                fieldValue.path = kvp.Key;

                switch (kvp.Value.type)
                {
                    case SerializableProperty.FieldType.Vector2:
                        {
                            Vector2 value = new Vector2();

                            for (int i = 0; i < 2; i++)
                                value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);

                            fieldValue.value = value;
                        }
                        break;
                    case SerializableProperty.FieldType.Vector3:
                        {
                            Vector3 value = new Vector3();

                            for (int i = 0; i < 3; i++)
                                value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);

                            fieldValue.value = value;
                        }
                        break;
                    case SerializableProperty.FieldType.Vector4:
                        {
                            Vector4 value = new Vector4();

                            for (int i = 0; i < 4; i++)
                                value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);

                            fieldValue.value = value;
                        }
                        break;
                    case SerializableProperty.FieldType.Color:
                        {
                            Color value = new Color();

                            for (int i = 0; i < 4; i++)
                                value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);

                            fieldValue.value = value;
                        }
                        break;
                    case SerializableProperty.FieldType.Bool:
                    case SerializableProperty.FieldType.Int:
                    case SerializableProperty.FieldType.Float:
                        fieldValue.value = kvp.Value.curveInfos[0].curve.Evaluate(time, false); ;
                        break;
                }

                values.Add(fieldValue);
            }

            guiFieldDisplay.SetDisplayValues(values.ToArray());
        }
Exemplo n.º 3
0
        private void SetCurrentFrame(int frameIdx)
        {
            currentFrameIdx = Math.Max(0, frameIdx);

            frameInputField.Value = currentFrameIdx;
            guiCurveEditor.SetMarkedFrame(currentFrameIdx);

            float time = guiCurveEditor.GetTimeForFrame(currentFrameIdx);

            List <GUIAnimFieldPathValue> values = new List <GUIAnimFieldPathValue>();

            foreach (var kvp in clipInfo.curves)
            {
                GUIAnimFieldPathValue fieldValue = new GUIAnimFieldPathValue();
                fieldValue.path = kvp.Key;

                switch (kvp.Value.type)
                {
                case SerializableProperty.FieldType.Vector2:
                {
                    Vector2 value = new Vector2();

                    for (int i = 0; i < 2; i++)
                    {
                        value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);
                    }

                    fieldValue.value = value;
                }
                break;

                case SerializableProperty.FieldType.Vector3:
                {
                    Vector3 value = new Vector3();

                    for (int i = 0; i < 3; i++)
                    {
                        value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);
                    }

                    fieldValue.value = value;
                }
                break;

                case SerializableProperty.FieldType.Vector4:
                {
                    Vector4 value = new Vector4();

                    for (int i = 0; i < 4; i++)
                    {
                        value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);
                    }

                    fieldValue.value = value;
                }
                break;

                case SerializableProperty.FieldType.Color:
                {
                    Color value = new Color();

                    for (int i = 0; i < 4; i++)
                    {
                        value[i] = kvp.Value.curveInfos[i].curve.Evaluate(time, false);
                    }

                    fieldValue.value = value;
                }
                break;

                case SerializableProperty.FieldType.Bool:
                case SerializableProperty.FieldType.Int:
                case SerializableProperty.FieldType.Float:
                    fieldValue.value = kvp.Value.curveInfos[0].curve.Evaluate(time, false);;
                    break;
                }

                values.Add(fieldValue);
            }

            guiFieldDisplay.SetDisplayValues(values.ToArray());
        }