Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mao-test-h
Created March 4, 2020 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mao-test-h/69f2c2623e5cb944edbd5f052f3fc2b3 to your computer and use it in GitHub Desktop.
Save mao-test-h/69f2c2623e5cb944edbd5f052f3fc2b3 to your computer and use it in GitHub Desktop.
ProjectSettingsを.unitypackage形式で出力
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