示例#1
0
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable <CameraEffectBehaviour> .Create(graph, template);

        CameraEffectBehaviour clone = playable.GetBehaviour();

        clone.Effect = Effect.Resolve(graph.GetResolver());
        return(playable);
    }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        if (cameraObj == null)
        {
            if (playerData is GameObject)
            {
                cameraObj = ((GameObject)playerData).GetComponent <Camera>();
            }
            else if (playerData is Camera)
            {
                cameraObj = playerData as Camera;
            }
        }
        if (cameraObj == null)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        Vector3    blendedPosition = Vector3.zero;
        Quaternion blendedRotation = new Quaternion(0f, 0f, 0f, 0f);

        for (int i = 0; i < inputCount; i++)
        {
            ScriptPlayable <CameraEffectBehaviour> playableInput = (ScriptPlayable <CameraEffectBehaviour>)playable.GetInput(i);
            CameraEffectBehaviour input = playableInput.GetBehaviour();

            float inputWeight    = playable.GetInputWeight(i);
            float normalisedTime = (float)(playableInput.GetTime() * input.inverseDuration);

            // if (input.Effect == null && input.EffectType != null)
            // {
            //     Type effectype = input.EffectType;
            //     input.Effect = (MonoBehaviour)cameraObj.gameObject.AddComponent(effectype);
            // }

            if (input.Effect != null)
            {
                if (!effectList.Contains(input.Effect))
                {
                    effectList.Add(input.Effect);
                }
                if (inputWeight > 0)
                {
                    input.Effect.enabled = true;
                }
                else
                {
                    input.Effect.enabled = false;
                }
            }
        }
    }
示例#3
0
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
#if UNITY_EDITOR
        foreach (TimelineClip clip in m_Clips)
        {
            CameraEffectClip mouthClip = clip.asset as CameraEffectClip;
            // the template variable comes from classes made with the playable wizard
            CameraEffectBehaviour behaviour = mouthClip.template;
            mouthClip.camera = go.GetComponent <PlayableDirector>().GetGenericBinding(this) as Camera;
            // name the track with my variables value
            clip.displayName   = mouthClip.EffectName;
            mouthClip.director = go.GetComponent <PlayableDirector>();
        }
#endif
        ScriptPlayable <CameraEffectMixerBehaviour> playable = ScriptPlayable <CameraEffectMixerBehaviour> .Create(graph, inputCount);

        return(playable);
    }