Page 2 of 2

Re: Trying to change background with sequencer command doesn't work

Posted: Mon Apr 17, 2023 7:22 pm
by pschroed
So I wrote my own sequencercommand script for displaying a video in the background.

But where do I save my script so that dialogue system can find it?

Drag and drop into the sequencer field doesn't work and I couldn't find anything in the documentation about it.

Re: Trying to change background with sequencer command doesn't work

Posted: Mon Apr 17, 2023 9:39 pm
by Tony Li
Hi,

As long as the namespace is PixelCrushers.DialogueSystem.SequencerCommands and the script name starts with SequencerCommand, the Dialogue System will find it no matter where it is in your project.

Re: Trying to change background with sequencer command doesn't work

Posted: Tue Apr 18, 2023 3:49 am
by pschroed
Strange in my case dialogue system doesn't find my script.

The script is saved in the script folder of my project.

The namespace is in the script:

namespace PixelCrushers.DialogueSystem.SequencerCommands

I also think that I named the script/class correctly:

public class SequencerCommandVideo1 : SequencerCommand

But if I type in Video1 in the Sequencer field of the dialogue node, it can't find it.

Re: Trying to change background with sequencer command doesn't work

Posted: Tue Apr 18, 2023 8:14 am
by Tony Li
Hi,

What do you mean by "it can't find it"? Does it not run the command when you play the game and get to that dialogue entry node?

Temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. Then play the game and get to the dialogue entry node that uses your custom sequencer command. You should see two lines in the Console window. The first one appears when the conversation parses the Sequence to know what commands to run. It will look something like:

Dialogue System: Sequencer.Play( Video1() )@0

The second one appears when the command actually runs. It will look something like:

Dialogue System: Sequencer: Video1()

If you see those lines, then it's trying to play the command.

As a test, inspect the node in the Dialogue Editor. Click the "+" next to the Sequence field and look for your command (Video1) in the All Sequencer Commands submenu. If it's there, the Dialogue System recognizes it.

Re: Trying to change background with sequencer command doesn't work

Posted: Tue Apr 18, 2023 12:35 pm
by pschroed
Found the mistake.

I typed in Video1 instead of Video1(). :oops:

So now it finds my sequencer command and tries to use it.

I added a Video Player to the hierarchy and a Canvas with a RawImage. I added a texture called VideoOutput to the RawImage and set that VideoOutput texture as target texture in the VideoPlayer GameObject. Now the Sequencer command should call my addressable asset (the video) and play it on the texture.

Unfortunately I get an error message and can't really find my mistake. It should work, but somehow it can't find the asset in the moved folder.

The error message I get is:

UnityEngine.AddressableAssets.InvalidKeyException: Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown. No Location found for Key=Assets/Resources_moved/Video1
UnityEngine.AddressableAssets.Addressables:LoadAssetAsync<UnityEngine.Video.VideoClip> (object)

That's my code:

Code: Select all

using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.Video;
using System.Collections.Generic;


namespace PixelCrushers.DialogueSystem.SequencerCommands
{

    public class SequencerCommandVideo1 : SequencerCommand
    {
        
        public void Update()
        {
            {
                AsyncOperationHandle<VideoClip> asyncOperationHandle =
                    Addressables.LoadAssetAsync<VideoClip>("Assets/Resources_moved/Video1");

                asyncOperationHandle.Completed += AsyncOperationHandle_Completed;
                Stop();
            }

        }

        private void AsyncOperationHandle_Completed(AsyncOperationHandle<VideoClip> asyncOperationHandle)
        {
            if (asyncOperationHandle.Status == AsyncOperationStatus.Succeeded)
            {
                VideoPlayer ClipPlayer = GameObject.Find("VideoPlayer").GetComponent<VideoPlayer>();
                ClipPlayer.clip = asyncOperationHandle.Result;
                ClipPlayer.Play();
            }
        }


    }

}
I am thankful for every hint where my mistake is.

Re: Trying to change background with sequencer command doesn't work

Posted: Tue Apr 18, 2023 1:01 pm
by Tony Li
The video’s addressable key is probably just “Video1”. Try specifying this in your load method.