private AudioTrack.BeatList GetPropertyObject(SerializedProperty property) { if (_instance == null) { var path = property.propertyPath.Split('.'); object propertyObject = property.serializedObject.targetObject; foreach (var pathNode in path) { propertyObject = propertyObject.GetType().GetField(pathNode).GetValue(propertyObject); } _instance = propertyObject as AudioTrack.BeatList; } return(_instance); }
private static void LoadFromText(AudioTrack.BeatList target, IEnumerable <string> lines) { var beats = lines.Select((l, i) => new NumberedLine(i, l.Trim())) .Where(l => !l.Text.StartsWith("#")) .Select(l => { TimeSpan val; if (!TimeSpan.TryParse(l.Text, out val)) { var errorMessage = string.Format("Parse error at line {0}: {1}", l.Num, l.Text); EditorUtility.DisplayDialog("Error", errorMessage, "OK"); throw new ArgumentException(errorMessage); } return((float)val.TotalSeconds); }); target.SetFromBeats(beats); }