/** * <summary>Serialises appropriate GameObject values into a string.</summary> * <returns>The data, serialised as a string</returns> */ public override string SaveData() { VideoPlayerData videoPlayerData = new VideoPlayerData(); videoPlayerData.objectID = constantID; videoPlayerData.savePrevented = savePrevented; if (GetComponent <VideoPlayer>()) { VideoPlayer videoPlayer = GetComponent <VideoPlayer>(); videoPlayerData.isPlaying = videoPlayer.isPlaying; videoPlayerData.currentFrame = videoPlayer.frame; videoPlayerData.currentTime = videoPlayer.time; if (saveClipAsset) { if (videoPlayer.clip != null) { videoPlayerData.clipAssetID = AssetLoader.GetAssetInstanceID(videoPlayer.clip); } } } return(Serializer.SaveScriptData <VideoPlayerData> (videoPlayerData)); }
/** * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary> * <param name = "stringData">The data, serialised as a string</param> */ public override void LoadData(string stringData) { VideoPlayerData data = Serializer.LoadScriptData <VideoPlayerData> (stringData); if (data == null) { return; } SavePrevented = data.savePrevented; if (savePrevented) { return; } if (GetComponent <VideoPlayer>()) { VideoPlayer videoPlayer = GetComponent <VideoPlayer>(); //videoPlayer.frame = data.currentFrame; videoPlayer.time = data.currentTime; if (data.isPlaying) { if (!videoPlayer.isPrepared) { loadTime = data.currentTime; playAfterLoad = true; videoPlayer.prepareCompleted += OnPrepareVideo; videoPlayer.Prepare(); } else { videoPlayer.Play(); } } else { if (data.currentTime > 0f) { if (!videoPlayer.isPrepared) { loadTime = data.currentTime; playAfterLoad = false; videoPlayer.prepareCompleted += OnPrepareVideo; videoPlayer.Prepare(); } else { videoPlayer.Pause(); } } else { videoPlayer.Stop(); } } } }
/** * <summary>Serialises appropriate GameObject values into a string.</summary> * <returns>The data, serialised as a string</returns> */ public override string SaveData() { VideoPlayerData videoPlayerData = new VideoPlayerData(); videoPlayerData.objectID = constantID; videoPlayerData.savePrevented = savePrevented; if (GetComponent <VideoPlayer>()) { VideoPlayer videoPlayer = GetComponent <VideoPlayer>(); videoPlayerData.isPlaying = videoPlayer.isPlaying; videoPlayerData.currentFrame = videoPlayer.frame; videoPlayerData.currentTime = videoPlayer.time; } return(Serializer.SaveScriptData <VideoPlayerData> (videoPlayerData)); }