OmniVirt makes the leading player for 360° video experiences across mobile and desktop. Upload your 360° content to OmniVirt and serve it into your app with few easy steps.
OmniVirt VR Player could be used on Unity 5.3 or newer.
OmniVirt VR Player for Unity provides you a really easy way to embed 360° content on your iOS and Android game with just few lines of code.
- Sign up for an account at OmniVirt
- Upload your VR / 360° photo or video on OmniVirt.
- Keep the Content ID assigned to your content for further use.
Content is now ready. It is time to work on Unity editor.
-
Download OmniVirtSDK.unitypackage
-
Import it to your Unity project via Assets -> Import Package -> Custom Package menu.
Your project will now contain all necessary files to run OmniVirt VR Player.
Currently OmniVirt VR Player for Unity is supported only on iOS and Android. So to make it works, you need to switch platform to either iOS or Android first. To do so, click at File -> Build Settings, choose your target platform (iOS or Android) and then click Switch Platform.
Please note that if you do not switch the platform, your code will not be able to compile.
You can now let you VR content played in your game with just a single line of code !
First, create an empty GameObject in the scene.
And then, create a C# script and rename it to VRPlayerControl
.
Drag the script and drop it a created GameObject to assign it to the scene.
Open VRPlayerControl.cs
file and add the following line in the header area.
using OmniVirt;
The following code snippet is used to launch a VR Player.
vrPlayer.LoadAndPlay (CONTENT_ID, // Replace your Content ID here
true // Cardboard Enabled; false for non-VR mode
);
Replace CONTENT_ID
with a Content ID got from step above to let it play the specific content you need, for example,
public class VRPlayerControl : MonoBehaviour {
VRPlayer vrPlayer;
// Use this for initialization
void Start () {
// Create VR Player instance
vrPlayer = new VRPlayer ();
// Register Callback for Video Playing Completion Event
vrPlayer.OnVideoEnd += OnVRPlayerEnded;
vrPlayer.OnUnloaded += OnVRPlayerUnloaded;
// Play
vrPlayer.LoadAndPlay (24, true); // Use your Content ID here
}
// Update is called once per frame
void Update () {
}
/*************************
* Callback for VR Player
*************************/
// Video Playing Completion Event
void OnVRPlayerEnded() {
// Automatically close the player after played
if (vrPlayer != null)
vrPlayer.Unload ();
}
// VR Player Unloaded Event
void OnVRPlayerUnloaded() {
vrPlayer = null;
}
}
And ... done ! It is this easy ! You can now build project and run to test the VR Player.
Would like to earn money from your 360° content? You can create an Ad Space on OmniVirt and pass the Ad Space ID acquired to the command like shown below to enable ad on the player.
vrPlayer.LoadAndPlay (CONTENT_ID, // Your Content ID
AD_SPACE_ID, // Your Ad Space ID
true // Cardboard Enabled; false for non-VR mode
);
Once you set it up correctly, user will sometime see an preroll-ad before the content is played and that will turn into your revenue !
Any change on the player could be detected by registering a callback function in the pattern like this.
void Start () {
...
// Register a Callback
vrPlayer.OnVideoEnd += OnVRPlayerEnded;
}
// Video Playing Completion Event
void OnVRPlayerEnded() {
}
These are the list of callback functions available.
-
OnVideoReady()
Called when video is ready to play.
-
OnVideoEnd()
Called when VR Player has finished playing.
-
OnUnloaded()
Called when VR Player has been destroyed.
Since Day Dream game controller support is required on Day Dream compatible application / game, OmniVirt SDK also provides support on this funcionality as well. You can enable it with some easy following steps.
-
Import Google VR SDK for Unity into your project. If your application or game is built for Day Dream, it supposes to have this SDK installed in your project already.
-
Add
GvrControllerMain
andGvrEditorEmulator
prefab to the scene.
- Add
OmniVirtGameController
script toGvrControllerMain
game object. (It is important to add script to the correct one otherwise it would not work).
That's all. Day Dream controller will now magically work with our VR Player in Day Dream mode !
Bitcode is not supported on OmniVirt SDK yet. Please turn the Bitcode off by set Build Settings -> Bitcode
to off for your deployment target.
Please feel free to email us at [email protected] !