Skip to content

Latest commit

 

History

History
105 lines (72 loc) · 4.66 KB

hisplayer-change-scene-sample.md

File metadata and controls

105 lines (72 loc) · 4.66 KB

HISPlayer Change Scene Sample

Import sample package

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

HISPlayer Sample configuration

image

  • 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

image

  • Open File > Build Settings > Add Open Scenes.

  • Your Build Settings > Scenes In Build will be like image below:

BuildSettings

  • 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.

HISPlayer Change Scene UI Demo

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.

image

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.

image

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();
    ....
    }