Created
March 4, 2020 12:52
-
-
Save mao-test-h/69f2c2623e5cb944edbd5f052f3fc2b3 to your computer and use it in GitHub Desktop.
ProjectSettingsを.unitypackage形式で出力
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
using System.Linq; | |
namespace EditorUtility | |
{ | |
static class ExportProjectSettings | |
{ | |
/// <summary> | |
/// ProjectSettingsを.unitypackage形式で出力 | |
/// </summary> | |
[MenuItem("Editor Utility/Export ProjectSettings")] | |
static void Export() | |
{ | |
const string ExportPath = "ExportedProjectSettings.unitypackage"; | |
// "(Project Directory)/ProjectSettings"のパスを取得 | |
var dataPath = Application.dataPath; | |
var lastSlashIndex = dataPath.LastIndexOf("/", StringComparison.Ordinal); | |
dataPath = dataPath.Substring(0, lastSlashIndex + 1); | |
dataPath += "ProjectSettings/"; | |
// ProjectSettings以下にあるファイルをかき集める | |
var directoryInfo = new DirectoryInfo(dataPath); | |
var fileInfos = directoryInfo.GetFiles("*", SearchOption.AllDirectories); | |
var files = fileInfos.Select(_ => "ProjectSettings/" + _.Name).ToArray(); | |
// 出力 | |
AssetDatabase.ExportPackage(files, ExportPath, | |
ExportPackageOptions.Interactive | ExportPackageOptions.Recurse); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment