Commit d099f4bd authored by Ben Huber's avatar Ben Huber
Browse files

first steam api test

parent 169706ed
fileFormatVersion: 2
guid: 425fbe90d273aede6b82fe5ba0237073
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b13a3116b43acfdda9c8c91114b750f1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2019 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
// Add 'DISABLEREDISTCOPY' to your custom platform defines to disable automatic copying!
#if UNITY_5_3_OR_NEWER
#define DISABLEREDISTCOPY
#endif // UNITY_5_3_OR_NEWER
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using Steamworks;
using System.IO;
public class RedistCopy {
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
string baseDir;
switch(target)
{
case BuildTarget.StandaloneWindows:
{
baseDir = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), Path.GetFileNameWithoutExtension(pathToBuiltProject) + "_Data");
CopyFile("steam_api.dll", "steam_api.dll", "Assets/Plugins/x86", pathToBuiltProject);
break;
}
case BuildTarget.StandaloneWindows64:
{
baseDir = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), Path.GetFileNameWithoutExtension(pathToBuiltProject) + "_Data");
CopyFile("steam_api64.dll", "steam_api64.dll", "Assets/Plugins/x86_64", pathToBuiltProject);
break;
}
#if !UNITY_2019_2_OR_NEWER
case BuildTarget.StandaloneLinux:
case BuildTarget.StandaloneLinuxUniversal:
#endif // !UNITY_2019_2_OR_NEWER
case BuildTarget.StandaloneLinux64:
{
baseDir = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), Path.GetFileNameWithoutExtension(pathToBuiltProject) + "_Data");
break;
}
#if UNITY_2017_3_OR_NEWER
case BuildTarget.StandaloneOSX:
#else
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
case BuildTarget.StandaloneOSXUniversal:
#endif // UNITY_2017_3_OR_NEWER
{
baseDir = Path.Combine(Path.Combine(Path.GetDirectoryName(pathToBuiltProject), Path.GetFileNameWithoutExtension(pathToBuiltProject) + ".app"), "Contents");
break;
}
default:
{
return;
}
}
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 CopyFile(string filename, string outputfilename, string pathToFile, string pathToBuiltProject) {
#if !DISABLEREDISTCOPY
string strCWD = Directory.GetCurrentDirectory();
string strSource = Path.Combine(Path.Combine(strCWD, pathToFile), filename);
string strFileDest = Path.Combine(Path.GetDirectoryName(pathToBuiltProject), outputfilename);
if (!File.Exists(strSource)) {
Debug.LogWarning(string.Format("[Steamworks.NET] Could not copy {0} into the project root. {0} could not be found in '{1}'. Place {0} from the redist into the project root manually.", filename, pathToFile));
return;
}
if (File.Exists(strFileDest)) {
if (File.GetLastWriteTime(strSource) == File.GetLastWriteTime(strFileDest)) {
FileInfo fInfo = new FileInfo(strSource);
FileInfo fInfo2 = new FileInfo(strFileDest);
if (fInfo.Length == fInfo2.Length) {
return;
}
}
}
File.Copy(strSource, strFileDest, true);
File.SetAttributes(strFileDest, File.GetAttributes(strFileDest) & ~FileAttributes.ReadOnly);
if (!File.Exists(strFileDest)) {
Debug.LogWarning(string.Format("[Steamworks.NET] Could not copy {0} into the built project. File.Copy() Failed. Place {0} from the redist folder into the output dir manually.", filename));
}
#endif // !DISABLEREDISTCOPY
}
}
#endif // !DISABLESTEAMWORKS
fileFormatVersion: 2
guid: ac3a1e01438079543bce36a2bbb5121a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2019 Riley Labrecque
// Please see the included LICENSE.txt for additional information.
// Uncomment this out or add it to your custom platform defines to disable checking the plugin platform settings.
//#define DISABLEPLATFORMSETTINGS
using UnityEngine;
using UnityEditor;
using System.IO;
// This copys various files into their required locations when Unity is launched to make installation a breeze.
[InitializeOnLoad]
public class RedistInstall {
static RedistInstall() {
CopyFile("Assets/Plugins/Steamworks.NET/redist", "steam_appid.txt", false);
// We only need to copy the dll into the project root on <= Unity 5.0
#if UNITY_EDITOR_WIN && (UNITY_4_7 || UNITY_5_0)
#if UNITY_EDITOR_64
CopyFile("Assets/Plugins/x86_64", "steam_api64.dll", true);
#else
CopyFile("Assets/Plugins/x86", "steam_api.dll", true);
#endif
#endif
#if UNITY_5 || UNITY_2017
#if !DISABLEPLATFORMSETTINGS
SetPlatformSettings();
#endif
#endif
}
static void CopyFile(string path, string filename, bool bCheckDifference) {
string strCWD = Directory.GetCurrentDirectory();
string strSource = Path.Combine(Path.Combine(strCWD, path), filename);
string strDest = Path.Combine(strCWD, filename);
if (!File.Exists(strSource)) {
Debug.LogWarning(string.Format("[Steamworks.NET] Could not copy {0} into the project root. {0} could not be found in '{1}'. Place {0} from the Steamworks SDK in the project root manually.", filename, Path.Combine(strCWD, path)));
return;
}
if (File.Exists(strDest)) {
if (!bCheckDifference)
return;
if (File.GetLastWriteTime(strSource) == File.GetLastWriteTime(strDest)) {
FileInfo fInfo = new FileInfo(strSource);
FileInfo fInfo2 = new FileInfo(strDest);
if (fInfo.Length == fInfo2.Length) {
return;
}
}
Debug.Log(string.Format("[Steamworks.NET] {0} in the project root differs from the Steamworks.NET redistributable. Updating.... Please relaunch Unity.", filename));
}
else {
Debug.Log(string.Format("[Steamworks.NET] {0} is not present in the project root. Copying...", filename));
}
File.Copy(strSource, strDest, true);
File.SetAttributes(strDest, File.GetAttributes(strDest) & ~FileAttributes.ReadOnly);
if (File.Exists(strDest)) {
Debug.Log(string.Format("[Steamworks.NET] Successfully copied {0} into the project root. Please relaunch Unity.", filename));
}
else {
Debug.LogWarning(string.Format("[Steamworks.NET] Could not copy {0} into the project root. File.Copy() Failed. Please copy {0} into the project root manually.", Path.Combine(path, filename)));
}
}
#if UNITY_5 || UNITY_2017 || UNITY_2017_1_OR_NEWER
static void SetPlatformSettings() {
foreach(var plugin in PluginImporter.GetAllImporters()) {
// Skip any null plugins, why is this a thing?!
if(plugin == null) {
continue;
}
// Skip any absolute paths, as they are only built in plugins.
if(Path.IsPathRooted(plugin.assetPath)) {
continue;
}
bool didUpdate = false;
string filename = Path.GetFileName(plugin.assetPath);
switch(filename) {
case "steam_api.bundle":
didUpdate |= ResetPluginSettings(plugin, "AnyCPU", "OSX");
didUpdate |= SetCompatibleWithOSX(plugin);
break;
case "libsteam_api.so":
if(plugin.assetPath.Contains("x86_64")) {
didUpdate |= ResetPluginSettings(plugin, "x86_64", "Linux");
didUpdate |= SetCompatibleWithLinux(plugin, BuildTarget.StandaloneLinux64);
}
#if !UNITY_2019_2_OR_NEWER
else {
didUpdate |= ResetPluginSettings(plugin, "x86", "Linux");
didUpdate |= SetCompatibleWithLinux(plugin, BuildTarget.StandaloneLinux);
}
#endif
break;
case "steam_api.dll":
case "steam_api64.dll":
if (plugin.assetPath.Contains("x86_64")) {
didUpdate |= ResetPluginSettings(plugin, "x86_64", "Windows");
#if UNITY_5_3_OR_NEWER
didUpdate |= SetCompatibleWithWindows(plugin, BuildTarget.StandaloneWindows64);
#endif
}
else {
didUpdate |= ResetPluginSettings(plugin, "x86", "Windows");
#if UNITY_5_3_OR_NEWER
didUpdate |= SetCompatibleWithWindows(plugin, BuildTarget.StandaloneWindows);
#endif
}
#if !UNITY_5_3_OR_NEWER
// We do this because Unity had a bug where dependent dll's didn't get loaded from the Plugins
// folder in actual builds. But they do in the editor now! So close... Unity bug number: 728945
// So ultimately we must keep using RedistCopy to copy steam_api[64].dll next to the .exe on builds, and
// we don't want a useless duplicate version of the dll ending up in the Plugins folder.
// This was fixed in Unity 5.3!
didUpdate |= SetCompatibleWithEditor(plugin);
#endif
break;
}
if (didUpdate) {
plugin.SaveAndReimport();
}
}
}
static bool ResetPluginSettings(PluginImporter plugin, string CPU, string OS) {
bool didUpdate = false;
if (plugin.GetCompatibleWithAnyPlatform() != false) {
plugin.SetCompatibleWithAnyPlatform(false);
didUpdate = true;
}
if (plugin.GetCompatibleWithEditor() != true) {
plugin.SetCompatibleWithEditor(true);
didUpdate = true;
}
if (plugin.GetEditorData("CPU") != CPU) {
plugin.SetEditorData("CPU", CPU);
didUpdate = true;
}
if (plugin.GetEditorData("OS") != OS) {
plugin.SetEditorData("OS", OS);
didUpdate = true;
}
return didUpdate;
}
static bool SetCompatibleWithOSX(PluginImporter plugin) {
bool didUpdate = false;
#if UNITY_2017_3_OR_NEWER
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSX, true);
#else
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel, true);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel64, true);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXUniversal, true);
#endif
#if !UNITY_2019_2_OR_NEWER
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinuxUniversal, false);
#endif
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux64, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows64, false);
return didUpdate;
}
static bool SetCompatibleWithLinux(PluginImporter plugin, BuildTarget platform) {
bool didUpdate = false;
#if !UNITY_2019_2_OR_NEWER
if (platform == BuildTarget.StandaloneLinux) {
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux, true);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux64, false);
}
else {
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux64, true);
}
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinuxUniversal, true);
#else
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux64, true);
#endif
#if UNITY_2017_3_OR_NEWER
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSX, false);
#else
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel64, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXUniversal, false);
#endif
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows64, false);
return didUpdate;
}
static bool SetCompatibleWithWindows(PluginImporter plugin, BuildTarget platform) {
bool didUpdate = false;
if (platform == BuildTarget.StandaloneWindows) {
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows, true);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows64, false);
}
else {
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows64, true);
}
#if !UNITY_2019_2_OR_NEWER
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinuxUniversal, false);
#endif
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux64, false);
#if UNITY_2017_3_OR_NEWER
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSX, false);
#else
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel64, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXUniversal, false);
#endif
return didUpdate;
}
static bool SetCompatibleWithEditor(PluginImporter plugin) {
bool didUpdate = false;
#if !UNITY_2019_2_OR_NEWER
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinuxUniversal, false);
#endif
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneLinux64, false);
#if UNITY_2017_3_OR_NEWER
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSX, false);
#else
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXIntel64, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneOSXUniversal, false);
#endif
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows, false);
didUpdate |= SetCompatibleWithPlatform(plugin, BuildTarget.StandaloneWindows64, false);
return didUpdate;
}
static bool SetCompatibleWithPlatform(PluginImporter plugin, BuildTarget platform, bool enable) {
if (plugin.GetCompatibleWithPlatform(platform) == enable) {
return false;
}
plugin.SetCompatibleWithPlatform(platform, enable);
return true;
}
#endif // UNITY_5 || UNITY_2017 || UNITY_2017_1_OR_NEWER
}
fileFormatVersion: 2
guid: 6e61c13de23373d47bb6c244a441b451
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -41,6 +41,7 @@ Shader "PpS/Antigender"
// scaling to convert screen space to view space
float3 _ScreenToViewScaling;
float _ScreenDimming;
struct appdata{
float4 vertex : POSITION;
......@@ -131,7 +132,7 @@ Shader "PpS/Antigender"
sourceColor.a = 1;
float4 color = lerp(sourceColor, _OutlineColor, outline);
if (_Invert < 0.5) {
color.rgb = float3(1,1,1) - color.rgb;
color.rgb = _ScreenDimming * (float3(1,1,1) - color.rgb);
}
//color.rgb = (normal+1)/2;
//color.rgb = (calcNormal(i.uv)+1)/2;
......
......@@ -47,6 +47,8 @@ public class EdgeDetect : MonoBehaviour {
public static float resolutionFactor = 1f;
float previousResolutionFactor = 0f;
public float dim;
void LateUpdate() {
if (cam == null && width != -1) {
......@@ -115,6 +117,7 @@ public class EdgeDetect : MonoBehaviour {
prevOutlineColor = outlineColor;
}
}
Shader.SetGlobalFloat("_ScreenDimming", dim);
}
void OnRenderImage(RenderTexture source, RenderTexture destination) {
......
fileFormatVersion: 2
guid: 1c802f3ef090c2bdca2b52e2adb1eca1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6cdf71a6086a890088bdc42057bf1aa9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2019 Riley Labrecque
// Please see the included LICENSE.txt for additional information.
// This file is automatically generated.
// Changes to this file will be reverted when you update Steamworks.NET
#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)
#define DISABLESTEAMWORKS
#endif
#if !DISABLESTEAMWORKS
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6
#error Unsupported Unity platform. Steamworks.NET requires Unity 4.7 or higher.
#elif UNITY_4_7 || UNITY_5 || UNITY_2017 || UNITY_2017_1_OR_NEWER
#if UNITY_EDITOR_WIN || (UNITY_STANDALONE_WIN && !UNITY_EDITOR)
#define WINDOWS_BUILD
#endif
#elif STEAMWORKS_WIN
#define WINDOWS_BUILD
#elif STEAMWORKS_LIN_OSX
// So that we don't enter the else block below.
#else
#error You need to define STEAMWORKS_WIN, or STEAMWORKS_LIN_OSX. Refer to the readme for more details.
#endif
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Steamworks {
public static class CallbackDispatcher {
// We catch exceptions inside callbacks and reroute them here.
// For some reason throwing an exception causes RunCallbacks() to break otherwise.
// If you have a custom ExceptionHandler in your engine you can register it here manually until we get something more elegant hooked up.
public static void ExceptionHandler(Exception e) {
#if UNITY_STANDALONE
UnityEngine.Debug.LogException(e);
#elif STEAMWORKS_WIN || STEAMWORKS_LIN_OSX
Console.WriteLine(e.Message);
#endif
}
private static Dictionary<int, List<Callback>> m_registeredCallbacks = new Dictionary<int, List<Callback>>();
private static Dictionary<int, List<Callback>> m_registeredGameServerCallbacks = new Dictionary<int, List<Callback>>();
private static Dictionary<ulong, List<CallResult>> m_registeredCallResults = new Dictionary<ulong, List<CallResult>>();
private static object m_sync = new object();
private static IntPtr m_pCallbackMsg;
private static int m_initCount;
public static bool IsInitialized {
get { return m_initCount > 0; }
}
internal static void Initialize() {
lock (m_sync) {
if (m_initCount == 0) {
NativeMethods.SteamAPI_ManualDispatch_Init();
m_pCallbackMsg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CallbackMsg_t)));
}
++m_initCount;
}
}
internal static void Shutdown() {
lock (m_sync) {
--m_initCount;
if (m_initCount == 0) {
UnregisterAll();
Marshal.FreeHGlobal(m_pCallbackMsg);
m_pCallbackMsg = IntPtr.Zero;
}
}
}
internal static void Register(Callback cb) {
int iCallback = CallbackIdentities.GetCallbackIdentity(cb.GetCallbackType());
var callbacksRegistry = cb.IsGameServer ? m_registeredGameServerCallbacks : m_registeredCallbacks;
lock (m_sync) {
List<Callback> callbacksList;
if (!callbacksRegistry.TryGetValue(iCallback, out callbacksList)) {
callbacksList = new List<Callback>();
callbacksRegistry.Add(iCallback, callbacksList);
}
callbacksList.Add(cb);
}
}
internal static void Register(SteamAPICall_t asyncCall, CallResult cr) {
lock (m_sync) {
List<CallResult> callResultsList;