public static Playable Create(PlayableGraph graph, int inputCount = 0)
        {
            var playable = new Playable(graph.CreatePlayableHandle());

            playable.SetInputCount(inputCount);
            return(playable);
        }
Exemple #2
0
        private static PlayableHandle CreateHandle(PlayableGraph graph, T template, int inputCount)
        {
            object obj;

            if (template == null)
            {
                obj = ScriptPlayable <T> .CreateScriptInstance();
            }
            else
            {
                obj = ScriptPlayable <T> .CloneScriptInstance(template);
            }
            PlayableHandle result;

            if (obj == null)
            {
                Debug.LogError("Could not create a ScriptPlayable of Type " + typeof(T).ToString());
                result = PlayableHandle.Null;
            }
            else
            {
                PlayableHandle playableHandle = graph.CreatePlayableHandle();
                if (!playableHandle.IsValid())
                {
                    result = PlayableHandle.Null;
                }
                else
                {
                    playableHandle.SetInputCount(inputCount);
                    playableHandle.SetScriptInstance(obj);
                    result = playableHandle;
                }
            }
            return(result);
        }
        private static PlayableHandle CreateHandle(PlayableGraph graph, T template, int inputCount)
        {
            bool   flag = template == null;
            object obj;

            if (flag)
            {
                obj = ScriptPlayable <T> .CreateScriptInstance();
            }
            else
            {
                obj = ScriptPlayable <T> .CloneScriptInstance(template);
            }
            bool           flag2 = obj == null;
            PlayableHandle result;

            if (flag2)
            {
                string arg_4C_0 = "Could not create a ScriptPlayable of Type ";
                Type   expr_40  = typeof(T);
                Debug.LogError(arg_4C_0 + ((expr_40 != null) ? expr_40.ToString() : null));
                result = PlayableHandle.Null;
            }
            else
            {
                PlayableHandle playableHandle = graph.CreatePlayableHandle();
                bool           flag3          = !playableHandle.IsValid();
                if (flag3)
                {
                    result = PlayableHandle.Null;
                }
                else
                {
                    playableHandle.SetInputCount(inputCount);
                    playableHandle.SetScriptInstance(obj);
                    result = playableHandle;
                }
            }
            return(result);
        }
        private static PlayableHandle CreateHandle(PlayableGraph graph, T template, int inputCount)
        {
            object scriptInstance = null;

            if (template == null)
            {
                // We are creating a new script instance.
                scriptInstance = CreateScriptInstance();
            }
            else
            {
                // We are not creating from scratch, we are creating from a template.
                scriptInstance = CloneScriptInstance(template);
            }

            if (scriptInstance == null)
            {
                Debug.LogError("Could not create a ScriptPlayable of Type " + typeof(T));
                return(PlayableHandle.Null);
            }

            PlayableHandle handle = graph.CreatePlayableHandle();

            if (!handle.IsValid())
            {
                return(PlayableHandle.Null);
            }

            handle.SetInputCount(inputCount);

            // This line should be the last one because it eventually calls
            // IPlayableBehaviour.OnPlayableCreate() on scriptInstance.
            handle.SetScriptInstance(scriptInstance);

            return(handle);
        }