ビルド方法
OpenFitterUnityUIのビルド、パッケージング、配布方法について説明します。
前提条件
ビルドを実行する前に、以下がインストールされていることを確認してください:
- Node.js 18以降
- npm (Node.jsに含まれます)
- Unity 2022.3以降
- Git (バージョン管理用)
開発環境のセットアップ
1. リポジトリのクローン
git clone https://github.com/Mushus/OpenFitterUnityUI.git
cd OpenFitter2. Node.js依存関係のインストール
npm installこれにより、以下がインストールされます:
- VitePress(ドキュメント生成)
- TypeScript(ビルドスクリプト)
- ts-node(TypeScript実行環境)
- その他の開発依存関係
3. Unityでプロジェクトを開く
- Unity Hubを起動
- 「開く」をクリック
- クローンしたリポジトリのディレクトリを選択
- Unity 2022.3以降で開く
Unityパッケージのビルド
npmスクリプトを使用
最も簡単な方法は、npmスクリプトを使用することです:
npm run create-packageこのコマンドは:
Assets/OpenFitter/ディレクトリをスキャン- 必要なファイルを収集
OpenFitter.unitypackageをプロジェクトルートに生成
ビルドスクリプトの詳細
scripts/create-unitypackage.tsは以下の処理を行います:
ファイルの収集:
Assets/OpenFitter/配下のすべてのファイル.metaファイルを含む
除外されるファイル:
.DS_Store(macOS).git関連ファイル- 一時ファイル
パッケージの生成:
- Unity の
ExportPackageAPIを使用 - GUIDを保持してインポート時の参照を維持
- Unity の
手動ビルド(Unity内)
Unity Editor内から手動でパッケージを作成することもできます:
- Unity Editorでプロジェクトを開く
- メニューから
Assets > Export Package...を選択 Assets/OpenFitterフォルダを選択Include dependenciesのチェックを外す(すべて自己完結しているため)Export...をクリック- 保存場所とファイル名を指定
Saveをクリック
ドキュメントのビルド
開発サーバーの起動
ドキュメントをローカルでプレビューする:
npm run docs:devブラウザで http://localhost:5173 を開いてプレビューできます。
本番ビルド
静的サイトをビルドする:
npm run docs:buildビルド結果はdocs/.vitepress/dist/に生成されます。
ドキュメントのデプロイ
GitHub Pagesへのデプロイ
- ビルド:
npm run docs:build- dist/をGitHub Pagesにデプロイ:
cd docs/.vitepress/dist
git init
git add -A
git commit -m "Deploy documentation"
git push -f git@github.com:yourusername/OpenFitter.git master:gh-pages- GitHub設定:
- リポジトリの Settings > Pages
- Source:
gh-pagesブランチを選択
Netlifyへのデプロイ
- Netlifyアカウントにログイン
- 「New site from Git」をクリック
- リポジトリを接続
- ビルド設定:
- Build command:
npm run docs:build - Publish directory:
docs/.vitepress/dist
- Build command:
テストの実行
ローカリゼーション検証
すべてのローカリゼーション文字列を検証:
npm run check-l10nこのスクリプトは以下をチェックします:
- すべての言語で同じキーが定義されているか
- 未使用のキーがないか
- 欠落しているキーがないか
Unity Test Runner
Unity Editor内でテストを実行:
- Unity Editorを開く
Window > General > Test Runnerを選択EditModeタブを選択Run Allをクリック
リリースプロセス
1. バージョンの更新
関連ファイルのバージョン番号を更新:
package.jsonのversionフィールドREADME.mdのバージョン参照(必要に応じて)- リリースノートの作成
2. テストの実行
すべてのテストが通ることを確認:
# ローカリゼーション検証
npm run check-l10n
# Unity Test Runnerでテスト実行(Unity Editor内で)3. Unityパッケージのビルド
npm run create-package4. ドキュメントのビルド(オプション)
npm run docs:build5. GitHubリリースの作成
- Gitタグの作成:
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0- GitHubでリリースを作成:
- GitHubのリポジトリページに移動
Releases>Draft a new releaseをクリック- タグを選択(v1.0.0)
- リリースタイトルとノートを記入
OpenFitter.unitypackageをアセットとしてアップロードPublish releaseをクリック
6. ドキュメントのデプロイ(オプション)
# GitHub Pagesへデプロイ
cd docs/.vitepress/dist
git init
git add -A
git commit -m "Deploy v1.0.0 documentation"
git push -f git@github.com:yourusername/OpenFitter.git master:gh-pages継続的インテグレーション(CI)
GitHub Actionsの設定例
.github/workflows/build.ymlを作成:
name: Build and Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Run localization validation
run: npm run check-l10n
- name: Build documentation
run: npm run docs:build
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build Unity package
run: npm run create-package
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: OpenFitter.unitypackage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}トラブルシューティング
ビルドエラー
問題: npm run create-packageが失敗する
解決方法:
- Node.jsのバージョンを確認(18以降が必要)
node_modules/を削除してnpm installを再実行- TypeScriptのエラーを確認して修正
Unity パッケージのインポートエラー
問題: 生成したパッケージがUnityでインポートできない
解決方法:
- GUIDが正しく保持されているか確認
.metaファイルがすべて含まれているか確認- Unityのバージョンが2022.3以降であることを確認
ドキュメントビルドエラー
問題: npm run docs:buildが失敗する
解決方法:
- Markdownファイルの構文エラーを確認
- VitePressの設定ファイル(
.vitepress/config.ts)を確認 - 不正なリンクがないか確認
ベストプラクティス
バージョン管理
- セマンティックバージョニング を使用(major.minor.patch)
- Major: 破壊的な変更
- Minor: 新機能の追加(後方互換性あり)
- Patch: バグ修正
リリースノート
各リリースには詳細なリリースノートを含める:
## v1.0.0 (2024-01-01)
### 新機能
- 自動環境セットアップ機能を追加
- ブレンドシェイプ管理機能を追加
### 改善
- フィッティング速度を30%向上
- UIのレスポンスを改善
### バグ修正
- 大きなメッシュでのクラッシュを修正
- ブレンドシェイプが保持されない問題を修正
### 既知の問題
- 非常に複雑なアーマチュアでパフォーマンスが低下する可能性ビルド前チェックリスト
- [ ] すべてのテストが通る
- [ ] ローカリゼーション検証が通る
- [ ] バージョン番号が更新されている
- [ ] リリースノートが作成されている
- [ ] ドキュメントが最新である
- [ ] 既知の問題が文書化されている
まとめ
OpenFitterUnityUIのビルドプロセスは以下のステップで構成されています:
- 開発環境のセットアップ: Node.jsとUnityのインストール
- Unityパッケージのビルド: npmスクリプトまたは手動ビルド
- ドキュメントのビルド: VitePressで静的サイトを生成
- テストの実行: ローカリゼーション検証とユニットテスト
- リリース: GitHubリリースの作成とパッケージのアップロード
自動化されたビルドスクリプトにより、一貫性のある品質の高いリリースを作成できます。
English
Building
This document explains how to build, package, and distribute OpenFitter.
Prerequisites
Before building, ensure the following are installed:
- Node.js 18 or later
- npm (included with Node.js)
- Unity 2022.3 or later
- Git (for version control)
Development Environment Setup
1. Clone the Repository
git clone https://github.com/Mushus/OpenFitterUnityUI.git
cd OpenFitter2. Install Node.js Dependencies
npm installThis installs:
- VitePress (documentation generation)
- TypeScript (build scripts)
- ts-node (TypeScript runtime)
- Other development dependencies
3. Open Project in Unity
- Launch Unity Hub
- Click "Open"
- Select the cloned repository directory
- Open with Unity 2022.3 or later
Building Unity Package
Using npm Script
The easiest method is using the npm script:
npm run create-packageThis command:
- Scans the
Assets/OpenFitter/directory - Collects necessary files
- Generates
OpenFitter.unitypackagein the project root
Build Script Details
scripts/create-unitypackage.ts performs the following:
File Collection:
- All files under
Assets/OpenFitter/ - Including
.metafiles
- All files under
Excluded Files:
.DS_Store(macOS).gitrelated files- Temporary files
Package Generation:
- Uses Unity's
ExportPackageAPI - Preserves GUIDs to maintain references on import
- Uses Unity's
Manual Build (In Unity)
You can also manually create a package from within Unity Editor:
- Open project in Unity Editor
- Select
Assets > Export Package...from menu - Select the
Assets/OpenFitterfolder - Uncheck
Include dependencies(everything is self-contained) - Click
Export... - Specify save location and filename
- Click
Save
Building Documentation
Start Development Server
Preview documentation locally:
npm run docs:devOpen http://localhost:5173 in browser to preview.
Production Build
Build static site:
npm run docs:buildBuild output is generated in docs/.vitepress/dist/.
Deploying Documentation
Deploy to GitHub Pages
- Build:
npm run docs:build- Deploy dist/ to GitHub Pages:
cd docs/.vitepress/dist
git init
git add -A
git commit -m "Deploy documentation"
git push -f git@github.com:yourusername/OpenFitter.git master:gh-pages- GitHub Settings:
- Repository Settings > Pages
- Source: Select
gh-pagesbranch
Deploy to Netlify
- Log in to Netlify account
- Click "New site from Git"
- Connect repository
- Build settings:
- Build command:
npm run docs:build - Publish directory:
docs/.vitepress/dist
- Build command:
Running Tests
Localization Validation
Validate all localization strings:
npm run check-l10nThis script checks:
- Same keys are defined in all languages
- No unused keys
- No missing keys
Unity Test Runner
Run tests in Unity Editor:
- Open Unity Editor
- Select
Window > General > Test Runner - Select
EditModetab - Click
Run All
Release Process
1. Update Version
Update version numbers in related files:
versionfield inpackage.json- Version references in
README.md(if needed) - Create release notes
2. Run Tests
Ensure all tests pass:
# Localization validation
npm run check-l10n
# Run tests in Unity Test Runner (in Unity Editor)3. Build Unity Package
npm run create-package4. Build Documentation (Optional)
npm run docs:build5. Create GitHub Release
- Create Git Tag:
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0- Create Release on GitHub:
- Go to repository page on GitHub
- Click
Releases>Draft a new release - Select tag (v1.0.0)
- Fill in release title and notes
- Upload
OpenFitter.unitypackageas asset - Click
Publish release
6. Deploy Documentation (Optional)
# Deploy to GitHub Pages
cd docs/.vitepress/dist
git init
git add -A
git commit -m "Deploy v1.0.0 documentation"
git push -f git@github.com:yourusername/OpenFitter.git master:gh-pagesContinuous Integration (CI)
GitHub Actions Example
Create .github/workflows/build.yml:
name: Build and Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Run localization validation
run: npm run check-l10n
- name: Build documentation
run: npm run docs:build
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build Unity package
run: npm run create-package
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: OpenFitter.unitypackage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Troubleshooting
Build Errors
Problem: npm run create-package fails
Solution:
- Check Node.js version (18 or later required)
- Delete
node_modules/and runnpm installagain - Check and fix TypeScript errors
Unity Package Import Errors
Problem: Generated package cannot be imported in Unity
Solution:
- Verify GUIDs are correctly preserved
- Check that all
.metafiles are included - Ensure Unity version is 2022.3 or later
Documentation Build Errors
Problem: npm run docs:build fails
Solution:
- Check Markdown file syntax errors
- Check VitePress configuration file (
.vitepress/config.ts) - Check for invalid links
Best Practices
Versioning
- Use Semantic Versioning (major.minor.patch)
- Major: Breaking changes
- Minor: New features (backward compatible)
- Patch: Bug fixes
Release Notes
Include detailed release notes for each release:
## v1.0.0 (2024-01-01)
### New Features
- Added automatic environment setup
- Added blendshape management
### Improvements
- Improved fitting speed by 30%
- Improved UI responsiveness
### Bug Fixes
- Fixed crash with large meshes
- Fixed blendshape preservation issue
### Known Issues
- Performance may degrade with very complex armaturesPre-Build Checklist
- [ ] All tests pass
- [ ] Localization validation passes
- [ ] Version number updated
- [ ] Release notes created
- [ ] Documentation is up-to-date
- [ ] Known issues are documented
Summary
OpenFitter's build process consists of the following steps:
- Development Environment Setup: Install Node.js and Unity
- Build Unity Package: npm script or manual build
- Build Documentation: Generate static site with VitePress
- Run Tests: Localization validation and unit tests
- Release: Create GitHub release and upload package
Automated build scripts enable consistent, high-quality releases.