40 lines
868 B
C#
40 lines
868 B
C#
using System;
|
|
using Steamworks;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
|
|
public class SteamManager : MonoBehaviour
|
|
{
|
|
public uint appId;
|
|
public UnityEvent onSteamFailed;
|
|
|
|
private void Awake()
|
|
{
|
|
DontDestroyOnLoad(this);
|
|
try
|
|
{
|
|
SteamClient.Init(appId);
|
|
Debug.Log("Steam is up and running!");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.Log(e.Message);
|
|
onSteamFailed.Invoke();
|
|
}
|
|
}
|
|
|
|
private void OnApplicationQuit()
|
|
{
|
|
try
|
|
{
|
|
Debug.Log("Steam is shutting down!");
|
|
SteamClient.Shutdown();
|
|
}
|
|
catch
|
|
{
|
|
Debug.Log("Steam is not running!");
|
|
}
|
|
}
|
|
}
|