public override Playable CreatePlayable(PlayableGraph graph, GameObject go) { List <Playable> list = new List <Playable>(); GameObject gameObject = this.sourceGameObject.Resolve(graph.GetResolver()); if (this.prefabGameObject != null) { Transform parentTransform = (!(gameObject != null)) ? null : gameObject.get_transform(); ScriptPlayable <PrefabControlPlayable> scriptPlayable = PrefabControlPlayable.Create(graph, this.prefabGameObject, parentTransform); gameObject = scriptPlayable.GetBehaviour().prefabInstance; list.Add(scriptPlayable); } this.m_Duration = PlayableBinding.DefaultDuration; this.m_SupportLoop = false; Playable result; if (gameObject == null) { result = Playable.Create(graph, 0); } else { IList <PlayableDirector> directors = this.GetDirectors(gameObject); IList <ParticleSystem> particleSystems = this.GetParticleSystems(gameObject); this.UpdateDurationAndLoopFlag(directors, particleSystems); PlayableDirector component = go.GetComponent <PlayableDirector>(); if (component != null) { this.m_ControlDirectorAsset = component.get_playableAsset(); } if (go == gameObject && this.prefabGameObject == null) { Debug.LogWarning("Control Playable (" + base.get_name() + ") is referencing the same PlayableDirector component than the one in which it is playing."); this.active = false; if (!this.searchHierarchy) { this.updateDirector = false; } } if (this.active) { this.CreateActivationPlayable(gameObject, graph, list); } if (this.updateDirector) { this.SearchHierarchyAndConnectDirector(directors, graph, list); } if (this.updateParticle) { this.SearchHiearchyAndConnectParticleSystem(particleSystems, graph, list); } if (this.updateITimeControl) { ControlPlayableAsset.SearchHierarchyAndConnectControlableScripts(ControlPlayableAsset.GetControlableScripts(gameObject), graph, list); } Playable playable = ControlPlayableAsset.ConnectPlayablesToMixer(graph, list); result = playable; } return(result); }
public void PlayAnimation(string animationName, Action onComplete = null, bool loop = false, bool restart = true, bool async = false) { TimelineAsset value; bool flag = ((Dictionary <string, TimelineAsset>)m_timelineAssetDictionary).TryGetValue(animationName, out value); if (flag && null != value) { m_playableDirector.set_extrapolationMode(0); if (value != m_playableDirector.get_playableAsset()) { m_playableDirector.Play(value); } else { if (restart || !m_animator2D.get_animationName().Equals(animationName)) { m_playableDirector.set_time(0.0); } m_playableDirector.Resume(); } m_hasTimeline = true; } else { if (flag) { Log.Warning("Boss named '" + this.get_gameObject().get_name() + "' has a timeline setup for key '" + animationName + "' but the actual asset is null.", 202, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\BossObject.cs"); } m_playableDirector.set_time(0.0); m_playableDirector.Pause(); m_hasTimeline = false; } m_animationCallback.Setup(animationName, restart, onComplete); m_animator2D.SetAnimation(animationName, loop, async, restart); }
private void StartAnimation(CharacterAnimationInfo animationInfo, Action onComplete = null, Action onCancel = null, bool restart = true, bool async = false) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) string animationName = animationInfo.animationName; string timelineKey = animationInfo.timelineKey; m_animator2D.get_transform().set_localRotation(animationInfo.flipX ? Quaternion.Euler(0f, -135f, 0f) : Quaternion.Euler(0f, 45f, 0f)); direction = animationInfo.direction; ITimelineAssetProvider characterData = m_characterData; if (characterData != null) { TimelineAsset timelineAsset; bool flag = characterData.TryGetTimelineAsset(timelineKey, out timelineAsset); if (flag && null != timelineAsset) { if (timelineAsset != m_playableDirector.get_playableAsset()) { m_playableDirector.Play(timelineAsset); } else { if (restart || !m_animator2D.get_animationName().Equals(animationName)) { m_playableDirector.set_time(0.0); } m_playableDirector.Resume(); } m_hasTimeline = true; } else { if (flag) { Log.Warning("Character named '" + m_characterData.get_name() + "' has a timeline setup for key '" + timelineKey + "' but the actual asset is null.", 323, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\HavreMap\\MapPathfindingActor.cs"); } m_playableDirector.set_time(0.0); m_playableDirector.Pause(); m_hasTimeline = false; } } m_animationCallback.Setup(animationName, restart, onComplete, onCancel); m_animator2D.SetAnimation(animationName, animationInfo.loops, async, restart); m_animationParameters = animationInfo.parameters; }
public static PlayableDirector[] GetDirectorsInSceneUsingAsset(PlayableAsset asset) { List <PlayableDirector> list = new List <PlayableDirector>(); PlayableDirector[] array = Resources.FindObjectsOfTypeAll(typeof(PlayableDirector)) as PlayableDirector[]; PlayableDirector[] array2 = array; for (int i = 0; i < array2.Length; i++) { PlayableDirector playableDirector = array2[i]; if ((playableDirector.get_hideFlags() & 15) == null) { string assetPath = AssetDatabase.GetAssetPath(playableDirector.get_transform().get_root().get_gameObject()); if (string.IsNullOrEmpty(assetPath)) { if (asset == null || (asset != null && playableDirector.get_playableAsset() == asset)) { list.Add(playableDirector); } } } } return(list.ToArray()); }
public static TimelineAsset GetTimelineAssetForDirectorComponent(PlayableDirector director) { return((!(director != null)) ? null : (director.get_playableAsset() as TimelineAsset)); }