Skip to content

Instantly share code, notes, and snippets.

@TakaakiIchijo
Last active September 7, 2017 10:10
Show Gist options
  • Save TakaakiIchijo/7bc4c5ade4d89deb5ebb1554bb8cde83 to your computer and use it in GitHub Desktop.
Save TakaakiIchijo/7bc4c5ade4d89deb5ebb1554bb8cde83 to your computer and use it in GitHub Desktop.
SteamWorks.Netを使ってSteamAPIを組み込むとき、テスト用のsteam_appid.txtをビルド結果のフォルダに配置する
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;
using System.Linq;
/// <summary>
/// SteamWorks.Netを使ってSteamAPIを組み込むとき、テスト用のsteam_appid.txtをビルド結果のフォルダに配置する//
/// Unity5.2.4で動作確認//
/// </summary>
public class PostBuildProcess
{
static readonly string STEAM_APPIDFILENAME = "steam_appid.txt";
static readonly string STEAM_APPIDFILEPATH = "Plugins/Steamworks.NET/redist/";
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
switch (buildTarget)
{
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
case BuildTarget.StandaloneOSXUniversal:
case BuildTarget.StandaloneLinux:
case BuildTarget.StandaloneLinux64:
case BuildTarget.StandaloneLinuxUniversal:
CopyAppIdFile(path);
break;
}
}
static void CopyAppIdFile(string path)
{
//.Net3.5だと3つ以上要素のCombineが使えないでござる//
string copyFrom = new[] { Application.dataPath, STEAM_APPIDFILEPATH, STEAM_APPIDFILENAME }.Aggregate(Path.Combine);
string copyTo = Path.Combine(Path.GetDirectoryName(path), STEAM_APPIDFILENAME);
File.Copy(copyFrom, copyTo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment