119 lines
2.6 KiB
C#
119 lines
2.6 KiB
C#
using UnityEngine;
|
|
using Viveport;
|
|
using Viveport.Core;
|
|
|
|
public class ViveportDemo_DLC : MonoBehaviour
|
|
{
|
|
private int nWidth = 140;
|
|
|
|
private int nHeight = 40;
|
|
|
|
private static bool bIsReady;
|
|
|
|
private static bool bIsDLCAvailable;
|
|
|
|
private static int dlcCount = -1;
|
|
|
|
private static string dlcAppId = string.Empty;
|
|
|
|
private int dlcIndex;
|
|
|
|
private int nXStart = 10;
|
|
|
|
private int nYStart = 35;
|
|
|
|
private static string APP_ID = "76d0898e-8772-49a9-aa55-1ec251a21686";
|
|
|
|
private static bool bInit = true;
|
|
|
|
private void Start()
|
|
{
|
|
Api.Init(InitStatusHandler, APP_ID);
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
GUIStyle style = new GUIStyle("button");
|
|
if (!bInit)
|
|
{
|
|
GUI.contentColor = Color.white;
|
|
}
|
|
else
|
|
{
|
|
GUI.contentColor = Color.gray;
|
|
}
|
|
if (GUI.Button(new Rect(nXStart, nYStart, nWidth, nHeight), "Init", style) && !bInit)
|
|
{
|
|
Api.Init(InitStatusHandler, APP_ID);
|
|
}
|
|
if (bInit)
|
|
{
|
|
GUI.contentColor = Color.white;
|
|
}
|
|
else
|
|
{
|
|
GUI.contentColor = Color.grey;
|
|
}
|
|
if (GUI.Button(new Rect(nXStart + (nWidth + 10), nYStart, nWidth, nHeight), "Shutdown", style) && bInit)
|
|
{
|
|
Api.Shutdown(ShutdownHandler);
|
|
}
|
|
if (GUI.Button(new Rect(nXStart + 2 * (nWidth + 10), nYStart, nWidth, nHeight), "IsDLCReady", style) && bInit)
|
|
{
|
|
DLC.IsDlcReady(IsDLCReadyHandler);
|
|
}
|
|
if (GUI.Button(new Rect(nXStart + 3 * (nWidth + 10), nYStart, nWidth, nHeight), "GetDLCCount", style) && bInit && bIsReady)
|
|
{
|
|
dlcCount = DLC.GetCount();
|
|
Viveport.Core.Logger.Log("DLC count: " + dlcCount);
|
|
}
|
|
if (GUI.Button(new Rect(nXStart + 4 * (nWidth + 10), nYStart, nWidth, nHeight), "GetIsAvailable", style) && bInit && bIsReady && DLC.GetIsAvailable(dlcIndex, out dlcAppId, out bIsDLCAvailable))
|
|
{
|
|
Viveport.Core.Logger.Log("Is DLC available: " + bIsDLCAvailable);
|
|
Viveport.Core.Logger.Log("DLC APP ID: " + dlcAppId);
|
|
}
|
|
}
|
|
|
|
private static void InitStatusHandler(int nResult)
|
|
{
|
|
if (nResult == 0)
|
|
{
|
|
bInit = true;
|
|
bIsReady = false;
|
|
Viveport.Core.Logger.Log("InitStatusHandler is successful");
|
|
}
|
|
else
|
|
{
|
|
bInit = false;
|
|
Viveport.Core.Logger.Log("InitStatusHandler error : " + nResult);
|
|
}
|
|
}
|
|
|
|
private static void ShutdownHandler(int nResult)
|
|
{
|
|
if (nResult == 0)
|
|
{
|
|
bInit = false;
|
|
bIsReady = false;
|
|
Viveport.Core.Logger.Log("ShutdownHandler is successful");
|
|
}
|
|
else
|
|
{
|
|
Viveport.Core.Logger.Log("ShutdownHandler error: " + nResult);
|
|
}
|
|
}
|
|
|
|
private static void IsDLCReadyHandler(int nResult)
|
|
{
|
|
if (nResult == 0)
|
|
{
|
|
Viveport.Core.Logger.Log("DLC is ready");
|
|
bIsReady = true;
|
|
}
|
|
else
|
|
{
|
|
Viveport.Core.Logger.Log("IsDLCReadyHandler error: " + nResult);
|
|
}
|
|
}
|
|
}
|