Files
Magical-Jumping-Bean/Library/metadata/4c/4c1821c1816c6fa44967b8ecb79ea7e4
T

358 lines
19 KiB
Plaintext
Raw Normal View History

2019-09-29 19:40:54 -04:00
íJ@2019.2.3f1þÿÿÿÿÿ’3$øÌuñ옲e+ Í=^7€ÿÿÿÿ¦€²Ð¦¦¦€#¦€+H€3ÿÿÿÿ1€1€ÿÿÿÿ@Þ Q€j
H€<ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jÕ€Iÿÿÿÿ1€1€ÿÿÿÿÀÞH€j€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€j€PAssetMetaDataguiddata[0]data[1]data[2]data[3]pathNameoriginalNamelabelsassetStoreRef ÿÿfš†!ë5˜9Ý4QÁóBí7€ÿÿÿÿ¦€²
E Þ€#.€,5a Þ€#.€,€r Þ€# .€,
H€«€ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jñ€JÿÿÿÿÀ1€1€ÿÿÿÿÞ€j€ÿÿÿÿ\€ÿÿÿÿH€rÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jH€wÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jH€€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jy
 Þ€#!.€,"€…ÿÿÿÿ#@1€1€ÿÿÿÿ$Þ%.€j&Õ€“ÿÿÿÿ'1€1€ÿÿÿÿ(ÀÞ)€j€ÿÿÿÿ*H€›€ÿÿÿÿ+1€1€ÿÿÿÿ,@Þ-Q€j.y
 /Þ€#0.€,1 €§2@¾€¶ 3@Þ€#4.€,5H€»ÿÿÿÿ61€1€ÿÿÿÿ7@Þ8Q€j9H€Æÿÿÿÿ:1€1€ÿÿÿÿ;@Þ<Q€j=H€Øÿÿÿÿ>1€1€ÿÿÿÿ?@Þ@Q€jAMonoImporterPPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_ExternalObjectsSourceAssetIdentifiertypeassemblynamem_UsedFileIDsm_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariantsÿÿ£Gñ×ÜZ56 :!@iÁJ*€7€ÿÿÿÿ¦€²E Þ.(a Þ.€r Þ .
H€«€ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jH€ê€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jñ€=ÿÿÿÿ1€1€ÿÿÿÿÞ€j€ÿÿÿÿH€›€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jy
 Þ.y€Q Þ. Þ€X!H€iÿÿÿÿ"1€1€ÿÿÿÿ#@Þ$Q€j%H€uÿÿÿÿ&1€1€ÿÿÿÿ'@Þ(Q€j)PPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespacedh\ày¯Èh6ÄÆöJ”v‹Î{ézN;Packages/com.unity.timeline/Editor/Utilities/TypeUtility.csày¯ TypeUtilityð5using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
