コード例 #1
0
ファイル: TrackAsset.cs プロジェクト: 0geova0/Jam
        /// <summary>
        /// Creates a timeline clip from an existing playable asset.
        /// </summary>
        /// <param name="asset"></param>
        /// <returns></returns>
        internal TimelineClip CreateClipFromPlayableAsset(IPlayableAsset asset)
        {
            if (asset == null)
                throw new ArgumentNullException("asset");

            if ((asset as ScriptableObject) == null)
                throw new System.ArgumentException("CreateClipFromPlayableAsset " + " only supports ScriptableObject-derived Types");

            if (!ValidateClipType(asset.GetType()))
                throw new System.InvalidOperationException("Clips of type " + asset.GetType() + " are not permitted on tracks of type " + GetType());

            return CreateClipFromAsset(asset as ScriptableObject);
        }
コード例 #2
0
        public static FieldInfo[] GetScriptPlayableFields(IPlayableAsset asset)
        {
            if (asset == null)
            {
                return(new FieldInfo[0]);
            }

            FieldInfo[] scriptPlayableFields;
            if (!AnimatedParameterCache.TryGetScriptPlayableFields(asset.GetType(), out scriptPlayableFields))
            {
                scriptPlayableFields = GetScriptPlayableFields_Internal(asset);
                AnimatedParameterCache.SetScriptPlayableFields(asset.GetType(), scriptPlayableFields);
            }

            return(scriptPlayableFields);
        }
コード例 #3
0
        internal static IEnumerable <FieldInfo> GetScriptPlayableFields(IPlayableAsset asset)
        {
            if (asset == null)
            {
                return(new FieldInfo[0]);
            }

            return(asset.GetType().GetFields().Where(f => f.IsPublic && !f.IsStatic && typeof(IPlayableBehaviour).IsAssignableFrom(f.FieldType)));
        }
コード例 #4
0
 static FieldInfo[] GetScriptPlayableFields_Internal(IPlayableAsset asset)
 {
     return(asset.GetType()
            .GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
            .Where(
                f => typeof(IPlayableBehaviour).IsAssignableFrom(f.FieldType) &&                 // The field is an IPlayableBehaviour
                (f.IsPublic || f.GetCustomAttributes(typeof(SerializeField), false).Any()) &&    // The field is either public or marked with [SerializeField]
                !f.GetCustomAttributes(typeof(NotKeyableAttribute), false).Any() &&              // The field is not marked with [NotKeyable]
                !f.GetCustomAttributes(typeof(HideInInspector), false).Any() &&                  // The field is not marked with [HideInInspector]
                !f.FieldType.GetCustomAttributes(typeof(NotKeyableAttribute), false).Any())      // The field is not of a type marked with [NotKeyable]
            .ToArray());
 }
コード例 #5
0
        internal static IEnumerable <FieldInfo> GetScriptPlayableFields(IPlayableAsset asset)
        {
            IEnumerable <FieldInfo> result;

            if (asset == null)
            {
                result = new FieldInfo[0];
            }
            else
            {
                result = from f in asset.GetType().GetFields()
                         where f.IsPublic && !f.IsStatic && typeof(IPlayableBehaviour).IsAssignableFrom(f.FieldType)
                         select f;
            }
            return(result);
        }
コード例 #6
0
ファイル: TimelineHelpers.cs プロジェクト: 0geova0/Jam
        /// <summary>
        /// Create a clip on track from an existing PlayableAsset
        /// </summary>
        public static TimelineClip CreateClipOnTrackFromPlayableAsset(IPlayableAsset asset, TrackAsset parentTrack, double candidateTime)
        {
            if (parentTrack == null || asset == null || !TypeUtility.IsConcretePlayableAsset(asset.GetType()))
            {
                return(null);
            }

            TimelineClip newClip = null;

            try
            {
                newClip = parentTrack.CreateClipFromPlayableAsset(asset);
            }
            catch
            {
                return(null);
            }

            WindowState state = null;

            if (TimelineWindow.instance != null)
            {
                state = TimelineWindow.instance.state;
            }

            AddClipOnTrack(newClip, parentTrack, candidateTime, null, state);

            return(newClip);
        }