SteamModule.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using KairoEngine.Core;
  6. using KairoEngine.Core.ModuleSystem;
  7. using Sirenix.OdinInspector;
  8. namespace KairoEngine.SteamIntegration
  9. {
  10. public class SteamModule : GameModuleBase
  11. {
  12. public override string name => "Steam Module";
  13. [LabelText("Steamworks App ID")] public uint appId = 0000000;
  14. public bool showDebug = false;
  15. public SteamModule(GameConfig config) : base(config)
  16. {
  17. this.gameConfig = config;
  18. this.className = this.GetType().AssemblyQualifiedName;
  19. this.typeName = "SteamModule";
  20. }
  21. public override void Load(Transform parent)
  22. {
  23. GameObject obj = GameObject.Instantiate(new GameObject(), parent);
  24. obj.name = "SteamIntegration";
  25. SteamworksManager steamworksManager = obj.AddComponent<SteamworksManager>();
  26. steamworksManager.appId = appId;
  27. steamworksManager.ShowDebug(showDebug);
  28. }
  29. public override void Start() { }
  30. public override void Reset() { }
  31. public override void Destroy() { }
  32. public static SteamModule JSONToSteamModule(string data)
  33. {
  34. try
  35. {
  36. return JsonUtility.FromJson<SteamModule>(data);
  37. }
  38. catch (System.Exception e)
  39. {
  40. Debug.LogError($"Could not deserialize SteamModule: \n{e}");
  41. return new SteamModule(null);
  42. }
  43. }
  44. public override void OnBeforeSerialize(ObjectSerializer serializer) { }
  45. public override void OnBeforeDeserialize(ObjectSerializer serializer) { }
  46. }
  47. }