void AddSerializedPlayableModifications(IPlayableAsset asset, AnimationClip clip) { var obj = asset as Object; if (obj == null) { return; } var driver = WindowState.previewDriver; if (driver == null || !AnimationMode.InAnimationMode(driver)) { return; } var bindings = AnimationClipCurveCache.Instance.GetCurveInfo(clip).bindings; var fields = AnimatedParameterExtensions.GetScriptPlayableFields(asset).ToList(); // go through each binding and offset using the field name // so the modification system can find the particle object using the asset as a root foreach (var b in bindings) { foreach (var f in fields) { DrivenPropertyManager.RegisterProperty(driver, obj, f.Name + "." + b.propertyName); } } }
private static string GetAnimatedParameterBindingName(TimelineClip clip, string parameterName) { string result; if (clip == null || clip.asset == null || clip.asset is IPlayableBehaviour) { result = parameterName; } else { IEnumerable <FieldInfo> scriptPlayableFields = AnimatedParameterExtensions.GetScriptPlayableFields(clip.asset as IPlayableAsset); foreach (FieldInfo current in scriptPlayableFields) { if (parameterName.StartsWith(current.Name)) { if (parameterName.Length > current.Name.Length && parameterName[current.Name.Length] == '.') { result = parameterName.Substring(current.Name.Length + 1); return(result); } } } result = parameterName; } return(result); }
internal static bool HasScriptPlayable(this TimelineClip clip) { bool result; if (clip.asset == null) { result = false; } else { IPlayableBehaviour playableBehaviour = clip.asset as IPlayableBehaviour; result = (playableBehaviour != null || AnimatedParameterExtensions.GetScriptPlayableFields(clip.asset as IPlayableAsset).Any <FieldInfo>()); } return(result); }
private void AddSerializedPlayableModifications(IPlayableAsset asset, AnimationClip clip) { Object @object = asset as Object; if (!(@object == null)) { AnimationModeDriver previewDriver = TimelineWindow.TimelineState.previewDriver; if (!(previewDriver == null) && AnimationMode.InAnimationMode(previewDriver)) { EditorCurveBinding[] bindings = AnimationClipCurveCache.Instance.GetCurveInfo(clip).bindings; List <FieldInfo> list = AnimatedParameterExtensions.GetScriptPlayableFields(asset).ToList <FieldInfo>(); EditorCurveBinding[] array = bindings; for (int i = 0; i < array.Length; i++) { EditorCurveBinding editorCurveBinding = array[i]; foreach (FieldInfo current in list) { DrivenPropertyManager.RegisterProperty(previewDriver, @object, current.Name + "." + editorCurveBinding.propertyName); } } } } }
internal static bool IsAnimatablePath(this TimelineClip clip, string path) { return(!(clip.asset == null) && AnimatedParameterExtensions.GetScriptPlayableFields(clip.asset as IPlayableAsset).Any((FieldInfo f) => path.StartsWith(f.Name) && path.Length > f.Name.Length && path[f.Name.Length] == '.')); }