private void RemoveSelectedFields() { for (int i = 0; i < selectedFields.Count; i++) { clipInfo.curves.Remove(GetSubPathParent(selectedFields[i])); } UpdateCurveColors(); UpdateDisplayedFields(); selectedFields.Clear(); EditorApplication.SetProjectDirty(); UpdateDisplayedCurves(); }
private void AddNewField(string path, SerializableProperty.FieldType type) { bool noSelection = selectedFields.Count == 0; switch (type) { case SerializableProperty.FieldType.Vector4: { FieldAnimCurves fieldCurves = new FieldAnimCurves(); fieldCurves.type = type; 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.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.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.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.curveInfos = new CurveDrawInfo[1]; fieldCurves.curveInfos[0].curve = new EdAnimationCurve(); selectedFields.Add(path); clipInfo.curves[path] = fieldCurves; } break; } UpdateCurveColors(); UpdateDisplayedFields(); EditorApplication.SetProjectDirty(); UpdateDisplayedCurves(noSelection); }
private void OnEventsChanged() { clipInfo.events = guiCurveEditor.Events; EditorApplication.SetProjectDirty(); }