using Component = UnityEngine.Component;
using Object = UnityEngine.Object;
namespace UnityEditor.Timeline
{
static class TypeUtility
{
private static Type[] s_AllTrackTypes;
private static Type[] s_AllClipTypes;
private static Type[] s_MarkerTypes;
private static Dictionary<Type, Type[]> s_TrackTypeToVisibleClipType = new Dictionary<Type, Type[]>();
private static Dictionary<Type, Type[]> s_TrackTypeToAllClipType = new Dictionary<Type, Type[]>();
private static Dictionary<Type, TrackBindingTypeAttribute> s_TrackToBindingCache = new Dictionary<Type, TrackBindingTypeAttribute>();
public static bool IsConcretePlayableAsset(Type t)
{
return typeof(IPlayableAsset).IsAssignableFrom(t)
&& typeof(ScriptableObject).IsAssignableFrom(t)
&& !t.IsAbstract
&& !t.IsGenericType
&& !t.IsInterface
&& !typeof(TrackAsset).IsAssignableFrom(t)
&& !typeof(TimelineAsset).IsAssignableFrom(t);
}
/// <summary>
/// List of all PlayableAssets
/// </summary>
public static IEnumerable<Type> AllClipTypes()
{
if (s_AllClipTypes == null)
{
s_AllClipTypes = EditorAssemblies.loadedTypes.
Where(t => IsConcretePlayableAsset(t)).
ToArray();
}
return s_AllClipTypes;
}
public static IEnumerable<Type> AllTrackTypes()
{
if (s_AllTrackTypes == null)
{
s_AllTrackTypes = EditorAssemblies.loadedTypes
.Where(x => !x.IsAbstract && typeof(TrackAsset).IsAssignableFrom(x))
.ToArray();
}
return s_AllTrackTypes;
}
public static IEnumerable<Type> GetVisiblePlayableAssetsHandledByTrack(Type trackType)
{
if (trackType == null || !typeof(TrackAsset).IsAssignableFrom(trackType))
return Enumerable.Empty<Type>();
Type[] types;
if (s_TrackTypeToVisibleClipType.TryGetValue(trackType, out types))
{
return types;
}
// special case -- the playable track handles all types not handled by other tracks
if (trackType == typeof(PlayableTrack))
{
types = GetUnhandledClipTypes().ToArray();
s_TrackTypeToVisibleClipType[trackType] = types;
return types;
}
var attributes = trackType.GetCustomAttributes(typeof(TrackClipTypeAttribute), true);
var baseClasses = attributes.
OfType<TrackClipTypeAttribute>().
Where(t => t.allowAutoCreate).
Select(a => a.inspectedType);
types = AllClipTypes().Where(t => baseClasses.Any(x => x.IsAssignableFrom(t))).ToArray();
s_TrackTypeToVisibleClipType[trackType] = types;
return types;
}
public static IEnumerable<Type> GetPlayableAssetsHandledByTrack(Type trackType)
{
if (trackType == null || !typeof(TrackAsset).IsAssignableFrom(trackType))
return Enumerable.Empty<Type>();
Type[] types;
if (s_TrackTypeToAllClipType.TryGetValue(trackType, out types))
{
return types;
}
// special case -- the playable track handles all types not handled by other tracks
if (trackType == typeof(PlayableTrack))
{
types = GetUnhandledClipTypes().ToArray();
s_TrackTypeToAllClipType[trackType] = types;
return types;
}
var attributes = trackType.GetCustomAttributes(typeof(TrackClipTypeAttribute), true);
var baseClasses = attributes.
OfType<TrackClipTypeAttribute>().
Select(a => a.inspectedType);
types = AllClipTypes().Where(t => baseClasses.Any(x => x.IsAssignableFrom(t))).ToArray();
s_TrackTypeToAllClipType[trackType] = types;
return types;
}
/// <summary>
/// Returns the binding attribute attrached to the track
/// </summary>
public static TrackBindingTypeAttribute GetTrackBindingAttribute(Type trackType)
{
if (trackType == null || !typeof(TrackAsset).IsAssignableFrom(trackType))
return null;
TrackBindingTypeAttribute attribute = null;
if (!s_TrackToBindingCache.TryGetValue(trackType, out attribute))
{
attribute = (TrackBindingTypeAttribute)Attribute.GetCustomAttribute(trackType, typeof(TrackBindingTypeAttribute));
s_TrackToBindingCache.Add(trackType, attribute);
}
return attribute;
}
/// <summary>
/// True if the given track has a clip type that handles the given object
/// </summary>
public static bool TrackHasClipForObject(Type trackType, Object obj)
{
return GetPlayableAssetsHandledByTrack(trackType)
.Any(c => ObjectReferenceField.FindObjectReferences(c).Any(o => o.IsAssignable(obj)));
}
/// <summary>
/// Get the list of markers that have fields for the object
/// </summary>
public static IEnumerable<Type> MarkerTypesWithFieldForObject(Object obj)
{
return GetAllMarkerTypes().Where(
c => ObjectReferenceField.FindObjectReferences(c).Any(o => o.IsAssignable(obj))
);
}
/// <summary>
/// Get the list of tracks that can handle this object as clips
/// </summary>
public static IEnumerable<Type> GetTrackTypesForObject(Object obj)
{
if (obj == null)
return Enumerable.Empty<Type>();
return AllTrackTypes().Where(t => TrackHasClipForObject(t, obj));
}
/// <summary>
/// Given a trackType and an object, does the binding type match
/// Takes into account whether creating a missing component is permitted
/// </summary>
public static bool IsTrackCreatableFromObject(Object obj, Type trackType)
{
if (obj == null || obj.IsPrefab())
return false;
var attribute = GetTrackBindingAttribute(trackType);
if (attribute == null || attribute.type == null)
return false;
if (attribute.type.IsAssignableFrom(obj.GetType()))
return true;
var gameObject = obj as GameObject;
if (gameObject != null && typeof(Component).IsAssignableFrom(attribute.type))
{
return gameObject.GetComponent(attribute.type) != null ||
(attribute.flags & TrackBindingFlags.AllowCreateComponent) != 0;
}
return false;
}
/// <summary>
/// Given an object, get the list of track that are creatable from it. Takes
/// binding flags into account
/// </summary>
public static IEnumerable<Type> GetTracksCreatableFromObject(Object obj)
{
if (obj == null)
return Enumerable.Empty<Type>();
return AllTrackTypes().Where(t => !IsHiddenInMenu(t) && IsTrackCreatableFromObject(obj, t));
}
/// <summary>
/// Get the list of playable assets that can handle an object for a particular track
/// </summary>
/// <param name="trackType">The type of the track</param>
/// <param name="obj">The object to handle</param>
/// <returns></returns>
public static IEnumerable<Type> GetAssetTypesForObject(Type trackType, Object obj)
{
if (obj == null)
return Enumerable.Empty<Type>();
return GetPlayableAssetsHandledByTrack(trackType).Where(
c => ObjectReferenceField.FindObjectReferences(c).Any(o => o.IsAssignable(obj))
);
}
// get the track types for a track from it's attributes
private static IEnumerable<Type> GetTrackClipTypesFromAttributes(Type trackType)
{
if (trackType == null || !typeof(TrackAsset).IsAssignableFrom(trackType))
return Enumerable.Empty<Type>();
var attributes = trackType.GetCustomAttributes(typeof(TrackClipTypeAttribute), true);
var baseClasses = attributes.
OfType<TrackClipTypeAttribute>().
Select(a => a.inspectedType);
return AllClipTypes().Where(t => baseClasses.Any(x => x.IsAssignableFrom(t)));
}
// find the playable asset types that are unhandled
private static IEnumerable<Type> GetUnhandledClipTypes()
{
var typesHandledByTrack = AllTrackTypes().SelectMany(t => GetTrackClipTypesFromAttributes(t));
// exclude anything in the timeline assembly, handled by tracks, has a hide in menu attribute
// or is explicity ignored
return AllClipTypes()
.Except(typesHandledByTrack)
.Where(t => t.Assembly != typeof(TimelineAsset).Assembly) // exclude built-in
.Where(t => !typeof(TrackAsset).IsAssignableFrom(t)) // exclude track types (they are playable assets)
.Where(t => !t.IsDefined(typeof(HideInMenuAttribute), false) && !t.IsDefined(typeof(IgnoreOnPlayableTrackAttribute), true))
.Distinct();
}
public static IEnumerable<Type> GetAllMarkerTypes()
{
if (s_MarkerTypes == null)
s_MarkerTypes = EditorAssemblies.loadedTypes.Where(x =>
typeof(IMarker).IsAssignableFrom(x) &&
typeof(ScriptableObject).IsAssignableFrom(x)
&& !x.IsAbstract
&& !x.IsGenericType
&& !x.IsInterface).ToArray();
return s_MarkerTypes;
}
public static IEnumerable<Type> GetUserMarkerTypes()
{
return GetAllMarkerTypes().Where(x => !x.Assembly.Equals(typeof(TimelineAsset).Assembly));
}
public static IEnumerable<Type> GetBuiltInMarkerTypes()
{
return GetAllMarkerTypes().Where(x => x.Assembly.Equals(typeof(TimelineAsset).Assembly));
}
public static bool DoesTrackSupportMarkerType(TrackAsset track, Type type)
{
if (track.supportsNotifications)
{
return true;
}
return !typeof(INotification).IsAssignableFrom(type);
}
internal static string GetDisplayName(Type t)
{
var displayName = ObjectNames.NicifyVariableName(t.Name);
var attr = Attribute.GetCustomAttribute(t, typeof(DisplayNameAttribute)) as DisplayNameAttribute;
if (attr != null)
displayName = attr.DisplayName;
return displayName;
}
/// <summary>
/// Gets a menu item name from an Enum value
/// </summary>
/// <param name="item"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static string GetMenuItemName<T>(T item)
{
var name = item.ToString();
if (typeof(T).IsEnum)
{
var f = typeof(T).GetField(name);
if (f != null)
{
var description = f.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (description.Length > 0)
{
name = ((DescriptionAttribute)description.First()).Description;
}
}
}
return ObjectNames.NicifyVariableName(name);
}
public static bool IsHiddenInMenu(Type type)
{
var attr = type.GetCustomAttributes(typeof(HideInMenuAttribute), false);
return attr.Length > 0;
}
public struct ObjectReference
{
public Type type;
public bool isSceneReference;
}
public static IEnumerable<ObjectReference> ObjectReferencesForType(Type type)
{
var objectReferences = ObjectReferenceField.FindObjectReferences(type);
var uniqueTypes = objectReferences.Select(objRef => objRef.type).Distinct();
foreach (var refType in uniqueTypes)
{
var isSceneReference = objectReferences.Any(objRef => objRef.type == refType && objRef.isSceneReference);
yield return new ObjectReference { type = refType, isSceneReference = isSceneReference };
}
}
/// <summary>
/// Checks whether a type has an overridden method with a specific name. This method also checks overridden members in parent classes.
/// </summary>
public static bool HasOverrideMethod(System.Type t, string name)
{
const MethodAttributes mask = MethodAttributes.Virtual | MethodAttributes.NewSlot;
const MethodAttributes expectedResult = MethodAttributes.Virtual;
var method = t.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return method != null && (method.Attributes & mask) == expectedResult;