This prefab adds support for SRT subtitles to USharpVideo - it will also work with base video players supported by VRChat (Unity and AVPro).
To check this out in-game visit this test world or world from this list.
The core of this prefab is based on this code by Haï~.
Currently, there are minor issues for the Quest users - see here.
- Subtitle synchronization with everyone in the instance
- Option to use own subtitles locally
- Rich customization with the ability for the players to save their settings
Contact me if you want your world to be added to this list.
- Unity 2019.4.29f1+
- UdonSharp v1.0.0+
- USharpVideo v1.0.0+
Tip
I suggest adding "subtitles" to your world's tags when using this prefab so that people can find worlds with subtitle support more easily.
- Install UdonSharp first (preferably using Creator Companion)
- Import USharpVideo (required even if you're not planning on using it unfortunately)
- Import latest release unitypackage
- Drag the
Subtitles
prefab into your scene- when using USharpVideo you can also drag
Subtitles
prefab intoUSharpVideo
in your scene and resetSubtitles
object's transform values
- when using USharpVideo you can also drag
- When a window asking you to import TextMeshPro Essentials appears - just do it
- Add a reference in the
Subtitles
object (SubtitleManager script) to:- when using USharpVideo (Target Video Player field) - USharpVideoPlayer from the
USharpVideo
object - in any other case (Base Video Player field) - VRCUnityVideoPlayer or VRCAVProVideoPlayer that have to be somewhere in your scene - depends on which one you're using (you can change this dynamically)
- when using USharpVideo (Target Video Player field) - USharpVideoPlayer from the
- Add a reference in the
Subtitles/Overlay
object (Video Screen field) to the video player's screen object, the overlay will copy the position and rotation of the screen on start- if this doesn't work on your world then you will have to manually adjust
Subtitles/Overlay
object's position and rotation to match the video screen object (while keeping the mentioned earlier field empty)
- if this doesn't work on your world then you will have to manually adjust
Methods that you might be interested in using when integrating this prefab with other stuff in your world.
Use this to change the video player reference that the subtitles are synced with
- Does nothing when using USharpVideo
Check whenever subtitles are currently loaded
- It will return
true
if subtitles are loaded for the current mode (IsLocal()
)
Loads subtitles from the text string globally or locally (depending on IsLocal()
value)
- When using USharpVideo - only the player who can control the video player can do this
- For other video players - if
IsLocked()
istrue
then only the Master can do this - To check whenever player is able to execute this - use
SubtitleManager.CanControlSubtitles()
Loads subtitles from the URL globally or locally (depending on IsLocal()
value)
- When using USharpVideo - only the player who can control the video player can do this
- For other video players - if
IsLocked()
istrue
then only the Master can do this - To check whenever player is able to execute this - use
SubtitleManager.CanControlSubtitles()
Clears the subtitles globally or locally (depending on IsLocal()
value)
- When using USharpVideo - only the player who can control the video player can do this
- For other video players - if
IsLocked()
istrue
then only the Master can do this - To check whenever player is able to execute this - use
SubtitleManager.CanControlSubtitles()
Whenever the access is locked to Master only
- When using USharpVideo it shares the same state with it
Change lock state, must be executed by the Master
- Does nothing when used with USharpVideo as it shares the same state with it
- This can fail if the synchronization is ongoing - check if
SubtitleManager.IsSynchronized()
istrue
before running it - To check whenever player is able to execute this - use
SubtitleManager.IsPrivilegedUser(VRCPlayerApi)
Whenever the subtitles are enabled for the the player
Enable or disable the subtitles for the the player
Whenever the player is using local subtitles
Switch between using global and local subtitles
Re-synchronizes the subtitles globally, only the person who loaded them can do this (or the master if the synchronization is finished) - this can change when that person leaves the instance or lock state changes - check the SubtitleManager.gameObject
owner in this case
- This can fail if the synchronization is ongoing - check if
SubtitleManager.IsSynchronized()
istrue
before running it - To check whenever player is able to execute this - use
SubtitleManager.CanSynchronizeSubtitles()
Use this method to get transform values of the overlay's Canvas
in case you want to display something on the same screen
Moves the overlay to the given object's transform values
- Make sure that the settings popup is not visible at this time as it will stay in the old position until it is re-opened
Check if settings popup is currently open
Toggle settings popup, use this to show and hide the popup using separate button
Import settings from the given string (the same string which is displayed in the settings window), the format is pretty easy to figure out