0 votes
by (120 points)
edited by

Hello,

I am developing a private app, just to test the functionalities, and I need the Headset to turn off after submitting the feedback so they won't forget it turned on

I tried using " Pvr_UnitySDKAPI.System.UPvr_ShutDown(); ". Although it doesn't do anything for me.

There's this function " Pvr_UnitySDKAPI.ToBService.UPvr_ControlSetDeviceAction(PBS_DeviceControlEnum.DEVICE_CONTROL_SHUTDOWN,callback); ", but this " ToBService" does not exist for me.

Does anyone know how can I do it?

1 Answer

0 votes
by (37.0k points)

Dear developer,
Could you pelase tell us what is your device model and the PUI verison?

by (120 points)

Hi,

Model: G2 4K Enterprise

PUI: v4.0.7

by (37.0k points)

Dear developer,
Please check sample scene TobService.unity and script “PvrToBService.cs” about how to initialize ToBService before using this interface. “PvrToBService.cs” can be directly attached to developing scene for binding service. Detailed description of interface usage is as follow:

    //Initializing and bind ToBService, the objectname refers to name of the object which is used to receive callback.
    private void Awake()
    {
        Pvr_UnitySDKAPI.ToBService.UPvr_InitToBService();
        Pvr_UnitySDKAPI.ToBService.UPvr_SetUnityObjectName(objectName);
        Pvr_UnitySDKAPI.ToBService.UPvr_BindToBService();
    }

//Unbind the ToBService
private void OnDestory()
{
    Pvr_UnitySDKAPI.ToBService.UPvr_UnBindToBService();
}
//Add 4 callback methods to allow corresponding callback can be received.
private void BoolCallback(string value)
{
    if (Pvr_UnitySDKAPI.ToBService.BoolCallback != null) Pvr_UnitySDKAPI.ToBService.BoolCallback(bool.Parse(value));
    Pvr_UnitySDKAPI.ToBService.BoolCallback = null;
}
private void IntCallback(string value)
{
    if (Pvr_UnitySDKAPI.ToBService.IntCallback != null) Pvr_UnitySDKAPI.ToBService.IntCallback(int.Parse(value));
    Pvr_UnitySDKAPI.ToBService.IntCallback = null;
}
private void LongCallback(string value)
{
    if (Pvr_UnitySDKAPI.ToBService.LongCallback != null) Pvr_UnitySDKAPI.ToBService.LongCallback(int.Parse(value));
    Pvr_UnitySDKAPI.ToBService.LongCallback = null;
}
private void StringCallback(string value)
{
    if (Pvr_UnitySDKAPI.ToBService.StringCallback != null) Pvr_UnitySDKAPI.ToBService.StringCallback(int.Parse(value));
    Pvr_UnitySDKAPI.ToBService.StringCallback = null;
}

Make sure ToBService is bound successfully before calling this interface. For callback of ToBService binding success, please add the following code to the initialization script. After TobService binding success, this method will be called.

public void toBServiceBind(string s){Debug.Log("Bind success.");}

And the UPvr_ControlSetDeviceAction is a Protected interface.
It’s required to add the label to AndroidManifest as below to use this interface:

<meta-data android:name="pico_advance_interface" android:value="0"/>

Note: To secure system steadiness and user experiences, application which uses following interfaces are not allowed to publish on Pico Store.
For more detial you can check the follow links:
https://developer-global.pico-interactive.com/docs/unity/en/13136/241295/#_7-12-2-protected-interfaces

by (120 points)

Thank you, but I can't find this "TobService.unity" and script “PvrToBService.cs”, it does not come with the SDK because I searched and it's empty.

It does not make sense to me, do I have to create an empty object in my scene and then use the code you gave me? It's just not very clear.

The code you attached is actually the PvrToBService.cs?

ago by (37.0k points)

Dear developer,
Could you please tell us what is the SDK version you are using?
If using PicoVR Unity SDK v2.8.12. You can find it below.
enter image description here
And the PvrToBService.cs code as follow, and add this script to an object in your scene.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Pvr_ToBService : MonoBehaviour
{
    private void Awake()
    {
        InitToBService();
    }
    private void Start()
    {
        BindToBService();
    }
    private void OnDestory()
    {
        UnBindToBService();
    }
    private void InitToBService()
    {
        Pvr_UnitySDKAPI.ToBService.UPvr_InitToBService();
        Pvr_UnitySDKAPI.ToBService.UPvr_SetUnityObjectName(name);
    }
    private void BindToBService()
    {
        Pvr_UnitySDKAPI.ToBService.UPvr_BindToBService();
    }
    private void UnBindToBService()
    {
        Pvr_UnitySDKAPI.ToBService.UPvr_UnBindToBService();
    }
    private void BoolCallback(string value)
    {
        if (Pvr_UnitySDKAPI.ToBService.BoolCallback != null) Pvr_UnitySDKAPI.ToBService.BoolCallback(bool.Parse(value));
        Pvr_UnitySDKAPI.ToBService.BoolCallback = null;
    }
    private void IntCallback(string value)
    {
        if (Pvr_UnitySDKAPI.ToBService.IntCallback != null) Pvr_UnitySDKAPI.ToBService.IntCallback(int.Parse(value));
        Pvr_UnitySDKAPI.ToBService.IntCallback = null;
    }
    private void LongCallback(string value)
    {
        if (Pvr_UnitySDKAPI.ToBService.LongCallback != null) Pvr_UnitySDKAPI.ToBService.LongCallback(int.Parse(value));
        Pvr_UnitySDKAPI.ToBService.LongCallback = null;
    }
    private void StringCallback(string value)
    {
        if (Pvr_UnitySDKAPI.ToBService.StringCallback != null) Pvr_UnitySDKAPI.ToBService.StringCallback(value);
        Pvr_UnitySDKAPI.ToBService.StringCallback = null;
    }

    #region Test
    public Text deviceInfoText;
    public void StateGetDeviceInfo()
    {
        string result = Pvr_UnitySDKAPI.ToBService.UPvr_StateGetDeviceInfo(Pvr_UnitySDKAPI.PBS_SystemInfoEnum.PUI_VERSION);
        deviceInfoText.text = "PUI_VERSION:" + result;
    }

    public void ControlSetDeviceAction()
    {
        Pvr_UnitySDKAPI.ToBService.UPvr_ControlSetDeviceAction(Pvr_UnitySDKAPI.PBS_DeviceControlEnum.DEVICE_CONTROL_SHUTDOWN, ControlSetDeviceActionCallBack);
    }
    private void ControlSetDeviceActionCallBack(int value)
    {
        Debug.Log("ControlSetDeviceActionCallBack : " + value);
    }

    public void AppManager()
    {
        Pvr_UnitySDKAPI.ToBService.UPvr_ControlAPPManger(Pvr_UnitySDKAPI.PBS_PackageControlEnum.PACKAGE_SILENCE_UNINSTALL, "com.pico.ipd.test", AppManagerCallBack);
    }
    private void AppManagerCallBack(int value)
    {
        Debug.Log("AppManagerCallBack : " + value);
    }

    #endregion
}

If you are using PicoXR Platform SDK V1.2.5
You can refer to the following documents for initialize System Service:
https://developer-global.pico-interactive.com/docs/unity/en/13136/system_related_legacy/

ago by (120 points)

I am using an outdated version of Pico VR SDK, I couldn't find the version 2.8.12 for G2 4K. Could you send it to me?

ago by (37.0k points)

Dear developer,
We will send the PicoVR Unity SDK v2.8.12 to your email.
Please check it later in your email.

...