This commit is contained in:
2025-06-16 15:14:23 +02:00
commit 074e590073
3174 changed files with 428263 additions and 0 deletions

View File

@ -0,0 +1,76 @@
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2022 Riley Labrecque
// Please see the included LICENSE.txt for additional information.
#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)
#define DISABLESTEAMWORKS
#endif
#if !DISABLESTEAMWORKS
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;
using Steamworks;
public class RedistCopy {
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
// We only want to do this on Steam supported platforms.
if ((target != BuildTarget.StandaloneWindows) && (target != BuildTarget.StandaloneWindows64) && (target != BuildTarget.StandaloneLinux64)) {
return;
}
CopyDebugInfo(target, pathToBuiltProject);
DeleteOldSteamApiDlls(target, pathToBuiltProject);
}
static void CopyDebugInfo(BuildTarget target, string pathToBuiltProject) {
string baseDir = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), Path.GetFileNameWithoutExtension(pathToBuiltProject) + "_Data");
string pluginsDir = Path.Combine(baseDir, "Plugins");
// Create if it doesn't exist yet
Directory.CreateDirectory(pluginsDir);
string[] DebugInfo = {
"Steamworks.NET created by Riley Labrecque",
"http://steamworks.github.io",
"",
"Steamworks.NET Version: " + Steamworks.Version.SteamworksNETVersion,
"Steamworks SDK Version: " + Steamworks.Version.SteamworksSDKVersion,
"Steam API DLL Version: " + Steamworks.Version.SteamAPIDLLVersion,
"Steam API DLL Size: " + Steamworks.Version.SteamAPIDLLSize,
"Steam API64 DLL Size: " + Steamworks.Version.SteamAPI64DLLSize,
""
};
File.WriteAllLines(Path.Combine(pluginsDir, "Steamworks.NET.txt"), DebugInfo);
}
static void DeleteOldSteamApiDlls(BuildTarget target, string pathToBuiltProject) {
string strDllPath = Path.Combine(pathToBuiltProject, "steam_api.dll");
if (File.Exists(strDllPath)) {
try {
File.Delete(strDllPath);
}
catch (System.Exception e) {
Debug.LogWarning($"[Steamworks.NET] Attempted to delete an old copy of 'steam_api.dll' in the following location: '{strDllPath}', but could not due to the following exception:");
Debug.LogException(e);
}
}
string strDll64Path = Path.Combine(pathToBuiltProject, "steam_api64.dll");
if (File.Exists(strDll64Path)) {
try {
File.Delete(strDll64Path);
}
catch (System.Exception e) {
Debug.LogWarning($"[Steamworks.NET] Attempted to delete an old copy of 'steam_api64.dll' in the following location: '{strDll64Path}', but could not due to the following exception:");
Debug.LogException(e);
}
}
}
}
#endif // !DISABLESTEAMWORKS

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 96dd4cffb1a008c4e8d429c9f4186034
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,70 @@
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2022 Riley Labrecque
// Please see the included LICENSE.txt for additional information.
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
// This copies various files into their required locations when Unity is launched to make installation a breeze.
[InitializeOnLoad]
public class RedistInstall {
static RedistInstall() {
WriteSteamAppIdTxtFile();
AddDefineSymbols();
CheckForOldDlls();
}
static void WriteSteamAppIdTxtFile() {
string strCWDPath = Directory.GetCurrentDirectory();
string strSteamAppIdPath = Path.Combine(strCWDPath, "steam_appid.txt");
// If the steam_appid.txt file already exists, then there's nothing to do.
if (File.Exists(strSteamAppIdPath)) {
return;
}
Debug.Log("[Steamworks.NET] 'steam_appid.txt' is not present in the project root. Writing...");
try {
StreamWriter appIdFile = File.CreateText(strSteamAppIdPath);
appIdFile.Write("480");
appIdFile.Close();
Debug.Log("[Steamworks.NET] Successfully copied 'steam_appid.txt' into the project root.");
}
catch (System.Exception e) {
Debug.LogWarning("[Steamworks.NET] Could not copy 'steam_appid.txt' into the project root. Please place 'steam_appid.txt' into the project root manually.");
Debug.LogException(e);
}
}
static void CheckForOldDlls() {
string strCwdPath = Directory.GetCurrentDirectory();
// Unfortunately we can't just delete these outright because Unity loads the dlls in the project root instantly and Windows won't let us delete them because they are in use.
string strDllPath = Path.Combine(strCwdPath, "steam_api.dll");
if (File.Exists(strDllPath)) {
Debug.LogError("[Steamworks.NET] Please delete the old version of 'steam_api.dll' in your project root before continuing.");
}
string strDll64Path = Path.Combine(strCwdPath, "steam_api64.dll");
if (File.Exists(strDll64Path)) {
Debug.LogError("[Steamworks.NET] Please delete the old version of 'steam_api64.dll' in your project root before continuing.");
}
}
static void AddDefineSymbols() {
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
HashSet<string> defines = new HashSet<string>(currentDefines.Split(';')) {
"STEAMWORKS_NET"
};
string newDefines = string.Join(";", defines);
if (newDefines != currentDefines) {
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, newDefines);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a716febd50f03244b98d9a5a0c6b36f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
{
"name": "com.rlabrecque.steamworks.net.editor",
"rootNamespace": "",
"references": [
"GUID:68bd7fdb68ef2684e982e8a9825b18a5"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be281b7992e9e1840851a78ba9db107c
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: