public static void Create(BGMList.Param param)
    {
        //TimelineAssetの生成
        TimelineAsset timeline = Initialize <TimelineAsset>(param.dictKey);

        AudioTrack[]     audioTracks = timeline.GetRootTracks() as AudioTrack[];
        List <AudioClip> audioClips  = AssetLoader.LoadAll <AudioClip>("BGM/" + param.dictKey); //ここでファイル名でソートさせる必要がありそう

        foreach (AudioTrack audioTrack in audioTracks)
        {
            timeline.DeleteTrack(audioTrack);
        }
        //AudioTrackの作成
        for (int i = 0; i <= param.subTrackTimeMarkers.Count; i++)
        {
            timeline.CreateTrack <AudioTrack>();
        }
        audioTracks = timeline.GetRootTracks() as AudioTrack[];
        //AudioClipの割り当て
        //メイントラック
        audioTracks[0].CreateClip(audioClips[0]);
        IEnumerable <TimelineClip> timelineClips = audioTracks[0].GetClips();

        foreach (TimelineClip clip in timelineClips)
        {
            clip.clipIn   = 0;
            clip.duration = audioClips[1].length;
            clip.start    = 0;
        }
        timeline.CreateMarkerTrack();
        //ループマーカーの追加
        timeline.markerTrack.CreateMarker(typeof(LoopStartMarker), param.loopTimeMarkers.loopStartTime);
        timeline.markerTrack.CreateMarker(typeof(LoopEndMarker), param.loopTimeMarkers.loopEndTime);
        //セクションマーカーの追加
        if (param.sectionMarkers.Count > 0)
        {
            foreach (double sectionmarker in param.sectionMarkers)
            {
                timeline.markerTrack.CreateMarker(typeof(SectionMarker), sectionmarker);
            }
        }
        if (param.subTrackTimeMarkers.Count <= 0)
        {
            return;
        }
        //サブトラックの割り当て
        for (int i = 1; i <= param.subTrackTimeMarkers.Count; i++)
        {
            audioTracks[i].CreateClip(audioClips[i]);
            timelineClips = audioTracks[i].GetClips();


            foreach (TimelineClip clip in timelineClips)
            {
                clip.clipIn   = 0;
                clip.duration = param.subTrackTimeMarkers[i - 1].endTime - param.subTrackTimeMarkers[i - 1].startTime;
                clip.start    = param.subTrackTimeMarkers[i - 1].startTime;
            }
        }
    }
