public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (Instance == null) { Debug.Log("Searching for CopyFilesPostProcessBuild."); Instance = EditorGUIUtility.Load(fileName) as CopyFilesPostProcessBuild; } if (Instance == null) { CreateInstance(); // Will be skipped, since there are no settings by now return; } if (!Instance.active) { Debug.LogWarning("Skipping CopyFilesPostProcessBuild since it is not active."); return; } if (!Instance.targets.Contains(target)) { Debug.LogWarning("Skipping CopyFilesPostProcessBuild, build target not in target list"); return; } var dataPath = pathToBuiltProject.Substring(0, pathToBuiltProject.Length - ".exe".Length) + "_Data"; Instance.CopyData(dataPath); }
private static void CreateInstance() { Instance = ScriptableObject.CreateInstance <CopyFilesPostProcessBuild>(); var assetRelativeFolderPath = "Assets/Editor Default Resources/"; // Create folders if not set Directory.CreateDirectory(Path.GetFullPath(assetRelativeFolderPath)); var assetRelativeFilePath = Path.Combine(assetRelativeFolderPath, fileName); AssetDatabase.CreateAsset(Instance, assetRelativeFilePath); }