-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
Syncing v2024.7.1
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
#if UNITY_EDITOR | ||
using UnityEditor; | ||
|
||
public static class CacheOpener | ||
{ | ||
[MenuItem("Tools/mod.io/Open Cache")] | ||
public static void OpenCache() | ||
{ | ||
try | ||
{ | ||
string path = Path.GetFullPath($"{Application.persistentDataPath}/mod.io"); | ||
#if UNITY_EDITOR_WIN || UNITY_EDITOR_LINUX | ||
// Supposedly Linux uses the same executable name as windows, though not 100% confident | ||
// so wrapping all this in a try catch. | ||
System.Diagnostics.Process.Start("explorer.exe", path); | ||
#elif UNITY_EDITOR_OSX | ||
System.Diagnostics.Process.Start("open", $"-R \"{path}\""); | ||
#endif | ||
} | ||
catch (Exception exception) | ||
{ | ||
Debug.LogError($"Exception opening local cache: {exception.Message}\n{exception.StackTrace}"); | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#if UNITY_EDITOR | ||
using System.Collections.Generic; | ||
using ModIO.Implementation; | ||
using UnityEditor; | ||
using UnityEditor.UIElements; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace ModIO.EditorCode | ||
{ | ||
public class ModioSettingProvider : SettingsProvider | ||
{ | ||
SettingsAsset _config; | ||
SerializedObject _serializedConfig; | ||
|
||
ModioSettingProvider() : | ||
base("mod.io/Settings", SettingsScope.Project, new HashSet<string>(new[] { "modio", "gameId", "gameKey", "apiKey", "Server URL" })) | ||
{ | ||
} | ||
|
||
public override void OnActivate(string searchContext, VisualElement rootElement) | ||
{ | ||
_config = EditorMenu.GetConfigAsset(); | ||
_serializedConfig = new SerializedObject(_config); | ||
|
||
rootElement.Add(new Label("mod.io Settings") | ||
{ | ||
style = | ||
{ | ||
marginLeft = 4, | ||
fontSize = 19, | ||
unityFontStyleAndWeight = FontStyle.Bold, | ||
}, | ||
}); | ||
rootElement.Add(new InspectorElement(_serializedConfig)); | ||
} | ||
|
||
[SettingsProvider] | ||
public static SettingsProvider OpenModioSettingsProvider() => new ModioSettingProvider(); | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#if UNITY_FACEPUNCH | ||
using Steamworks; | ||
#endif | ||
using UnityEngine; | ||
|
||
namespace ModIO.Implementation.Platform | ||
{ | ||
public class ModioPlatformExampleFacepunch : MonoBehaviour | ||
{ | ||
[SerializeField] int appId; | ||
|
||
void Awake() | ||
{ | ||
bool supportedPlatform = !Application.isConsolePlatform; | ||
|
||
#if !UNITY_FACEPUNCH | ||
supportedPlatform = false; | ||
#endif | ||
|
||
if (!supportedPlatform) | ||
{ | ||
Destroy(this); | ||
return; | ||
} | ||
|
||
#if UNITY_FACEPUNCH | ||
try | ||
{ | ||
SteamClient.Init((uint)appId, true); | ||
} | ||
catch (System.Exception e) | ||
{ | ||
Debug.Log(e); | ||
return; | ||
} | ||
#endif | ||
|
||
// --- This is the important line to include in your own implementation --- | ||
ModioPlatformFacepunch.SetAsPlatform(); | ||
} | ||
|
||
#if UNITY_FACEPUNCH | ||
void OnDisable() | ||
{ | ||
SteamClient.Shutdown(); | ||
} | ||
|
||
void Update() | ||
{ | ||
SteamClient.RunCallbacks(); | ||
} | ||
#endif | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.