Beispiel #2
0
        static void AddSingleMarkerCallback(Type markerType, double time, TimelineAsset timeline, PlayableDirector director, Object assignableObject)
        {
            timeline.CreateMarkerTrack();
            var markerTrack = timeline.markerTrack;

            SelectionManager.Clear();
            var marker = TimelineHelpers.CreateMarkerOnTrack(markerType, assignableObject, markerTrack, time);

            SelectionManager.Add(marker);

            if (typeof(INotification).IsAssignableFrom(markerType) && director != null)
            {
                if (director != null && director.GetGenericBinding(markerTrack) == null)
                {
                    director.SetGenericBinding(markerTrack, director.gameObject);
                }
            }

            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
        }
        internal void SetShowMarkerHeader(bool newValue)
        {
            TimelineAsset asset = state.editSequence.asset;

            if (state.showMarkerHeader == newValue || asset == null)
            {
                return;
            }

            string undoOperation = L10n.Tr("Toggle Show Markers");

            if (newValue)
            {
                //Create the marker track if it does not exist
                TimelineUndo.PushUndo(asset, undoOperation);
                asset.CreateMarkerTrack();
            }
            else
            {
                SelectionManager.Remove(asset.markerTrack);
            }

            asset.markerTrack.SetShowTrackMarkers(newValue);
        }
    public static void GenerateNewTimeline(TimelineAsset originTimeline, TimelineAsset dstTimeline)
    {
        dstTimeline.CreateMarkerTrack();

        foreach (IMarker output in  originTimeline.markerTrack.GetMarkers())
        {
            EnemyMarker marker = output as EnemyMarker;

            if (marker == null)
            {
                Debug.Log("Marker added " + output.time);
                continue;
            }

            double deltaTime    = EnemyBase.Distance / marker.enemyParams.speed;
            double creationTime = marker.time - deltaTime;

            EnemyNotificationMarker copyMarker = dstTimeline.markerTrack.CreateMarker(typeof(EnemyNotificationMarker), creationTime) as EnemyNotificationMarker;

            copyMarker.enemyParams = marker.enemyParams;

            Debug.Log("Old time " + marker.time + ", New time " + creationTime);
        }
    }
        public static DragAndDropVisualMode HandleClipPaneObjectDragAndDrop(IEnumerable<UnityObject> objectsBeingDropped, TrackAsset targetTrack, bool perform, TimelineAsset timeline, TrackAsset parent, PlayableDirector director, double candidateTime, TypeResolver typeResolver, TrackAsset insertBefore = null)
        {
            if (timeline == null)
                return DragAndDropVisualMode.Rejected;

            // locked tracks always reject
            if (targetTrack != null && targetTrack.lockedInHierarchy)
                return DragAndDropVisualMode.Rejected;

            // treat group tracks as having no track
            if (targetTrack is GroupTrack)
            {
                parent = targetTrack;
                targetTrack = null;
            }

            // Special case for monoscripts, since they describe the type
            if (objectsBeingDropped.Any(o => o is MonoScript))
                return HandleClipPaneMonoScriptDragAndDrop(objectsBeingDropped.OfType<MonoScript>(), targetTrack, perform, timeline, parent, director, candidateTime);

            // no unity objects, or explicit exceptions
            if (!objectsBeingDropped.Any() || objectsBeingDropped.Any(o => !ValidateObjectDrop(o)))
                return DragAndDropVisualMode.Rejected;

            // reject scene references if we have no context
            if (director == null && objectsBeingDropped.Any(o => o.IsSceneObject()))
                return DragAndDropVisualMode.Rejected;

            var validTrackTypes = objectsBeingDropped.SelectMany(o => TypeUtility.GetTrackTypesForObject(o)).Distinct().ToList();
            // special case for playable assets
            if (objectsBeingDropped.Any(o => TypeUtility.IsConcretePlayableAsset(o.GetType())))
            {
                var playableAssets = objectsBeingDropped.OfType<IPlayableAsset>().Where(o => TypeUtility.IsConcretePlayableAsset(o.GetType()));
                return HandleClipPanePlayableAssetDragAndDrop(playableAssets, targetTrack, perform, timeline, parent, director, candidateTime, typeResolver);
            }

            var markerTypes = objectsBeingDropped.SelectMany(o => TypeUtility.MarkerTypesWithFieldForObject(o)).Distinct();

            // Markers support all tracks
            if (!markerTypes.Any())
            {
                // No tracks support this object
                if (!validTrackTypes.Any())
                    return DragAndDropVisualMode.Rejected;

                // no tracks for this object
                if (targetTrack != null && !validTrackTypes.Contains(targetTrack.GetType()))
                    return DragAndDropVisualMode.Rejected;
            }

            // there is no target track, dropping to empty space, or onto a group
            if (perform)
            {
                // choose track and then clip
                if (targetTrack == null)
                {
                    var createdTrack = HandleTrackAndItemCreation(objectsBeingDropped, candidateTime, typeResolver, timeline, parent, validTrackTypes, insertBefore);
                    if (!createdTrack)
                    {
                        timeline.CreateMarkerTrack();
                        HandleItemCreation(objectsBeingDropped, timeline.markerTrack, candidateTime, typeResolver, true); // menu is always popped if ambiguous choice
                    }
                }
                // just choose clip/marker
                else
                {
                    HandleItemCreation(objectsBeingDropped, targetTrack, candidateTime, typeResolver, true); // menu is always popped if ambiguous choice
                }
            }

            return DragAndDropVisualMode.Copy;
        }