Please, download the sample here -> HISPlayer Change Scene Sample (no need to download it if you have received it in the email).
Importing the package is the same as importing other normal packages in Unity. Select the downloaded package and import it.
- Assets > Import Package > Custom Package > HISPlayerChangeSceneSample.unitypackage
-
Select the target platform and complete the HISPlayer configuration
- Android -> Configure Unity for Android
- iOS -> Configure Unity for iOS
- WebGL -> Configure Unity for WebGL
- Windows -> Configure Unity for Windows
- UWP -> Configure Unity for UWP
- macOS -> Configure Unity for macOS
-
Open the scene Assets/HISPlayerChangeSceneSample/Scenes/HomeScene.unity
-
Import TextMesh Pro Essential
-
Open File > Build Settings > Add Open Scenes
-
Open the scene Assets/HISPlayerChangeSceneSample/Scenes/HISPlayerSample.unity
-
If you received a license key from HISPlayer, input the license key through the Inspector. HISPlayerController GameObject -> HISPlayerController component -> License Key
-
Open File > Build Settings > Add Open Scenes.
-
Your Build Settings > Scenes In Build will be like image below:
- Build and Run
To check how to set up the SDK and API usage, please refer to Assets/HISPlayerChangeSceneSample/Scripts/HISPlayerController.cs and HISPlayerController GameObject in the Editor.
The UI components in the sample scene are fully modifiable and each stream has its own UI. The sample is intended to show how to change between 2 Unity scenes at runtime with HISPlayerSDK attached in one of the scene.
HomeScene is the first scene where you will start the game. To change to the next HISPlayerSample scene, please refer to LoadSceneButton GameObject in the Editor and the OnChangeScene() function in the SceneLoader.cs script.
HISPlayerSample is the second scene where you have the HISPlayerSDK control attached. To go back to the previous HomeScene, please refer to the ChangeSceneButton GameObject in the Editor and the OnChangeScene() function in the HISPlayerController.cs script.
If you are using HISPlayerSDK v4.3.0 and below, before changing scene from the scene where you have HISPlayer attached, please call Release() API to release all of the HISPlayer resources.
If you are using HISPlayerSDK v4.4.0 and above, the Release() is called automatically.
public void ReleasePlayer()
{
for (int i = 0; i < totalScreens; i++)
{
StopCoroutine(UpdateVideoPosition(i));
}
Release(); // Not needed for HISPlayerSDK v4.4.0 and above
}
public void OnChangeScene()
{
ReleasePlayer();
SceneManager.LoadScene("HomeScene");
}
When entering or re-entering the HISPlayer scene, make sure that you call SetUpPlayer() API to reinitialize HISPlayer, otherwise the video will not be loaded.
protected override void Awake()
{
base.Awake();
SetUpPlayer();
....
}