/// <summary> /// Registers a new animation curve field. /// </summary> /// <param name="path">Path of the field, see <see cref="GUIFieldSelector.OnElementSelected"/></param> /// <param name="type">Type of the field (float, vector, etc.)</param> private void AddNewField(string path, SerializableProperty.FieldType type) { bool noSelection = selectedFields.Count == 0; bool isPropertyCurve = !clipInfo.isImported && !EditorAnimClipInfo.IsMorphShapeCurve(path); switch (type) { case SerializableProperty.FieldType.Vector4: { FieldAnimCurves fieldCurves = new FieldAnimCurves(); fieldCurves.type = type; fieldCurves.isPropertyCurve = isPropertyCurve; fieldCurves.curveInfos = new CurveDrawInfo[4]; string[] subPaths = { ".x", ".y", ".z", ".w" }; for (int i = 0; i < subPaths.Length; i++) { string subFieldPath = path + subPaths[i]; fieldCurves.curveInfos[i].curve = new EdAnimationCurve(); selectedFields.Add(subFieldPath); } clipInfo.curves[path] = fieldCurves; } break; case SerializableProperty.FieldType.Vector3: { FieldAnimCurves fieldCurves = new FieldAnimCurves(); fieldCurves.type = type; fieldCurves.isPropertyCurve = isPropertyCurve; fieldCurves.curveInfos = new CurveDrawInfo[3]; string[] subPaths = { ".x", ".y", ".z" }; for (int i = 0; i < subPaths.Length; i++) { string subFieldPath = path + subPaths[i]; fieldCurves.curveInfos[i].curve = new EdAnimationCurve(); selectedFields.Add(subFieldPath); } clipInfo.curves[path] = fieldCurves; } break; case SerializableProperty.FieldType.Vector2: { FieldAnimCurves fieldCurves = new FieldAnimCurves(); fieldCurves.type = type; fieldCurves.isPropertyCurve = isPropertyCurve; fieldCurves.curveInfos = new CurveDrawInfo[2]; string[] subPaths = { ".x", ".y" }; for (int i = 0; i < subPaths.Length; i++) { string subFieldPath = path + subPaths[i]; fieldCurves.curveInfos[i].curve = new EdAnimationCurve(); selectedFields.Add(subFieldPath); } clipInfo.curves[path] = fieldCurves; } break; case SerializableProperty.FieldType.Color: { FieldAnimCurves fieldCurves = new FieldAnimCurves(); fieldCurves.type = type; fieldCurves.isPropertyCurve = isPropertyCurve; fieldCurves.curveInfos = new CurveDrawInfo[4]; string[] subPaths = { ".r", ".g", ".b", ".a" }; for (int i = 0; i < subPaths.Length; i++) { string subFieldPath = path + subPaths[i]; fieldCurves.curveInfos[i].curve = new EdAnimationCurve(); selectedFields.Add(subFieldPath); } clipInfo.curves[path] = fieldCurves; } break; default: // Primitive type { FieldAnimCurves fieldCurves = new FieldAnimCurves(); fieldCurves.type = type; fieldCurves.isPropertyCurve = isPropertyCurve; fieldCurves.curveInfos = new CurveDrawInfo[1]; fieldCurves.curveInfos[0].curve = new EdAnimationCurve(); selectedFields.Add(path); clipInfo.curves[path] = fieldCurves; } break; } UpdateCurveColors(); UpdateDisplayedFields(); EditorApplication.SetProjectDirty(); UpdateDisplayedCurves(noSelection); }
public AnimFieldInfo(string path, FieldAnimCurves curveGroup) { this.path = path; this.curveGroup = curveGroup; }