![]() This repository contains a Unity project that uses a custom WebGL template to embed the Ready Player Me character creator inside an application to seamlessly add avatars.This page provides a list of all of the Unity Web Player versions currently used by games in Flashpoint. This project can be used as a reference for anybody wanting to add Ready Player Me Avatars into their Unity WebGL application. TemplatesĪs the name suggests this template is specifically designed to work for Unity 2019 versions as the WebGL API changed in Unity 2020+. ![]() This is template was created to support Unity version 2020 or higher, making use of the latest features of Unity's WebGL packaging system. Open the example project in Unity (version 2019 or higher) and open up the build settings window. Make sure the example scene Scenes/WebGLExample is added at the top of the Scenes In Build section. From there select Player from the menu on the left side and open the Resolution and Presentation section.įrom here select the RPMTemplate (or RPM_2019 if using Unity version 2019). Once that is done you can open up the Build Settings window again, make sure you have selected WebGL as the target platform then click Build And Run. It will take some time to compile but once it is finished it should open up the WebGL application in your default browser. To simplify things we will be looking at the RPM_Template as it is more relevant however the logic is very similar for the RPM_2019 template.Īs with all WebGL templates, there is an index.html which is based on the Default template that unity provides but with some extra wrappers ( canvas-wrap) and an that will hold our Ready Player me iFrame as you can see below. ![]() eventName = "v1.avatar.exported" ) Īs you can see we first check this eventName as we specifically want to handle it every time we get the vr.avatar.exported event (after an avatar has been created). the data we wish to pass, which is a URL in this case.the name of the function we want to run (OnWebViewAvatarGenerated).the name of the target object in the Unity scene that has the script and function we want to run (ReadyPlayerMeAvatar in this case).Then we use the reference to the UnityInstance called unityGame and run the SendMessage function. Private static extern void HideReadyPlayerMeFrame() Private static extern void ShowReadyPlayerMeFrame() Private static extern void SetupRpm( string partner) To communicate from Unity to the iFrame running Ready Player me we created a Javascript Library called WebHelper.jslib as shown below it has 3 functions. Once declared this way they can be called like regular C# functions (on WebGL builds). The WebAvatarLoader.cs is a simple class based on the RuntimeTest.cs example, it handles the loading of the avatar loading and setup of the Ready Player Me iFrame. It is important to note that this script is added to an object called WebAvatarLoader and it has a function called OnWebViewAvatarGenerated. Both the name and the function are required so that it can receive the SendMessage function from the browser as mentioned previously here.Whenever a new major version of Unity is released, the webplayer plugin for the browser is also updated to take advantage of the latest features. The plugin checks for new releases as it starts up and will automatically upgrade itself when necessary.Īlthough Unity does take backward compatibility very seriously, it is still possible that a new release could introduce bugs that cause problems with existing webplayers. Since the plugin updates automatically, such bugs could leave a user unable to play a web game until they are fixed and in the meantime, there may be no way to get the working version of the runtime back. To avoid problems like this, the plugin is designed to keep a number of different versions of the Unity runtime, which are called Release Channels. ![]() When an update to the runtime is released, the plugin automatically retrieves it but also retains a copy of the previous version. The latest channel is named Release while the previous one is named Stable.
0 Comments
Leave a Reply. |