1
+ using System . IO ;
2
+ using Unity . Logging ;
3
+ using UnityEditor ;
4
+ using UnityEditor . Callbacks ;
5
+ using UnityEngine ;
6
+
7
+ public class PostBuildProcessor
8
+ {
9
+ /// <summary>
10
+ /// ビルド後SteamAssetsフォルダを生成する
11
+ /// </summary>
12
+ /// <param name="target"></param>
13
+ /// <param name="pathToBuiltProject"></param>
14
+ [ PostProcessBuild ( 1 ) ]
15
+ public static void OnPostprocessBuild ( BuildTarget target , string pathToBuiltProject )
16
+ {
17
+ // ビルドされたプロジェクトのディレクトリを取得
18
+ var buildDirectory = Path . GetDirectoryName ( pathToBuiltProject ) ;
19
+ if ( string . IsNullOrEmpty ( buildDirectory ) )
20
+ {
21
+ Log . Error ( "ビルドされたプロジェクトのディレクトリが取得できませんでした。" ) ;
22
+ return ;
23
+ }
24
+
25
+ var appName = Path . GetFileNameWithoutExtension ( pathToBuiltProject ) ;
26
+
27
+ var streamingAssetsPath = "" ;
28
+
29
+ if ( target == BuildTarget . StandaloneWindows || target == BuildTarget . StandaloneWindows64 ||
30
+ target == BuildTarget . StandaloneLinux64 )
31
+ {
32
+ // Windows および Linux の場合
33
+ streamingAssetsPath = Path . Combine ( buildDirectory , $ "{ appName } _Data", "StreamingAssets" ) ;
34
+ } else if ( target == BuildTarget . StandaloneOSX )
35
+ {
36
+ // macOS の場合
37
+ streamingAssetsPath = Path . Combine ( buildDirectory , $ "{ appName } .app", "Contents" , "Resources" , "Data" ,
38
+ "StreamingAssets" ) ;
39
+ } else
40
+ {
41
+ Debug . LogWarning ( "このプラットフォームはサポートされていません: " + target ) ;
42
+ return ;
43
+ }
44
+
45
+ // StreamingAssets フォルダが存在しない場合は作成
46
+ if ( ! Directory . Exists ( streamingAssetsPath ) )
47
+ {
48
+ Directory . CreateDirectory ( streamingAssetsPath ) ;
49
+ }
50
+
51
+ // Voice/Click フォルダを作成
52
+ var clickVoicePath = Path . Combine ( streamingAssetsPath , "Voice" , "Click" ) ;
53
+ if ( ! Directory . Exists ( clickVoicePath ) )
54
+ {
55
+ Directory . CreateDirectory ( clickVoicePath ) ;
56
+ }
57
+
58
+ // Voice/Drag フォルダを作成(または Voice/Hold フォルダ)
59
+ var dragVoicePath = Path . Combine ( streamingAssetsPath , "Voice" , "Drag" ) ;
60
+ if ( ! Directory . Exists ( dragVoicePath ) )
61
+ {
62
+ Directory . CreateDirectory ( dragVoicePath ) ;
63
+ }
64
+
65
+ // ログ出力(必要に応じて)
66
+ Log . Debug ( "ビルド後処理が完了しました。必要なフォルダを生成しました。" ) ;
67
+ }
68
+ }
0 commit comments