Example #1
0
        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.transform;
                ScriptPlayable <PrefabControlPlayable> playable = PrefabControlPlayable.Create(graph, this.prefabGameObject, parentTransform);
                gameObject = playable.GetBehaviour().prefabInstance;
                list.Add(playable);
            }
            this.m_Duration    = PlayableBinding.DefaultDuration;
            this.m_SupportLoop = false;
            Playable result;

            if (gameObject == null)
            {
                result = Playable.Create(graph, 0);
            }
            else
            {
                IList <PlayableDirector> component  = this.GetComponent <PlayableDirector>(gameObject);
                IList <ParticleSystem>   component2 = this.GetComponent <ParticleSystem>(gameObject);
                this.UpdateDurationAndLoopFlag(component, component2);
                PlayableDirector component3 = go.GetComponent <PlayableDirector>();
                if (component3 != null)
                {
                    this.m_ControlDirectorAsset = component3.playableAsset;
                }
                if (go == gameObject && this.prefabGameObject == null)
                {
                    Debug.LogWarning("Control Playable (" + base.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(component, graph, list);
                }
                if (this.updateParticle)
                {
                    this.SearchHiearchyAndConnectParticleSystem(component2, graph, list);
                }
                if (this.updateITimeControl)
                {
                    ControlPlayableAsset.SearchHierarchyAndConnectControlableScripts(ControlPlayableAsset.GetControlableScripts(gameObject), graph, list);
                }
                Playable playable2 = ControlPlayableAsset.ConnectPlayablesToMixer(graph, list);
                result = playable2;
            }
            return(result);
        }
Example #2
0
 public void GatherProperties(PlayableDirector director, IPropertyCollector driver)
 {
     if (!(director == null))
     {
         if (!ControlPlayableAsset.s_ProcessedDirectors.Contains(director))
         {
             ControlPlayableAsset.s_ProcessedDirectors.Add(director);
             GameObject gameObject = this.sourceGameObject.Resolve(director);
             if (gameObject != null)
             {
                 if (this.updateParticle)
                 {
                     foreach (ParticleSystem particleSystem in this.GetComponent <ParticleSystem>(gameObject))
                     {
                         driver.AddFromName <ParticleSystem>(particleSystem.gameObject, "randomSeed");
                         driver.AddFromName <ParticleSystem>(particleSystem.gameObject, "autoRandomSeed");
                     }
                 }
                 if (this.active)
                 {
                     driver.AddFromName(gameObject, "m_IsActive");
                 }
                 if (this.updateITimeControl)
                 {
                     foreach (MonoBehaviour monoBehaviour in ControlPlayableAsset.GetControlableScripts(gameObject))
                     {
                         IPropertyPreview propertyPreview = monoBehaviour as IPropertyPreview;
                         if (propertyPreview != null)
                         {
                             propertyPreview.GatherProperties(director, driver);
                         }
                         else
                         {
                             driver.AddFromComponent(monoBehaviour.gameObject, monoBehaviour);
                         }
                     }
                 }
                 if (this.updateDirector)
                 {
                     foreach (PlayableDirector playableDirector in this.GetComponent <PlayableDirector>(gameObject))
                     {
                         if (!(playableDirector == null))
                         {
                             TimelineAsset timelineAsset = playableDirector.playableAsset as TimelineAsset;
                             if (!(timelineAsset == null))
                             {
                                 timelineAsset.GatherProperties(playableDirector, driver);
                             }
                         }
                     }
                 }
             }
             ControlPlayableAsset.s_ProcessedDirectors.Remove(director);
         }
     }
 }
Example #3
0
        private static Playable ConnectPlayablesToMixer(PlayableGraph graph, List <Playable> playables)
        {
            Playable playable = Playable.Create(graph, playables.Count);

            for (int num = 0; num != playables.Count; num++)
            {
                ControlPlayableAsset.ConnectMixerAndPlayable(graph, playable, playables[num], num);
            }
            playable.SetPropagateSetTime(true);
            return(playable);
        }
Example #4
0
        /// <inheritdoc/>
        public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
        {
            if (director == null)
            {
                return;
            }

            // avoid recursion
            if (s_ProcessedDirectors.Contains(director))
            {
                return;
            }

            s_ProcessedDirectors.Add(director);

            var particlesToPreview    = new HashSet <ParticleSystem>();
            var activationToPreview   = new HashSet <GameObject>();
            var timeControlToPreview  = new HashSet <MonoBehaviour>();
            var subDirectorsToPreview = new HashSet <PlayableDirector>();

            foreach (var clip in GetClips())
            {
                var controlPlayableAsset = clip.asset as ControlPlayableAsset;
                if (controlPlayableAsset == null)
                {
                    continue;
                }

                var gameObject = controlPlayableAsset.sourceGameObject.Resolve(director);
                if (gameObject == null)
                {
                    continue;
                }

                if (controlPlayableAsset.updateParticle)
                {
                    particlesToPreview.UnionWith(gameObject.GetComponentsInChildren <ParticleSystem>(true));
                }
                if (controlPlayableAsset.active)
                {
                    activationToPreview.Add(gameObject);
                }
                if (controlPlayableAsset.updateITimeControl)
                {
                    timeControlToPreview.UnionWith(ControlPlayableAsset.GetControlableScripts(gameObject));
                }
                if (controlPlayableAsset.updateDirector)
                {
                    subDirectorsToPreview.UnionWith(controlPlayableAsset.GetComponent <PlayableDirector>(gameObject));
                }
            }

            ControlPlayableAsset.PreviewParticles(driver, particlesToPreview);
            ControlPlayableAsset.PreviewActivation(driver, activationToPreview);
            ControlPlayableAsset.PreviewTimeControl(driver, director, timeControlToPreview);
            ControlPlayableAsset.PreviewDirectors(driver, subDirectorsToPreview);

            s_ProcessedDirectors.Remove(director);

            particlesToPreview.Clear();
            activationToPreview.Clear();
            timeControlToPreview.Clear();
            subDirectorsToPreview.Clear();
        }