public void GetTotalDuration() { var animation = new TimelineClip { Timeline = new SingleFromToByAnimation { Duration = TimeSpan.FromSeconds(1.0) }, Delay = TimeSpan.FromSeconds(10), Duration = null, Speed = 1.0f, }; // Default duration is 1 second. Assert.AreEqual(TimeSpan.FromSeconds(11.0), animation.GetTotalDuration()); animation.Duration = TimeSpan.FromSeconds(5.0); Assert.AreEqual(TimeSpan.FromSeconds(15.0), animation.GetTotalDuration()); animation.Speed = 2.0f; Assert.AreEqual(TimeSpan.FromSeconds(12.5), animation.GetTotalDuration()); animation.Delay = TimeSpan.FromSeconds(-1.0); Assert.AreEqual(TimeSpan.FromSeconds(1.5), animation.GetTotalDuration()); animation.Speed = 0.0f; Assert.AreEqual(TimeSpan.MaxValue, animation.GetTotalDuration()); }
public void CheckDefaultValues() { var timelineClip = new TimelineClip(); Assert.IsNull(timelineClip.Timeline); Assert.False(timelineClip.ClipStart.HasValue); Assert.False(timelineClip.ClipEnd.HasValue); Assert.IsFalse(timelineClip.IsClipReversed); Assert.AreEqual(TimeSpan.FromSeconds(0.0), timelineClip.ClipOffset); Assert.AreEqual(LoopBehavior.Constant, timelineClip.LoopBehavior); }
public void GetTotalDuration2() { var timelineClip = new TimelineClip(); Assert.AreEqual(TimeSpan.FromSeconds(0.0), timelineClip.GetTotalDuration()); timelineClip.Timeline = new TimelineClip { Timeline = new SingleFromToByAnimation(), Delay = TimeSpan.FromSeconds(10), Duration = TimeSpan.FromSeconds(4.0), Speed = 2.0f, }; Assert.AreEqual(TimeSpan.FromSeconds(12.0), timelineClip.GetTotalDuration()); }
public void CreateInstanceTest() { var timelineClip = new TimelineClip { Timeline = new SingleFromToByAnimation(), ClipStart = TimeSpan.FromSeconds(0.75), ClipEnd = TimeSpan.FromSeconds(0.25), }; var animationInstance = timelineClip.CreateInstance(); Assert.IsNotNull(animationInstance); Assert.AreEqual(1, animationInstance.Children.Count); Assert.AreEqual(timelineClip.Timeline, animationInstance.Children[0].Animation); Assert.AreEqual(0, animationInstance.Children[0].Children.Count); }
/// <summary> /// Called when a clip is created. /// </summary> /// <param name="clip">The newly created clip.</param> /// <param name="track">The track that the clip is assigned to.</param> /// <param name="clonedFrom">The source that the clip was copied from. This can be set to null if the clip is not a copy.</param> /// <remarks> /// The callback occurs before the clip is assigned to the track. /// </remarks> public virtual void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { }
// Checks if the underlying asset duration is usable. This means the clip // can loop or hold public static bool HasUsableAssetDuration(TimelineClip clip) { double length = clip.clipAssetDuration; return((length < TimelineClip.kMaxTimeValue) && !double.IsInfinity(length) && !double.IsNaN(length)); }
public SequenceState(WindowState windowState, TimelineAsset asset, PlayableDirector director, TimelineClip hostClip, SequenceState parentSequence) { m_WindowState = windowState; m_ParentSequence = parentSequence; this.asset = asset; this.director = director; this.hostClip = hostClip; isAssetOnly = asset != null && director == null; start = hostClip == null ? 0.0 : hostClip.start; timeScale = hostClip == null ? 1.0 : hostClip.timeScale * parentSequence.timeScale; if (asset != null) { asset.AssetModifiedOnDisk += AssetOnAssetModifiedOnDisk; } }
public static void CompleteLastLoop(TimelineClip clip) { FixLoops(clip, true); }
public static bool Delete(TimelineAsset timeline, TimelineClip clip) { return(timeline.DeleteClip(clip)); }
private static bool SelectBlendingIntersecting(TimelineClip clip, double time) { return(clip.start <= time && time <= clip.end && (time <= clip.start + clip.blendInDuration || time >= clip.end - clip.blendOutDuration)); }
protected override void OnCreateClip(TimelineClip clip) { base.OnCreateClip(clip); }
protected override Playable CreatePlayable(PlayableGraph graph, GameObject gameObject, TimelineClip clip) { PlayableGraph externalGraph = TimelineManager.Instance.GetGraph(); if (!animOutput.IsOutputValid()) { PlayableDirector playableDirector = graph.GetResolver() as PlayableDirector; Animator bindAnimator = playableDirector.GetGenericBinding(this) as Animator; animOutput = AnimationPlayableOutput.Create(externalGraph, "AnimOutPut", bindAnimator); animMixer = AnimationMixerPlayable.Create(externalGraph); animOutput.SetSourcePlayable(animMixer); } int clipIndex = 0; IEnumerable <TimelineClip> clips = GetClips(); foreach (var animClip in clips) { if (animClip == clip) { var asset = clip.asset as AnimationBlendClip; asset.SetOutPutPlayable(clipIndex, animMixer); break; } clipIndex++; } TimelineClip frontClip = null; foreach (var animClip in clips) { if (frontClip != null) { if (IsCrossed(frontClip, animClip)) { (frontClip.asset as AnimationBlendClip)?.SetClipEndCrossed(true); } } frontClip = animClip; } return(base.CreatePlayable(graph, gameObject, clip)); }
//---------------------------------------------------------------------------------------------------------------------- internal static double CalculateTimePerFrame(TimelineClip clip) { return(CalculateTimePerFrame(clip.GetParentTrack())); }
public ClipItem(TimelineClip clip) { m_Clip = clip; }
/// <summary> /// Gets the sub-timelines for a specific clip. Implement this method if your clip supports playing nested timelines. /// </summary> /// <param name="clip">The clip with the ControlPlayableAsset.</param> /// <param name="director">The playable director driving the Timeline Clip. This may not be the same as TimelineEditor.inspectedDirector.</param> /// <param name="subTimelines">Specify the sub-timelines to control.</param> public virtual void GetSubTimelines(TimelineClip clip, PlayableDirector director, List <PlayableDirector> subTimelines) { }
/// <summary> /// Called when a clip is changed by the Editor. /// </summary> /// <param name="clip">The clip that changed.</param> public virtual void OnClipChanged(TimelineClip clip) { }
public void ShouldThrowWhenSpeedIsNaN() { var animation = new TimelineClip(); animation.Speed = float.NaN; }
public void TargetObjectTest() { var animation = new TimelineClip(); Assert.IsNull(animation.TargetObject); animation.TargetObject = ""; Assert.IsEmpty(animation.TargetObject); animation.TargetObject = "Object XY"; Assert.AreEqual("Object XY", animation.TargetObject); }
static HashSet <double> GetKeyTimes(IList <PropertyModification> modifications, WindowState state) { var keyTimes = new HashSet <double>(); AnimationClip animationClip; double keyTime; bool inRange; var component = modifications[0].target as Component; var target = modifications[0].target; if (component != null) { var track = GetTrackForGameObject(component.gameObject, state); var go = TimelineUtility.GetSceneGameObject(TimelineEditor.inspectedDirector, track); if (go != null) { target = go.transform; } } GetClipAndRelativeTime(target, state, out animationClip, out keyTime, out inRange); if (animationClip == null) { return(keyTimes); } var playableAsset = target as IPlayableAsset; var info = AnimationClipCurveCache.Instance.GetCurveInfo(animationClip); TimelineClip clip = null; if (component != null) { GetTrackForGameObject(component.gameObject, state).FindRecordingClipAtTime(state.editSequence.time, out clip); } else if (playableAsset != null) { clip = FindClipWithAsset(state.editSequence.asset, playableAsset); } foreach (var mod in modifications) { EditorCurveBinding temp; if (HasBinding(target, mod, animationClip, out temp)) { IEnumerable <double> keys = new HashSet <double>(); if (temp.isPPtrCurve) { var curve = info.GetObjectCurveForBinding(temp); if (curve != null) { keys = curve.Select(x => (double)x.time); } } else { var curve = info.GetCurveForBinding(temp); if (curve != null) { keys = curve.keys.Select(x => (double)x.time); } } // Transform the times in to 'global' space using the clip if (clip != null) { foreach (var k in keys) { var time = clip.FromLocalTimeUnbound(k); const double eps = 1e-5; if (time >= clip.start - eps && time <= clip.end + eps) { keyTimes.Add(time); } } } // infinite clip mode, global == local space else { keyTimes.UnionWith(keys); } } } return(keyTimes); }
public override void OnClipChanged(TimelineClip clip) { }
public override void DrawBackground(TimelineClip clip, ClipBackgroundRegion region) { if (!(clip.asset is MidiAnimationAsset midiAnimationAsset)) { return; } var midiTrack = midiAnimationAsset.MidiTrack; if (midiTrack == null) { return; } Texture texture; if (_textures.ContainsKey(clip) && _textures[clip] is null) { texture = _textures[clip]; } else { const int topMargin = 2; const int bottomMargin = 1; texture = midiTrack.WriteNoteBarTexture2D((int)midiTrack.DeltaTime / 2, topMargin, bottomMargin); if (_textures.ContainsKey(clip)) { _textures[clip] = texture; } else { _textures.Add(clip, texture); } } Material material; if (_materials.ContainsKey(clip) && _materials[clip] is null) { material = _materials[clip]; } else { var shader = Shader.Find("jp.goma_recorder.Midity.Playable/ClipBackground"); material = new Material(shader) { mainTexture = texture }; if (_materials.ContainsKey(clip)) { _materials[clip] = material; } else { _materials.Add(clip, material); } } var loopCount = (region.endTime - region.startTime) / midiTrack.TotalSeconds; material.SetFloat("_RepeatX", (float)loopCount); material.SetFloat("_OffsetX", (float)(region.startTime / midiTrack.TotalSeconds)); var rect = region.position; var quantizedRect = new Rect(Mathf.Ceil(rect.x), Mathf.Ceil(rect.y), Mathf.Ceil(rect.width), Mathf.Ceil(rect.height)); Graphics.DrawTexture(quantizedRect, texture, material); }
public void SetCurrentSequence(TimelineAsset timelineAsset, PlayableDirector director, TimelineClip hostClip) { if (OnBeforeSequenceChange != null) { OnBeforeSequenceChange.Invoke(); } OnCurrentDirectorWillChange(); if (hostClip == null || timelineAsset == null) { m_PropertyCollector.Clear(); m_SequenceHierarchy.Clear(); } if (timelineAsset != null) { m_SequenceHierarchy.Add(timelineAsset, director, hostClip); } if (OnAfterSequenceChange != null) { OnAfterSequenceChange.Invoke(); } }
public override void AddDefaultCurves(TimelineClip clip) { clip.curves.SetCurve("", typeof(SkinnedMeshBlendshapeClip), "_weight", new AnimationCurve()); }
public static void SetStart(TimelineClip clip, double time, bool affectTimeScale) { var supportsClipIn = clip.SupportsClipIn(); var supportsPadding = TimelineUtility.IsRecordableAnimationClip(clip); bool calculateTimeScale = (affectTimeScale && clip.SupportsSpeedMultiplier()); // treat empty recordable clips as not supporting clip in (there are no keys to modify) if (supportsPadding && (clip.animationClip == null || clip.animationClip.empty)) { supportsClipIn = false; } if (supportsClipIn && !supportsPadding && !calculateTimeScale) { var minStart = clip.FromLocalTimeUnbound(0.0); if (time < minStart) { time = minStart; } } var maxStart = clip.end - TimelineClip.kMinDuration; if (time > maxStart) { time = maxStart; } var timeOffset = time - clip.start; var duration = clip.duration - timeOffset; if (calculateTimeScale) { var f = clip.duration / duration; clip.timeScale *= f; } if (supportsClipIn && !calculateTimeScale) { if (supportsPadding) { double clipInGlobal = clip.clipIn / clip.timeScale; double keyShift = -timeOffset; if (timeOffset < 0) // left drag, eliminate clipIn before shifting { double clipInDelta = Math.Max(-clipInGlobal, timeOffset); keyShift = -Math.Min(0, timeOffset - clipInDelta); clip.clipIn += clipInDelta * clip.timeScale; } else if (timeOffset > 0) // right drag, elimate padding in animation clip before adding clip in { var clipInfo = AnimationClipCurveCache.Instance.GetCurveInfo(clip.animationClip); double keyDelta = clip.FromLocalTimeUnbound(clipInfo.keyTimes.Min()) - clip.start; keyShift = -Math.Max(0, Math.Min(timeOffset, keyDelta)); clip.clipIn += Math.Max(timeOffset + keyShift, 0) * clip.timeScale; } if (keyShift != 0) { AnimationTrackRecorder.ShiftAnimationClip(clip.animationClip, (float)(keyShift * clip.timeScale)); } } else { clip.clipIn += timeOffset * clip.timeScale; } } clip.start = time; clip.duration = duration; clip.ConformEaseValues(); }
public virtual void UpdateFrame(Playable playable, TimelineClip clip, double lastTime, double time) { }
public static void TrimLastLoop(TimelineClip clip) { FixLoops(clip, false); }
internal static void AddClipOffset(AnimationTrack track, UndoPropertyModification[] mods, TimelineClip clip, Animator animator) { if (clip == null || clip.asset == null) { return; } var clipAsset = clip.asset as AnimationPlayableAsset; var copyClipOffset = track.inClipMode && clipAsset != null && !ClipHasPositionOrRotation(clipAsset.clip) && mods.Any(x => IsPositionOrRotation(x) && IsRootModification(x)) && animator != null; if (copyClipOffset) { var rigidTransform = ComputeInitialClipOffsets(track, mods, animator); clipAsset.position = rigidTransform.position; clipAsset.rotation = rigidTransform.rotation; } }
//---------------------------------------------------------------------------------------------------------------------- /// <summary> /// StreamingImageSequencePlayableAsset GUI Drawing /// </summary> public override void OnInspectorGUI() { if (null == m_asset) return; Undo.RecordObject(m_asset, "StreamingImageSequencePlayableAssetInspector::OnInspectorGUI"); using (new EditorGUILayout.VerticalScope (GUI.skin.box)) { m_resolutionFoldout = EditorGUILayout.Foldout(m_resolutionFoldout, "Resolution"); if (m_resolutionFoldout) { ImageDimensionInt res = m_asset.GetResolution(); EditorGUILayout.LabelField("Width", $"{res.Width } px"); EditorGUILayout.LabelField("Height", $"{res.Height } px"); } GUILayout.Space(4f); } GUILayout.Space(4f); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { GUILayout.Label("Folder", "BoldLabel"); GUILayout.Space(4f); DrawFolderGUI(); } GUILayout.Space(4f); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { int numImages = m_asset.GetNumImages(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Images: " + numImages, "BoldLabel"); if (GUILayout.Button("Reload", GUILayout.Width(50))) { m_asset.Reload(); } EditorGUILayout.EndHorizontal(); using (new EditorGUI.DisabledScope(0 == numImages)) { if (0 == numImages) EditorGUILayout.IntField("FPS", 0); else { TimelineClip clip = m_asset.GetBoundTimelineClipSISData().GetOwner(); float prevFps = numImages / (float)(clip.duration); float fps = EditorGUILayout.FloatField("FPS", prevFps); if (!Mathf.Approximately(fps, prevFps) && !Mathf.Approximately(fps, 0.0f)) { double prevDuration = clip.duration; clip.duration = numImages / fps; clip.timeScale = (prevDuration * clip.timeScale) / clip.duration; } } } GUILayout.Space(4f); m_imageListFoldout = EditorGUILayout.Foldout(m_imageListFoldout, "Images"); if (m_imageListFoldout) { DoImageGUI(); } } if (null == TimelineEditor.selectedClip) return; GUILayout.Space(15); //Frame markers if (TimelineEditor.selectedClip.asset == m_asset) { InspectorUtility.ShowFrameMarkersGUI(m_asset); } GUILayout.Space(15); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUILayout.LabelField("Background Colors"); ++EditorGUI.indentLevel; Color timelineBgColor = m_asset.GetTimelineBGColor(); m_asset.SetTimelineBGColor(EditorGUILayout.ColorField("In Timeline Window", timelineBgColor)); --EditorGUI.indentLevel; GUILayout.Space(15); } if (GUILayout.Button("Reset Curve (Not Undoable)")) { //AnimationClip.SetCurve() doesn't seem to be undoable StreamingImageSequencePlayableAsset.ResetTimelineClipCurve(TimelineEditor.selectedClip); } }
public void ShouldThrowWhenClipIsInvalid() { var timelineClip = new TimelineClip { Timeline = new SingleFromToByAnimation(), ClipStart = TimeSpan.FromSeconds(0.75), ClipEnd = TimeSpan.FromSeconds(0.25), }; Assert.That(() => timelineClip.GetTotalDuration(), Throws.TypeOf<InvalidAnimationException>()); Assert.That(() => timelineClip.GetState(TimeSpan.Zero), Throws.TypeOf<InvalidAnimationException>()); Assert.That(() => timelineClip.GetAnimationTime(TimeSpan.Zero), Throws.TypeOf<InvalidAnimationException>()); }
internal static TimelineAnimationUtilities.RigidTransform GetLocalToTrack(AnimationTrack track, TimelineClip clip) { if (track == null) { return(TimelineAnimationUtilities.RigidTransform.Compose(Vector3.zero, Quaternion.identity)); } var trackPos = track.position; var trackRot = track.rotation; if (track.trackOffset == TrackOffset.ApplySceneOffsets) { trackPos = track.sceneOffsetPosition; trackRot = Quaternion.Euler(track.sceneOffsetRotation); } var clipWrapper = clip == null ? null : clip.asset as AnimationPlayableAsset; var clipTransform = TimelineAnimationUtilities.RigidTransform.Compose(Vector3.zero, Quaternion.identity); if (clipWrapper != null) { clipTransform = TimelineAnimationUtilities.RigidTransform.Compose(clipWrapper.position, clipWrapper.rotation); } else { clipTransform = TimelineAnimationUtilities.RigidTransform.Compose(track.infiniteClipOffsetPosition, track.infiniteClipOffsetRotation); } var trackTransform = TimelineAnimationUtilities.RigidTransform.Compose(trackPos, trackRot); return(TimelineAnimationUtilities.RigidTransform.Mul(trackTransform, clipTransform)); }
/// <summary> /// Override this method to draw a background for a clip . /// </summary> /// <param name="clip">The clip being drawn.</param> /// <param name="region">The on-screen area where the clip is drawn.</param> public virtual void DrawBackground(TimelineClip clip, ClipBackgroundRegion region) { }
public void ShouldThrowWhenDurationIsNegative() { var animation = new TimelineClip(); animation.Duration = TimeSpan.FromSeconds(-1.0); }
internal static void ReapplyOffsets(UndoPropertyModification modification, AnimationTrack track, TimelineClip clip, UndoPropertyModification[] mods) { if (IsPositionOrRotation(modification)) { var modifiedGO = GetGameObjectFromModification(modification); var target = TimelineAnimationUtilities.RigidTransform.Compose(modifiedGO.transform.localPosition, modifiedGO.transform.localRotation); var localToTrack = GetLocalToTrack(track, clip); var trackSpace = TimelineAnimationUtilities.RigidTransform.Mul(localToTrack, target); // Update the undo call values var prevPos = modifiedGO.transform.localPosition; var prevRot = modifiedGO.transform.localRotation; GetPreviousPositionAndRotation(mods, ref prevPos, ref prevRot); var previousRigidTransform = TimelineAnimationUtilities.RigidTransform.Mul(localToTrack, TimelineAnimationUtilities.RigidTransform.Compose(prevPos, prevRot)); SetPreviousPositionAndRotation(mods, previousRigidTransform.position, previousRigidTransform.rotation); var currentPos = modifiedGO.transform.localPosition; var currentRot = modifiedGO.transform.localRotation; GetCurrentPositionAndRotation(mods, ref currentPos, ref currentRot); var currentRigidTransform = TimelineAnimationUtilities.RigidTransform.Mul(localToTrack, TimelineAnimationUtilities.RigidTransform.Compose(currentPos, currentRot)); SetCurrentPositionAndRotation(mods, currentRigidTransform.position, currentRigidTransform.rotation); modifiedGO.transform.localPosition = trackSpace.position; modifiedGO.transform.localRotation = trackSpace.rotation; } }
public void ShouldThrowWhenLoopBehaviorIsCycleOffset() { var timelineClip = new TimelineClip { LoopBehavior = LoopBehavior.CycleOffset }; }
internal static UndoPropertyModification[] HandleEulerModifications(AnimationTrack track, TimelineClip clip, AnimationClip animClip, float time, UndoPropertyModification[] mods) { if (mods.Any(x => x.currentValue.propertyPath.StartsWith(kLocalEulerHint) || x.currentValue.propertyPath.StartsWith(kLocalRotation))) { // if there is a rotational offsets, we need to strip the euler hints, since they are used by the animation recording system // over the quaternion. var localToTrack = GetLocalToTrack(track, clip); if (localToTrack.rotation != Quaternion.identity) { if (s_LastTrackWarning != track) { s_LastTrackWarning = track; Debug.LogWarning(kRotationWarning); } Transform transform = mods[0].currentValue.target as Transform; if (transform != null) { var trackToLocal = TimelineAnimationUtilities.RigidTransform.Inverse(localToTrack); // since the euler angles are going to be transformed, we do a best guess at a euler that gives the shortest path var quatMods = mods.Where(x => !x.currentValue.propertyPath.StartsWith(kLocalEulerHint)); var eulerMods = FindBestEulerHint(trackToLocal.rotation * transform.localRotation, animClip, time, transform); return(quatMods.Union(eulerMods).ToArray()); } return(mods.Where(x => !x.currentValue.propertyPath.StartsWith(kLocalEulerHint)).ToArray()); } } return(mods); }
public void ShouldThrowWhenSpeedIsNegative() { var animation = new TimelineClip(); animation.Speed = -1.0f; }
static void ParseScreenplay() { Clear(); // load file var selectedFilepath = EditorUtility.OpenFilePanel("Select Screenplay", "", "txt"); FileInfo fileInfo = new FileInfo(selectedFilepath); string timeText = System.DateTime.Now.ToString("hh.mm.ss"); // get time so we can mark where these changes were made // create playabledirector in scene currentPlayableGameObject = new GameObject(); currentPlayableGameObject.name = fileInfo.Name.Replace(".txt", string.Empty) + " " + timeText + " Timeline"; currentDataSlate = currentPlayableGameObject.AddComponent <screenwriterDataSlate> (); currentPlayable = currentPlayableGameObject.AddComponent <PlayableDirector> (); // create timeline asset TimelineAsset currentTimeline = ScriptableObject.CreateInstance("TimelineAsset") as TimelineAsset; AssetDatabase.CreateAsset(currentTimeline, "Assets/Timelines/" + fileInfo.Name.Replace(".txt", string.Empty) + " " + timeText + ".playable"); currentTimeline = (TimelineAsset)AssetDatabase.LoadAssetAtPath("Assets/Timelines/" + fileInfo.Name.Replace(".txt", string.Empty) + " " + timeText + ".playable", typeof(TimelineAsset)); currentPlayable.playableAsset = currentTimeline; masterTrack = currentTimeline.CreateTrack <GroupTrack> (null, "Master Group"); currentTimeline.CreateTrack <ControlTrack> (masterTrack, "Shots"); currentTimeline.CreateTrack <ControlTrack> (masterTrack, "Lighting"); // currentTimeline.CreateTrack<SignalTrack> (null, "Track"); // currentTimeline.CreateTrack<AnimationTrack> (null, "Track"); string filePath = fileInfo.FullName; line = null; StreamReader reader = new StreamReader(filePath); using (reader) { do { thirdLastLine = lastLine; lastLine = line; line = reader.ReadLine(); if (System.String.IsNullOrEmpty(line) == false) { // this is where we actually parse the screenplay lineCount++; // print ("Parsing line #" + lineCount); // capital letters checker char[] possibleCharacter = line.ToCharArray(); int capitalization = 0; for (int i = 0; i < possibleCharacter.Length; i++) { if (System.Char.IsUpper(possibleCharacter[i])) { capitalization++; } } // location, time of day if (line.Contains("EXT") || line.Contains("INT")) { char splitChar = '-'; string[] splitString = line.Split(splitChar); currentDataSlate.TryAddLocation(splitString[0]); currentLocation = splitString[0]; currentDataSlate.TryAddLightingScenario(splitString[1]); currentLightingScenario = splitString[1]; continue; } // character check - all capitals and no : if (capitalization > possibleCharacter.Length * 0.8f && line.Contains(":") == false) { currentDataSlate.TryAddCharacter(line); currentCharacter = line; continue; } // extra actor instructions check - has () if (line.Contains("(")) { currentMood = line; continue; } // transition data - contains : and is caps if (line.Contains(":") && capitalization > possibleCharacter.Length * 0.5f) { continue; } // at this point there arent many edge cases left - check if we have a actor guidelines or an actor name above us to see if this is dialogue if (lastLine != null) { if (lastLine.Contains("(") || currentDataSlate.characters.Contains(lastLine)) { //dialogue callback // check if we already have a character group bool alreadyCreatedCharacter = false; IEnumerable <TrackAsset> duplicateCharacterCheck = currentTimeline.GetRootTracks(); foreach (TrackAsset track in duplicateCharacterCheck) { print(track.name); if (track.name == currentCharacter) { alreadyCreatedCharacter = true; } } if (alreadyCreatedCharacter == false) { TrackAsset characterTrack = currentTimeline.CreateTrack <GroupTrack> (null, currentCharacter); TrackAsset possibleSignalTrack = currentTimeline.CreateTrack <SignalTrack> (characterTrack, currentCharacter + " Signals"); TrackAsset animationTrack = currentTimeline.CreateTrack <AnimationTrack> (characterTrack, currentCharacter + " Animation Overrides"); } IEnumerable <TrackAsset> allTracksForActors = currentTimeline.GetOutputTracks(); foreach (TrackAsset track in allTracksForActors) { if (track.name == currentCharacter + " Signals") { IMarker newMarker = track.CreateMarker <SignalEmitter> (currentTimelineScrub); } if (track.name == currentCharacter + " Animation Overrides") { TimelineClip newClip = track.CreateDefaultClip(); newClip.start = currentTimelineScrub; newClip.duration = Convert.ToDouble(line.Length) / 12.0; newClip.displayName = "Dialogue Animation"; } } } } // shot callback IEnumerable <TrackAsset> allTracksForActions = currentTimeline.GetOutputTracks(); foreach (TrackAsset track in allTracksForActions) { if (track.name == "Shots") { GameObject cameraInstance = PrefabUtility.InstantiatePrefab(currentDataSlate.cameraPrefab) as GameObject; cameraInstance.name = "Shot Camera"; cameraInstance.transform.parent = currentPlayableGameObject.transform; // TimelineClip newClip = track.CreateDefaultClip (); // TimelineClip tlClip = track.CreateClip <ControlPlayableAsset> (); ControlPlayableAsset clip = tlClip.asset as ControlPlayableAsset; clip.sourceGameObject.exposedName = UnityEditor.GUID.Generate().ToString(); currentPlayable.SetReferenceValue(clip.sourceGameObject.exposedName, cameraInstance); tlClip.clipIn = currentTimelineScrub; tlClip.duration = Convert.ToDouble(line.Length) / 12.0; tlClip.displayName = line; } if (track.name == "Lighting") { TimelineClip newClip = track.CreateDefaultClip(); newClip.displayName = currentLightingScenario; newClip.clipIn = currentTimelineScrub; newClip.duration = Convert.ToDouble(line.Length) / 12.0; } } currentTimelineScrub = currentTimeline.duration; } }while (line != null); reader.Close(); } }
private void DrawCacheStatus(float nextStartY, TimelineClip clip) { var asset = clip.asset as StreamingImageSequencePlayableAsset; float wholeWidth = m_fRightAreaWidth - 16.0f; double start = clip.start; double end = clip.end; double duration = m_currentDirector.duration; start = start / duration; end = end / duration; double startPoint = wholeWidth * start; double endPoint = wholeWidth * end; int length = asset.Pictures.Length; if (m_MovieProxyPlayableAssetToColorArray.ContainsKey(asset)) { } else { m_MovieProxyPlayableAssetToColorArray.Add(asset, new BGJobCacheParam(asset)); } /* * if (BGJobPictureLoader.m_sUpdated ) * new BGJobCacheChecker( m_MovieProxyPlayableAssetToColorArray[asset]); * * UInt32[] colorArray = m_MovieProxyPlayableAssetToColorArray[asset].m_collorArray; * if (colorArray == null) * { * return; * * } */ /* * var parm = m_MovieProxyPlayableAssetToColorArray[asset]; * * PluginUtil.SetOverwrapWindowData(asset.GetInstanceID(), colorArray, colorArray.Length); */ /* * // if (parm.m_NeedUpdate) * { * Texture2D result = parm.m_tex2D; * if ( result != null ) * { * result.SetPixels(colorArray); * result.filterMode = FilterMode.Point; * result.Apply(); * parm.m_style.normal.background = result; * // Graphics.DrawTexture(new Rect(-20, -20, 40, 40), result); * parm.m_NeedUpdate = false; * * } * } */ float fRectStartX = kHeaderWidth + kLineWidth + 8.0f + (float)startPoint; float fRectWidth = (float)(endPoint - startPoint); // Rect tRightBodyRect = new Rect(fRectStartX, nextStartY + kHeaderTrackHeight -3.0f, fRectWidth, 1.0f); }
public static TimelineWindowTimeControl CreateTimeController(TimelineWindow.TimelineState state, TimelineClip clip) { AnimationWindow window = EditorWindow.GetWindow <AnimationWindow>(); TimelineWindowTimeControl timelineWindowTimeControl = ScriptableObject.CreateInstance <TimelineWindowTimeControl>(); timelineWindowTimeControl.Init(state.GetWindow(), window.get_state(), clip); return(timelineWindowTimeControl); }
public void GetValueTest() { var timelineClip = new TimelineClip(); timelineClip.GetState(TimeSpan.Zero); // Should not crash. timelineClip.GetAnimationTime(TimeSpan.FromSeconds(0.0)); // Should not crash. timelineClip.Delay = TimeSpan.FromSeconds(100); timelineClip.Speed = 1.0f; timelineClip.ClipStart = TimeSpan.FromSeconds(10.5); timelineClip.ClipEnd = TimeSpan.FromSeconds(11.5); timelineClip.ClipOffset = TimeSpan.FromSeconds(-0.5); timelineClip.Duration = TimeSpan.FromSeconds(4.0); timelineClip.LoopBehavior = LoopBehavior.Oscillate; timelineClip.Timeline = new TimelineClip { Timeline = new SingleFromToByAnimation { Duration = TimeSpan.FromSeconds(4.0) }, Delay = TimeSpan.FromSeconds(10), Duration = null, Speed = 2.0f, }; // Delayed Assert.AreEqual(AnimationState.Delayed, timelineClip.GetState(TimeSpan.FromSeconds(99.0))); Assert.IsFalse(timelineClip.GetAnimationTime(TimeSpan.FromSeconds(99.0)).HasValue); // Playing Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(100.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(100.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(100.5))); Assert.AreEqual(TimeSpan.FromSeconds(10.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(100.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(101.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(101.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(101.5))); Assert.AreEqual(TimeSpan.FromSeconds(11.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(101.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(102.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(102.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(102.5))); Assert.AreEqual(TimeSpan.FromSeconds(10.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(102.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(103.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(103.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(103.5))); Assert.AreEqual(TimeSpan.FromSeconds(11.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(103.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(104.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(104.0))); // Filling Assert.AreEqual(AnimationState.Filling, timelineClip.GetState(TimeSpan.FromSeconds(104.5))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(104.5))); timelineClip.FillBehavior = FillBehavior.Stop; // Stopped Assert.AreEqual(AnimationState.Stopped, timelineClip.GetState(TimeSpan.FromSeconds(104.5))); Assert.IsFalse(timelineClip.GetAnimationTime(TimeSpan.FromSeconds(104.5)).HasValue); }
public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) { }