Forum rules - please read before posting.

Saving/Loading a Video RenderTexture

edited December 2023 in Technical Q&A

I'm making an FMV game that is 100% video. The videos are playing fine on a prefab that contains a canvas with a RenderTexture and with a VideoPlayer that is targeting that texture. It works absolutely fine and it'll play videos no problem.

The issue is with the saving and loading.

The player can manually save. When a load game is loaded however, it doesn't seem to save the current video that was playing at the time on the RenderTexture. It's just a blank screen on load.

I've added Constant IDs, I've tried 'Remember Video' but the video is never resumed on load.

Any ideas why the loading isn't working? All other scene elements are showing (hotspots etc).

I'm using Unity 2022.3.14 and AC 1.78.4.

Comments

  • So the RenderTexture is displayed in an Image component on the Canvas?

    The Remember Video Player component will save the playback state of the Video Player - it should be enough.

    Is the Canvas registered as an AC Menu, and - if it's a prefab - does the Remember Video Player have Retain in prefab? checked.

    What is the exact state of the Canvas at the time the player saves? If the Canvas is disabled at the time, its Remember data will not be saved.

    You can check if the data is being saved by opening the Save-game Manager, selecting the save file, and checking the "Persistent data" block in the "Main data" section.

  • edited December 2023

    Hi Chris and thanks for the reply.

    Yes, the RenderTexture is displayed as an image component of the Canvas.

    The Remember Video Player component has Retain in prefab checked.

    It wasn't originally an AC menu - the prefab was in each scene - but I've just tried to create it as an AC menu that turns on when needed and the same issue persists when loading - just a blank screen with everything else loading correctly apart from the video.

    The Canvas isn't disabled but it does say the following in the Persistent Data of the save file:

    "objectID":48378,
    "savePrevented":false,
    "isPlaying":false,
    "currentFrame":-1,
    "currentTime":0.0,
    "clipAssetID":""

    It states that isPlaying is false and the currentFrame is -1 so I'm presuming this is the problem when it loads?

    Any idea what's causing this, as the video is playing?

    I thought it might be because the Save Menu was set to 'Pause on enabled' and was therefore saving the video's paused state, but unchecking that on the menu doesn't seem to make a difference.

    EDIT: I just tried again by removing the menu and relying on the VideoPlayer/Canvas/RenderTexture as an in-scene prefab and the isPlayimg is now set to true and the currentFrame shows the frame it was on during the save. The clipAssetID is still blank, so is this the problem? The videos are simply stored in a folder outside of the Resources folder (adding them to the Resources folder doesn't make a different in regards to the loading issue).

  • clipAssetID is only set if you check Save clip asset? in the Inspector - this is only necessary if you're assigning the VideoClip at runtime, as opposed to it already being assigned in the VideoPlayer in Edit mode.

    Is the saving/loading now working after moving it to the scene, removed from the Menu?

    It states that isPlaying is false and the currentFrame is -1 so I'm presuming this is the problem when it loads?

    Sounds like it, though it's not a behaviour I can recreate. The data is extracted directly from the VideoPlayer component - i.e. isPlaying, so the result it returns it down to Unity.

    Does the objectID match, i.e. 48378 is listed in the Remember Video Player component's Inspector?

  • When I don't rely on the menu, it saves the correct data (isPlaying = true/currentFrame =21, for example).

    The objectID matches and is correct.

    I can't seem to figure it out so I've switched to an autosave method which I've set to force a scene reload onLoad - this will do in the meantime.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.