Skip to content

Commit

Permalink
Update setup-guide.md
Browse files Browse the repository at this point in the history
  • Loading branch information
StAincrad authored Oct 24, 2023
1 parent 201004a commit 17af244
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions setup-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ Open the window HISPlayer located in the upper side of the screen > Click on Pla
</p>

## 2.1 Set up HISPlayer Manager
Create a script (for example **iOSStreamController**) which is going to inherit from **HISPlayerManager**. It is needed to include the namespace by adding **using HISPlayerAPI;** and add this component to a GameObject. It is recommended to create an **Empty GameObject** for this.
Create a new script which will inherit from **HISPlayerManager**, for example, iOSStreamController. It is necessary to add the **'using HISPlayerAPI;'** dependancy. Then, add this component to a new game object (recommended to be empty).

Call the **SetUpPlayer()** function in order to initialize the stream environment internally. This function can be called whenever it’s needed.
Call the **SetUpPlayer()** function in order to initialize the stream environment internally. This function can be called whenever it’s needed.

For example, using the Awake function:

```C#
using System.Collections;
using System.Collections.Generic;
Expand All @@ -58,48 +59,45 @@ public class iOSStreamController : HISPlayerManager
}
}
```
It is strictly necessary to use **SetUpPlayer** before using anything else, because this function will initialize everything from the SDK in order to be able to use the rest of the functions (Play, Pause, Seek …).

## 2.2 Attach Unity Resources
Move to **Unity Editor** to attach all the resources. The rendering system is supporting **Material, RawImage, RenderTexture** and **NONE** Unity’s components.
It is strictly necessary to use SetUpPlayer before using anything else. This function initializes everything else that will be needed during the usage of HISPlayer APIs.

### <ins>Material</ins>
Move into Assets’ folder for creating a new **Material**. It is possible to create a new **Material** into **Assets > Create > Material**.
Remember to call the Release function after closing the app or before changing scenes in Unity for freeing the internal resources.

<p align="center">
<img src="./assets/material.png">
</p>
## 2.2 Attach Unity resources

Move to **Unity Editor** to attach all the resources. The rendering system is supporting **Material**, **RawImage** and **RenderTexture** Unity’s components.

Attach the material to the GameObject which is going to be used as a screen.
### <ins>Material</ins>
Create a new Material from **Assets > Create > Material** and attach it to the GameObject that is going to be used as screen and to the stream controller component.

You can also use the **Resources > Materials > HISPlayerDefaultMaterial.mat** we provide in our package.

<p align="center">
<img src="./assets/attach-material.png">
<img width=40% alt="image" src="https://github.com/HISPlayer/UnityAndroid-SDK/assets/47497948/eacab2a8-7cee-4218-add9-98672f250540">
<img width=40% alt="image" src="https://github.com/HISPlayer/UnityAndroid-SDK/assets/47497948/9781bc85-0abb-49a9-97a2-901d5cbc899f">
</p>

### <ins>Raw Image</ins>
This action will be related to Unity’s Canvas. If there is not a Canvas created yet, creating a **Raw Image** will create one automatically.

For the creation, select **GameObject > UI > Raw Image**
For the creation, select **GameObject > UI > Raw Image**. Once it is created, attach it to the stream controller component

<p align="center">
<img src="./assets/rawimage.png">
<img width="400" alt="image" src="https://github.com/HISPlayer/UnityAndroid-SDK/assets/47497948/1eb441fa-1188-427a-bc72-f7be48a44c18">
</p>

Once it is created, it can be attached to the stream controller script without doing anything else.

### <ins>RenderTexture</ins>
First of all, check if the Resources folder exists and contains the RenderTextures folder. If it doesn’t exist then create it from zero. In this case, look for the Resources folder and copy its contents into the Unity Assets folder. This folder contains Unity RenderTexture resources. Another option is creating RenderTexture in Assets directly.
For this you can use the RenderTexture we provide or create a RenderTexture from zero. In the first case, go to the Resources folder of our package and attach the **Resources > Materials > HISPlayerDefaultMaterialRenderTexture.mat** to the GameObject that is going to be used as screen and the **Resources > RenderTextures > HISPlayerRenderTexture.renderTexture** to the stream controller component.

The **RenderTexture** has to be attached to the GameObject which will be a screen for rendering the multimedia stream.
For creating it from zero, select **Assets > Create > Render Texutre** and then create a **Material** referencing the **Render Texture**. This last action can be done automatically by grabbing the **Render Texture** and dropping it at the end of a GameObject's Inspector with the component **Mesh Renderer** with **Material field empty**. This will create the new material inside a **Materials** folder.

For creating this object, select **GameObject > 3D Object > Quad**. Then select the GameObject and remove the material attached to its **Mesh Renderer** component, then replace it with the **RenderTexture** created. The **RenderTextures** folder provided by the SDK contains the **Material** folder and this material is the one which is needed to be used for the replacement . If the **RenderTexture** resource has been created from 0, then another option is to grab the **RenderTexture** from the **Assets** folder and drop it at the end of the GameObject’s Inspector, this will create a new material automatically.
Once all this process it’s done, associate the **RenderTexture** to the script component.

<p align="center">
<img src="./assets/rendertexture.png">
<img src="https://github.com/HISPlayer/UnityiOS-SDK/assets/47497948/a0f26bc1-c7b1-432e-ad87-1a2d203d32c8">
</p>

Once all this process it’s done, associate the **RenderTexture** to the script component.

## 2.3 Configure HISPlayer Properties
### <ins>License Key</ins>
Input the license key that is associated with the SDK. If the license key is not valid, the player won't work and will throw an error message.
Expand Down

0 comments on commit 17af244

Please sign in to comment.