private void SwapPlayers() { // Pause the previously playing video // This is useful for systems that will struggle to play 2 videos at once if (_pausePreviousOnTransition) { CurrentPlayer.Pause(); } // Tell listeners that the playlist item has changed Events.Invoke(this, MediaPlayerEvent.EventType.PlaylistItemChanged, ErrorCode.None); // Start the transition if (_currentTransition != Transition.None) { // Create a new transition texture if required Texture currentTexture = GetCurrentTexture(); Texture nextTexture = GetNextTexture(); if (currentTexture != null && nextTexture != null) { int maxWidth = Mathf.Max(nextTexture.width, currentTexture.width); int maxHeight = Mathf.Max(nextTexture.height, currentTexture.height); if (_rt != null) { if (_rt.width != maxWidth || _rt.height != maxHeight) { RenderTexture.ReleaseTemporary(_rt); _rt = null; } } if (_rt == null) { _rt = RenderTexture.GetTemporary(maxWidth, maxHeight, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 1); } Graphics.Blit(currentTexture, _rt); _material.SetTexture(PropFromTex.Id, currentTexture); _easeFunc = Easing.GetFunction(_currentTransitionEasing); _transitionTimer = 0f; } else { // Immediately complete the transition _transitionTimer = _currentTransitionDuration; if (_autoCloseVideo) { CurrentPlayer.MediaPath.Path = string.Empty; CurrentPlayer.CloseMedia(); } } } // Swap the videos if (NextPlayer == _playerA) { _nextPlayer = _playerB; } else { _nextPlayer = _playerA; } // Swap the items _currentItem = _nextItem; _nextItem = null; }