From c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Apr 2020 17:19:32 -0400 Subject: Inital commit --- .../Editor/Utilities/AnimatedParameterCache.cs | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Library/PackageCache/com.unity.timeline@1.2.13/Editor/Utilities/AnimatedParameterCache.cs (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Editor/Utilities/AnimatedParameterCache.cs') diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Utilities/AnimatedParameterCache.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Utilities/AnimatedParameterCache.cs new file mode 100644 index 0000000..d5f091f --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Utilities/AnimatedParameterCache.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace UnityEditor.Timeline +{ + static class AnimatedParameterCache + { + static readonly Dictionary k_ScriptPlayableFieldsCache = new Dictionary(); + static readonly Dictionary k_PropertyFieldInfoCache = new Dictionary(); + static readonly Dictionary k_PropertyIsAnimatableCache = new Dictionary(); + static readonly Dictionary k_BindingNameCache = new Dictionary(); + + public static bool TryGetScriptPlayableFields(Type type, out FieldInfo[] scriptPlayableFields) + { + return k_ScriptPlayableFieldsCache.TryGetValue(type, out scriptPlayableFields); + } + + public static void SetScriptPlayableFields(Type type, FieldInfo[] scriptPlayableFields) + { + k_ScriptPlayableFieldsCache[type] = scriptPlayableFields; + } + + public static bool TryGetFieldInfoForProperty(SerializedProperty property, out FieldInfo fieldInfo) + { + return k_PropertyFieldInfoCache.TryGetValue(new PropertyKey(property), out fieldInfo); + } + + public static void SetFieldInfoForProperty(SerializedProperty property, FieldInfo fieldInfo) + { + k_PropertyFieldInfoCache[new PropertyKey(property)] = fieldInfo; + } + + public static bool TryGetIsPropertyAnimatable(SerializedProperty property, out bool isAnimatable) + { + return k_PropertyIsAnimatableCache.TryGetValue(new PropertyKey(property), out isAnimatable); + } + + public static void SetIsPropertyAnimatable(SerializedProperty property, bool isAnimatable) + { + k_PropertyIsAnimatableCache[new PropertyKey(property)] = isAnimatable; + } + + public static bool TryGetBindingName(Type type, string path, out string bindingName) + { + return k_BindingNameCache.TryGetValue(new PropertyKey(type, path), out bindingName); + } + + public static void SetBindingName(Type type, string path, string bindingName) + { + k_BindingNameCache[new PropertyKey(type, path)] = bindingName; + } + } + + struct PropertyKey : IEquatable + { + readonly Type m_Type; + readonly string m_Path; + + public PropertyKey(SerializedProperty property) + { + m_Type = property.serializedObject.targetObject.GetType(); + m_Path = property.propertyPath; + } + + public PropertyKey(Type type, string path) + { + m_Type = type; + m_Path = path; + } + + public bool Equals(PropertyKey other) + { + return m_Type == other.m_Type && string.Equals(m_Path, other.m_Path); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + return obj is PropertyKey && Equals((PropertyKey)obj); + } + + public override int GetHashCode() + { + unchecked + { + return ((m_Type != null ? m_Type.GetHashCode() : 0) * 397) ^ (m_Path != null ? m_Path.GetHashCode() : 0); + } + } + } +} -- cgit v1.2.3