Exemplo n.º 1
0
    public static void ReflectChanges(Cutscene cutscene, CutsceneWrapper wrapper)
    {
        if (cutscene == null || wrapper == null)
        {
            return;
        }

        cutscene.Duration = wrapper.Duration;
        {
            // foreach(var tgw in wrapper.TrackGroups)
            var __enumerator4 = (wrapper.TrackGroups).GetEnumerator();
            while (__enumerator4.MoveNext())
            {
                var tgw = (TrackGroupWrapper)__enumerator4.Current;
                {
                    TrackGroup tg = tgw.Behaviour as TrackGroup;
                    tg.Ordinal = tgw.Ordinal;
                    {
                        // foreach(var trackWrapper in tgw.Tracks)
                        var __enumerator23 = (tgw.Tracks).GetEnumerator();
                        while (__enumerator23.MoveNext())
                        {
                            var trackWrapper = (TimelineTrackWrapper)__enumerator23.Current;
                            {
                                TimelineTrack track = trackWrapper.Behaviour as TimelineTrack;
                                track.Ordinal = trackWrapper.Ordinal;
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    protected override void showBodyContextMenu(Event evt)
    {
        TimelineTrack itemTrack = TargetTrack.Behaviour as TimelineTrack;

        if (itemTrack == null)
        {
            return;
        }

        List <Type> trackTypes = itemTrack.GetAllowedCutsceneItems();
        GenericMenu createMenu = new GenericMenu();

        for (int i = 0; i < trackTypes.Count; i++)
        {
            ContextData data = getContextData(trackTypes[i]);
            data.Firetime = (evt.mousePosition.x - state.Translation.x) / state.Scale.x;
            createMenu.AddItem(new GUIContent(string.Format("Add New/{0}/{1}", data.Category, data.Label)), false, addCutsceneItem, data);
        }

        Behaviour    b            = DirectorCopyPaste.Peek();
        PasteContext pasteContext = new PasteContext(evt.mousePosition, itemTrack);

        if (b != null && DirectorHelper.IsTrackItemValidForTrack(b, itemTrack))
        {
            createMenu.AddItem(new GUIContent("Paste"), false, pasteItem, pasteContext);
        }
        else
        {
            createMenu.AddDisabledItem(new GUIContent("Paste"));
        }


        createMenu.ShowAsContext();
    }
Exemplo n.º 3
0
 public ContextData(Type type, Type pairedType, TimelineTrack track, string category, string label)
 {
     Type       = type;
     PairedType = pairedType;
     Track      = track;
     Category   = category;
     Label      = label;
 }
Exemplo n.º 4
0
        protected void Start()
        {
            if (mesh == null)
            {
                Debug.LogError("[SampleController] No 'mesh' provided"); return;
            }
            if (material == null)
            {
                Debug.LogError("[SampleController] No 'material' provided"); return;
            }

            //Allocate arrays
            cubeData      = new CubeData[cubeCount];
            bucketedCubes = new BucketSet <CubeData>(bucketCount: avoidanceBucketCount, maxBucketSize: avoidanceMaxBucketSize);
            renderSet     = new RenderSet(mesh, material, maxBatches: Mathf.CeilToInt(cubeCount / 1023f));

            //Create misc stuff
            int numExecutors = useMultiThreading ? (System.Environment.ProcessorCount - 1) : 0;

            Debug.Log(string.Format("[SampleController] Staring 'TaskManager' with '{0}' executors", numExecutors));
            taskManager     = new TaskManager(numExecutors);
            avoidanceHasher = new PositionHasher();
            random          = new ShiftRandomProvider();

            //Create tasks
            startTask          = new StartFrameTask();
            bucketCubeTask     = new BucketCubeTask(bucketedCubes, avoidanceHasher);
            moveCubeTask       = new MoveCubeTask(avoidanceHasher, bucketedCubes);
            respawnCubeTask    = new RespawnCubeTask(random);
            addToRenderSetTask = new AddToRenderSetTask(renderSet);

            //Setup profiler timeline
            if (profiler != null)
            {
                completeProfilerTrack       = profiler.CreateTrack <TimelineTrack>("Blocking main-thread to complete tasks");
                renderProfilerTrack         = profiler.CreateTrack <TimelineTrack>("Render instanced");
                bucketCubesProfilerTrack    = profiler.CreateTrack <TaskTimelineTrack>("Bucket cubes");
                moveCubesProfilerTrack      = profiler.CreateTrack <TaskTimelineTrack>("Move cubes");
                respawnCubesProfilerTrack   = profiler.CreateTrack <TaskTimelineTrack>("Respawn cubes");
                addToRenderSetProfilerTrack = profiler.CreateTrack <TaskTimelineTrack>("Creating render batches");
                profiler.StartTimers();
            }

            //Setup initial data
            Rect spawnArea = MathUtils.FromCenterAndSize(Vector2.zero, spawnAreaSize);

            for (int i = 0; i < cubeCount; i++)
            {
                cubeData[i] = new CubeData
                {
                    ID                = i,
                    Position          = random.Inside(spawnArea),
                    TimeNotHitTarget1 = 999f,
                    TimeNotHitTarget2 = 999f
                }
            }
            ;
        }
Exemplo n.º 5
0
 public ContextData(int controlId, Type type, Type pairedType, TimelineTrack track, string category, string label, float firetime)
 {
     ControlID  = controlId;
     Type       = type;
     PairedType = pairedType;
     Track      = track;
     Category   = category;
     Label      = label;
     Firetime   = firetime;
 }
Exemplo n.º 6
0
    public static bool IsTrackItemValidForTrack(Behaviour behaviour, TimelineTrack track)
    {
        bool retVal = false;

        if (track.GetType() == (typeof(ShotTrack)))
        {
            if (behaviour.GetType() == (typeof(CinemaShot)))
            {
                retVal = true;
            }
        }
        else if (track.GetType() == (typeof(AudioTrack)))
        {
            if (behaviour.GetType() == (typeof(CinemaAudio)))
            {
                retVal = true;
            }
        }
        else if (track.GetType() == (typeof(GlobalItemTrack)) || track.GetType().IsSubclassOf(typeof(GlobalItemTrack)))
        {
            if (behaviour.GetType() == typeof(CinemaShot) || (behaviour.GetType().IsSubclassOf(typeof(CinemaAudio))))
            {
                retVal = false;
            }
            else if (behaviour.GetType().IsSubclassOf(typeof(CinemaGlobalAction)) || behaviour.GetType().IsSubclassOf(typeof(CinemaGlobalEvent)))
            {
                retVal = true;
            }
        }
        else if (track.GetType() == (typeof(ActorItemTrack)) || track.GetType().IsSubclassOf(typeof(ActorItemTrack)))
        {
            if (behaviour.GetType().IsSubclassOf(typeof(CinemaActorAction)) || behaviour.GetType().IsSubclassOf(typeof(CinemaActorEvent)))
            {
                retVal = true;
            }
        }
        else if (track.GetType() == (typeof(CurveTrack)) || track.GetType().IsSubclassOf(typeof(CurveTrack)))
        {
            if (behaviour.GetType() == (typeof(CinemaActorClipCurve)))
            {
                retVal = true;
            }
        }
        else if (track.GetType() == (typeof(MultiCurveTrack)) || track.GetType().IsSubclassOf(typeof(MultiCurveTrack)))
        {
            if (behaviour.GetType() == (typeof(CinemaMultiActorCurveClip)))
            {
                retVal = true;
            }
        }
        return(retVal);
    }
Exemplo n.º 7
0
    protected override void updateHeaderControl5(UnityEngine.Rect position)
    {
        track = this.Behaviour.gameObject.GetComponent <TimelineTrack>();

        if (!track.lockedStatus)
        {
            if (GUI.Button(position, string.Empty, TrackGroupControl.styles.UnlockIconSM))
            {
                track.lockedStatus = true;
            }
        }
        else
        {
            if (GUI.Button(position, string.Empty, TrackGroupControl.styles.LockIconSM))
            {
                track.lockedStatus = false;
            }
        }
    }
Exemplo n.º 8
0
    protected override void updateHeaderControl6(UnityEngine.Rect position)
    {
        track = this.Behaviour.gameObject.GetComponent <TimelineTrack>();

        if (!track.mute)
        {
            if (GUI.Button(position, string.Empty, TrackGroupControl.styles.UnMuteSM))
            {
                track.mute = true;
            }
        }
        else
        {
            if (GUI.Button(position, string.Empty, TrackGroupControl.styles.MuteSM))
            {
                track.mute = false;
            }
        }
    }
Exemplo n.º 9
0
    public static void ReflectChanges(TimelineManager cutscene, CutsceneWrapper wrapper)
    {
        if (cutscene == null || wrapper == null)
        {
            return;
        }

        cutscene.Duration = wrapper.Duration;
        foreach (TrackGroupWrapper tgw in wrapper.TrackGroups)
        {
            TrackGroup tg = tgw.Behaviour as TrackGroup;
            tg.Ordinal = tgw.Ordinal;

            foreach (TimelineTrackWrapper trackWrapper in tgw.Tracks)
            {
                TimelineTrack track = trackWrapper.Behaviour as TimelineTrack;
                track.Ordinal = trackWrapper.Ordinal;
            }
        }
    }
Exemplo n.º 10
0
    protected override void showBodyContextMenu(Event evt)
    {
        TimelineTrack itemTrack = TargetTrack.Behaviour as TimelineTrack;

        if (itemTrack == null)
        {
            return;
        }

        Behaviour b = DirectorCopyPaste.Peek();

        PasteContext pasteContext = new PasteContext(evt.mousePosition, itemTrack);
        GenericMenu  createMenu   = new GenericMenu();

        if (b != null && DirectorHelper.IsTrackItemValidForTrack(b, itemTrack))
        {
            createMenu.AddItem(new GUIContent("Paste"), false, pasteItem, pasteContext);
        }
        else
        {
            createMenu.AddDisabledItem(new GUIContent("Paste"));
        }
        createMenu.ShowAsContext();
    }
Exemplo n.º 11
0
 public PasteContext(Vector2 mousePosition, TimelineTrack track)
 {
     this.mousePosition = mousePosition;
     this.track         = track;
 }
Exemplo n.º 12
0
    /// <summary>
    /// Header Control 4 is typically the "Add" control.
    /// </summary>
    /// <param name="position">The position that this control is drawn at.</param>
    protected override void updateHeaderControl4(UnityEngine.Rect position)
    {
        TimelineTrack track = TargetTrack.Behaviour as TimelineTrack;

        if (track == null)
        {
            return;
        }

        Color temp = GUI.color;

        GUI.color = (track.GetTimelineItems().Length > 0) ? Color.green : Color.red;

        controlID = GUIUtility.GetControlID(track.GetInstanceID(), FocusType.Passive);

        if (GUI.Button(position, string.Empty, TrackGroupControl.styles.AddIcon))
        {
            // Get the possible items that this track can contain.
            List <Type> trackTypes = track.GetAllowedCutsceneItems();

            if (trackTypes.Count == 1)
            {
                // Only one option, so just create it.
                ContextData data = getContextData(trackTypes[0]);
                if (data.PairedType == null)
                {
                    addCutsceneItem(data);
                }
                else
                {
                    showObjectPicker(data);
                }
            }
            else if (trackTypes.Count > 1)
            {
                // Present context menu for selection.
                GenericMenu createMenu = new GenericMenu();
                for (int i = 0; i < trackTypes.Count; i++)
                {
                    ContextData data = getContextData(trackTypes[i]);

                    createMenu.AddItem(new GUIContent(string.Format("{0}/{1}", data.Category, data.Label)), false, addCutsceneItem, data);
                }
                createMenu.ShowAsContext();
            }
        }

        // Handle the case where the object picker has a value selected.
        if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "ObjectSelectorClosed")
        {
            if (EditorGUIUtility.GetObjectPickerControlID() == controlID)
            {
                UnityEngine.Object pickedObject = EditorGUIUtility.GetObjectPickerObject();

                if (pickedObject != null)
                {
                    addCutsceneItem(savedData, pickedObject);
                }

                Event.current.Use();
            }
        }

        GUI.color = temp;
    }
Exemplo n.º 13
0
    /// <summary>
    /// Create a new Timeline Item (Cutscene Item)
    /// </summary>
    /// <param name="timelineTrack">The track that this item will be attached to.</param>
    /// <param name="type">the type of the new item.</param>
    /// <param name="label">The name of the new item.</param>
    /// <returns>The newly created Cutscene Item. Reminder: Register an Undo.</returns>
    internal static TimelineItem CreateCutsceneItem(TimelineTrack timelineTrack, Type type, string label, float firetime)
    {
        GameObject   itemGO = new GameObject(label, type);
        TimelineItem ti     = itemGO.GetComponent <TimelineItem>();

        ti.SetDefaults();

        // Find an appropriate firetime/duration for it.
        if (type.IsSubclassOf(typeof(TimelineActionFixed)))
        {
            // The new timeline item is an action of fixed length.
            TimelineActionFixed newAction = ti as TimelineActionFixed;

            SortedDictionary <float, TimelineActionFixed> sortedClips = new SortedDictionary <float, TimelineActionFixed>();
            foreach (TimelineItem current in timelineTrack.TimelineItems)
            {
                TimelineActionFixed action = current as TimelineActionFixed;
                if (action == null)
                {
                    continue;
                }
                sortedClips.Add(action.Firetime, action);
            }

            float latestTime = firetime;
            float length     = newAction.ItemLength;
            foreach (TimelineActionFixed a in sortedClips.Values)
            {
                if (!(latestTime < a.Firetime && latestTime + length <= a.Firetime))
                {
                    latestTime = a.Firetime + a.Duration;
                }
            }

            newAction.Firetime = latestTime;
        }
        else if (type.IsSubclassOf(typeof(TimelineAction)))
        {
            // The new timeline item is an action with arbitrary length.
            TimelineAction newAction = ti as TimelineAction;

            SortedDictionary <float, TimelineAction> sortedActions = new SortedDictionary <float, TimelineAction>();
            foreach (TimelineItem current in timelineTrack.TimelineItems)
            {
                TimelineAction action = current as TimelineAction;
                if (action == null)
                {
                    continue;
                }
                sortedActions.Add(action.Firetime, action);
            }

            float latestTime = firetime;
            float length     = newAction.Duration;
            foreach (TimelineAction a in sortedActions.Values)
            {
                if (latestTime >= a.Firetime)
                {
                    latestTime = Mathf.Max(latestTime, a.Firetime + a.Duration);
                }
                else
                {
                    length = a.Firetime - latestTime;
                    break;
                }
            }

            newAction.Firetime = latestTime;
            newAction.Duration = length;
        }
        else
        {
            ti.Firetime = firetime;
        }

        itemGO.transform.parent = timelineTrack.transform;
        return(ti);
    }
Exemplo n.º 14
0
    public static bool IsTrackItemValidForTrack(Behaviour behaviour, TimelineTrack track)
    {
        bool retVal = true;

        return(retVal);
    }
Exemplo n.º 15
0
 private void RegisterTrackAndInitialize <TValue>(AudioMetadata.ValueHelper <TValue> valueHelper, TimelineTrack <TValue> track)
 {
     track.Initialize(Editor, valueHelper);
     _tracks.Add(track);
 }