<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>プログラミング | アリッシアの朝</title>
	<atom:link href="https://alicia-ing.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>https://alicia-ing.com</link>
	<description></description>
	<lastBuildDate>Sun, 16 Nov 2025 22:00:00 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia-32x32.webp</url>
	<title>プログラミング | アリッシアの朝</title>
	<link>https://alicia-ing.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Unity】ゲームビルドやり方｜画面サイズ・WebGL設定</title>
		<link>https://alicia-ing.com/programming/build-setting/</link>
					<comments>https://alicia-ing.com/programming/build-setting/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 16 Nov 2025 22:00:00 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[プログラミング]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8790</guid>

					<description><![CDATA[自作したゲームを販売する上で、作品のexe化（ビルド）しなければいけません。本記事では、ビルドする方法を分かりやすく解説します。 Unityのビルドとは？ Unityにおける「ビルド」とは、開発中のゲームプロジェクトを実 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>自作したゲームを販売する上で、作品のexe化（ビルド）しなければいけません。<br>本記事では、ビルドする方法を分かりやすく解説します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Unityで開発したゲームを出品したい人</li>



<li>ビルドのやり方を知りたい人</li>



<li>WebGLの形式でビルドしたい人</li>



<li>ビルドしたら画面サイズがおかしくなった人</li>
</ul>
</div></div>



<h2 class="wp-block-heading">Unityのビルドとは？</h2>



<p>Unityにおける「ビルド」とは、開発中の<strong>ゲームプロジェクトを実行可能なアプリケーションやデータに変換する作業</strong>のことです。エディタ上で動かしていたゲームを、Windows/Mac用の実行ファイルやWebブラウザで動作するデータ（WebGL）などに出力し、<strong>他のユーザーがプレイできる</strong>形にします。</p>



<p>Unityエディタでの再生は<strong>開発者ローカルのテスト</strong>に過ぎず、完成したゲームを配布・公開するにはビルドして所定のプラットフォーム用ファイルを用意する必要があります。ビルドを行うことで、初めてUnityをインストールしていないPCでもゲームを起動できたり、Web上に公開して遊んでもらうことが可能になります。</p>



<p>ビルドの結果、例えばWindowsなら「.exe実行ファイルとデータフォルダ」、WebGLなら「index.htmlとUnityの生成したライブラリファイル群」など、プラットフォームごとに必要なファイル一式が出力されます。<strong>これらを配布・サーバーアップロードすることでユーザーがゲームをプレイできる</strong>ようになります。</p>



<h3 class="wp-block-heading">Unityでゲームをビルドする基本手順</h3>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-memo block-box has-border-color has-yellow-border-color">
<p>本記事は、<strong>Unity6</strong>でのビルド方法を紹介しています。<br>バージョンが異なってもほとんど操作は同じです。</p>
</div>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2025/11/Buildwindow.webp" alt="" class="wp-image-8800" srcset="https://alicia-ing.com/wp-content/uploads/2025/11/Buildwindow.webp 1200w, https://alicia-ing.com/wp-content/uploads/2025/11/Buildwindow-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/11/Buildwindow-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/11/Buildwindow-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>基本的なビルド手順は<strong>「シーンの設定 → プラットフォームの選択 → ビルドの実行」</strong>という流れになります。</p>



<div class="wp-block-cocoon-blocks-timeline timeline-box cf block-box has-point-color has-light-blue-point-color not-nested-style cocoon-block-timeline" style="--cocoon-custom-point-color:#2ca9e1"><div class="timeline-title">ビルド手順</div><ul class="timeline">
<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step1</div><div class="timeline-item-content cf"><div class="timeline-item-title">ゲームで使うシーンを追加</div><div class="timeline-item-snippet">
<p></p>
</div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step2</div><div class="timeline-item-content cf"><div class="timeline-item-title">プラットフォーム（Windows,Mac,WebGLなど）を選ぶ</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step3</div><div class="timeline-item-content cf"><div class="timeline-item-title">ビルド</div><div class="timeline-item-snippet"></div></div></li>
</ul></div>



<p><a target="_self" href="https://docs.unity3d.com/ja/2018.4/Manual/PublishingBuilds.html">>>公式ページのビルド方法</a></p>



<h3 class="wp-block-heading">シーン登録</h3>



<p>初めにビルドに含めるシーンを指定します。Unityメニューから <strong>File > Build Profiles </strong>を開き、Scenes Listに現在のシーンを追加します（「Open Scene List」>「Add Open Scenes」ボタン）。複数シーンがある場合、すべて追加しましょう。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2025/11/BuildSetting.webp" alt="" class="wp-image-8799" srcset="https://alicia-ing.com/wp-content/uploads/2025/11/BuildSetting.webp 1200w, https://alicia-ing.com/wp-content/uploads/2025/11/BuildSetting-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/11/BuildSetting-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/11/BuildSetting-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>ボタンを押しても何も反応がない場合は、シーンが読み込めていません。<br>そこで、<strong>現在のシーンを変更してから「Add Open Scenes」ボタンを押す</strong>と認識できます。</p>



<p><strong>シーンリスト番号「0」が、ゲーム起動時に最初にロードされるシーン</strong>になります。一般的にタイトルやメインメニューのシーンを先頭に置きます。ドラッグ＆ドロップで順序を並び替え、一番最初に実行したいシーンがトップに来るよう設定します。</p>



<p><strong>チェックボックスでビルド対象に含めるか除外するかを制御</strong>できます。不要なシーンはチェックを外すことでビルドから除外可能ですが、基本的にはリストに追加したシーンはすべて有効にしておきます。Scene移動はスクリプトで制御しないと遷移できないですが、チェックボックスで除外しておく方が無難です。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>実用的なシーン切り替えを紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/scene-change-fade/" title="【Unity】シーン切り替え演出｜フェイドイン・アウト" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/10/scene-change-fade-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/scene-change-fade-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/10/scene-change-fade-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/10/scene-change-fade-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】シーン切り替え演出｜フェイドイン・アウト</div><div class="blogcard-snippet internal-blogcard-snippet">Unityのシーン切り替え演出の１つにフェイドイン・フェイドアウトがあります。シーン遷移は突然してしまうためフェイドを使い滑らかにすることでユーザビリティ―が向上します。本記事では、ボタンを押してフェイド演出を詳しく解説しています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.04.29</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">プラットフォームの選択</h3>



<p> ビルド設定ウィンドウを開きます（ショートカット: Ctrl+Shift+B）。ここでプロジェクトのビルド対象プラットフォームを設定できます。</p>



<p> 左側カラムのPlatformsからビルドしたいターゲットプラットフォームを選びます（ PC向けなら「Windows, MacOS, Linux」、Webブラウザ向けなら「WebGL」、スマホアプリなら「iOS、Android」など）。選択すると右下にビルド対象として表示され、現在のプラットフォームでない場合は「Switch Platform」ボタンが有効になります。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-light-blue-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#2ca9e1"><div class="tab-caption-box-label block-box-label box-label fab-pencil"><span class="tab-caption-box-label-text block-box-label-text box-label-text">ビルドしたいプラットフォームを有効にする</span></div><div class="tab-caption-box-content block-box-content box-content">
<p>希望するプラットフォームが一覧に表示されていない、<strong>「No module loaded」</strong>といった表示が出る場合は、そのプラットフォーム用モジュールが未インストールです。</p>



<p><strong>「Install with Unity Hub」</strong>で、Unity Hubを開き、該当Unityエディターのバージョンに対し「モジュールを追加」から必要なビルドサポート（例: WebGL、Android、iOS など）をインストールしてください。モジュール追加後、Unityエディタを再起動するとプラットフォームが選択可能になります。</p>
</div></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2025/11/nomodule.webp" alt="" class="wp-image-8801" srcset="https://alicia-ing.com/wp-content/uploads/2025/11/nomodule.webp 1200w, https://alicia-ing.com/wp-content/uploads/2025/11/nomodule-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/11/nomodule-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/11/nomodule-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>ビルド対象を選んだら、<strong>Switch Platformボタンをクリックしてプラットフォームを切り替えます</strong>。プラットフォーム切り替え時には必要なライブラリのインポート処理が走るため、完了するまで待ちましょう。切り替え後、選択したプラットフォーム名の右に「(Active)」と表示されます。</p>



<h3 class="wp-block-heading">ビルドの実行</h3>



<p>ビルド前に、必要に応じて右下のDevelopment Build（開発ビルド）やCompression Method（圧縮方式）などのオプションをチェックできます。開発ビルドにチェックを入れるとデバッグ情報付きでビルドされ、パフォーマンスは落ちますがデバッグに有用です。<strong>初学者の場合、基本はチェック不要で構いません。</strong></p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-1 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/alicia.webp" alt="著者の体験談" class="speech-icon-image"/></figure><div class="speech-name">著者の体験談</div></div><div class="speech-balloon">
<p>項目が多すぎるので、基本そのままでOK</p>
</div></div>



<p> ビルドには、<strong>Build か Build and Run</strong>どちらかを押すと処理されます。「Build」ボタンを押すとビルド処理が始まります（完了後、出力先フォルダを開いて自分で実行ファイルを起動）。「Build and Run」を押すとビルド完了後に自動的にアプリケーション（またはエミュレータ）が起動し、実行結果をすぐ確認できます。<strong>開発中はBuild and Runが便利です。</strong></p>



<p>ビルド中は<strong>Unityエディタ下部の進行バーに進捗メッセージが表示</strong>されます。スクリプトのコンパイルやシーンのデータ書き出しなど、多少時間がかかる場合がありますが完了まで待ちましょう。<strong>Consoleウィンドウにエラーが出た場合、ビルドは失敗</strong>しています。</p>



<p> ビルドが成功すると、指定したフォルダ内に出力物が生成されます。Windowsは実行ファイル（.exe 等）とDataフォルダ、WebGLの場合はBuildフォルダとindex.html、Androidの場合はAPKファイル等ができています。それらを実行・配置することで実際にゲームが動作するか確認できます。</p>



<h2 class="wp-block-heading">出品に向けた設定</h2>



<p>いざ、ゲームをビルドしてもタイトルがそのままだったり、よくわからないファイルが同封されているなど問題だらけです。また、ゲーム作りはプロでも１年以上は費やして完成をさせます。しかし出品の際に、<strong>スクリプトなどを保護</strong>をしないと購入者に解析されてしまうことがあります。（逆コンパイル）</p>



<p>このように、個人情報や作品の保護などより質の高いビルドについて解説をします。まずは、Edit >ProjectSettingを開きます（ビルド設定ウィンドウのPlayerSettingからでもOKです。）。</p>



<p>Playerをいじれば基本的なゲーム設定は可能です。<strong>「Resolution and Presentation」</strong>は画面サイズや比率の設定は後述します。</p>



<h3 class="wp-block-heading">名前変更</h3>



<p>ゲームの主要情報はここで変えることができます。ここは<strong>ユーザーが見えるところ</strong>なのでしっかりと変更することが重要です。</p>



<ul class="wp-block-list">
<li>Company Name：会社名（セーブデータ格納とかでフォルダー名になる）</li>



<li>Product Name：ゲーム名（ゲームファイルの名前になる）</li>



<li>Verson：バージョン（1.2.3という命名がおすすめ。【ゲーム性】.【機能追加】.【バグ修正】）</li>



<li>Default Icon：実行ファイルのアイコン。未設定ではUnityのロゴ</li>



<li>Default Cursor：マウスカーソルの見た目変更。</li>



<li>Default Hotspot：カーソルの位置、基本的にデフォルトでOK(x,y)=(0,0)</li>
</ul>



<p></p>



<h3 class="wp-block-heading">Splash Image（ゲーム開始時の企業ロゴ）</h3>



<p>ゲームを開始するときに企業ロゴや注意事項などが出てくる作品がありますが、Unityでも再現ができます。基本初期のままで構いませんが、いくつか変更すると良いところがありますので私が良くする設定で紹介します。</p>



<ul class="wp-block-list">
<li>Splash Screen>Animation：Custom（ロゴのズームをしないように設定）</li>



<li>Logos>Show Unity Logo：なし（Unityのロゴを非表示。<strong>Unity6から無料版でもチェックを外せる</strong>ように！）</li>
</ul>



<p>Splash StyleやBackground Colorなどはそれぞれのロゴに適したものを使うと良いでしょう。</p>



<h3 class="wp-block-heading">Other Settings</h3>



<p>その他なのに最も項目が多くてめんどくさいので、変えないといけない箇所だけ紹介します。</p>



<ul class="wp-block-list">
<li>Configuration>Scripting Backend：<strong>IL2CPP</strong>（スクリプト等の保護。MONOだと逆コンパイルでデータが盗まれる）</li>
</ul>



<p>その他にも、使っていないスクリプトを削除して軽くする機能もありますが、予期せぬバグになるので省略します。</p>



<h3 class="wp-block-heading">フォルダーの削除</h3>



<p>ビルドを終えると、基本的に削除してはいけないファイルばかりですが、「BurstDebugInformation<strong>_DoNotShip</strong>」というフォルダーは削除しなければいけません。フォルダーの中身は、ビルド情報が載りますが、よく見ると自分のPC情報が記載されています。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Library: C:\Users<strong>\【username】</strong>\Desktop\UnityProject\Tile_RPG\Temp\BurstOutput\Data\Plugins\x86_64\lib_burst_generated<br>&#8211;platform=Windows<br>&#8211;backend=burst-llvm-18</p>
<cite>Tile_RPG_BurstDebugInformation_DoNotShip/lib_burst_generated.txt</cite></blockquote>



<h2 class="wp-block-heading">画面サイズと解像度の設定</h2>



<p>PC向け（Standalone）ビルドでは、デフォルト設定のままだとゲーム起動時にディスプレイ全画面で表示されます。古いUnityでは起動時に解像度選択ダイアログが表示されることもありましたが、2020年以降のUnityでは初期挙動が自動でフルスクリーンとなる場合が多いです。</p>



<p>必要に応じて、ビルドされたゲームの画面モードや解像度を指定しましょう。</p>



<p>Unityエディタ上部メニューから Edit > Project Settingsを開き、左メニューから Player を選択します。その中の対象プラットフォームの<strong>Resolution and Presentation</strong> セクションを展開してください。ここで画面モードや初期解像度に関する設定を変更できます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2025/11/ScreenSize.webp" alt="" class="wp-image-8802" srcset="https://alicia-ing.com/wp-content/uploads/2025/11/ScreenSize.webp 1200w, https://alicia-ing.com/wp-content/uploads/2025/11/ScreenSize-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/11/ScreenSize-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/11/ScreenSize-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-vivid-cyan-blue-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#0693e3"><div class="tab-caption-box-label block-box-label box-label fab-edit"><span class="tab-caption-box-label-text block-box-label-text box-label-text">不要なPlayer.txtが表示</span></div><div class="tab-caption-box-content block-box-content box-content">
<p>AppDataフォルダーの中にPlayer.txtが生成されてしまいます。これはスクリプㇳのDebugなどを検知しますが、「Use Player Log」のチェックを外せば生成されることは無くなります。</p>
</div></div>



<p> Fullscreen Mode という設定項目があります。デフォルトでは「Fullscreen Window（全画面表示ウィンドウ）」もしくは「Exclusive Fullscreen（専用全画面）」になっています。これを <strong>「Windowed（ウィンドウ表示）」</strong> に変更すると、ビルド後のゲームがウィンドウモードで起動するようになります。フルスクリーンだと起動時にモニタ解像度で全面表示されますが、Windowedにすることでウィンドウ枠のある通常のウィンドウになります。</p>



<p> Default Screen Width（デフォルト幅）、Default Screen Height（デフォルト高さ）という項目で、ウィンドウモード時の初期画面サイズ（解像度）を指定できます。ただしこれらは Fullscreen Modeを「<strong>Windowed」にした場合のみ有効</strong>です。（フルスクリーン時はモニタ解像度に依存）。例えば幅1920×高さ1080にしたければ、それぞれ1920、1080と設定します。</p>



<p>Resizable Window オプションを true にすると、ユーザーがウィンドウの端をドラッグして自由にリサイズできるようになります。固定サイズで遊ばせたい場合は false に設定し、ウィンドウサイズ変更を禁止します。<strong>リサイズを許可する場合、画面比率が変わってUI配置が崩れないようCanvasの設定</strong>（UIのScale ModeやReference Resolution）にも注意が必要なので、<strong>許可しないことをおすすめします。</strong></p>



<h3 class="wp-block-heading">著者が実際にしている画面サイズ設定</h3>



<p>私の設定では、<strong>FullScreenとWindowedモードのハイブリット</strong>にしています。</p>



<ul class="wp-block-list">
<li>Fulscreen Mode：Windowed</li>



<li>Default Screen :幅1280×高さ720</li>
</ul>



<p>このサイズにしておけば、<strong>ほとんどのユーザーのPCに納まる</strong>かと思います。</p>



<p>また、以下のスクリプトをゲームのタイトル画面に設置してフルスクリーンとウィンドウどちらにも対応できるようにしています。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>    // ウィンドウモードに戻すときのサイズ
    [SerializeField] private int windowWidth = 1280;
    [SerializeField] private int windowHeight = 720;

    // UIボタンから呼ぶ関数
    public void ToggleFullscreen()
    {
        if (Screen.fullScreen)
        {
            // フルスクリーン → ウィンドウモード
            Screen.SetResolution(windowWidth, windowHeight, FullScreenMode.Windowed);
            Debug.Log(&quot;Switched to Windowed Mode&quot;);
        }
        else
        {
            // ウィンドウモード → フルスクリーン
            Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, FullScreenMode.FullScreenWindow);
            Debug.Log(&quot;Switched to Fullscreen Mode&quot;);
        }
    }</code></pre></div>



<h2 class="wp-block-heading">WebGLビルドの方法とポイント</h2>



<p>WebGLプラットフォームを選択すると、UnityのゲームをWebブラウザ上で実行できる形でビルドできます。HTML5/WebGL対応ゲームのビルド手順と注意点を解説します。</p>



<p>WebGLでビルドするには、まずUnityにWebGLビルドサポートモジュールがインストールされている必要があります。Unity Hubのインストール項目から現在使用中のUnityバージョンに対し<strong>「WebGL Build Support」を追加インストール</strong>してください（未導入の場合、Build SettingsでWebGLプラットフォームを選ぶ際に自動で「Install with Unity Hub」というボタンが表示されます）。</p>



<p>Build Settings ウィンドウで Platform を「WebGL」に選択し、「Switch Platform」で切り替えます。切り替え後、「WebGL」がActiveプラットフォームになったことを確認してください。</p>



<p> WebGLビルド用のPlayer Settingsも確認しておきましょう。たとえば「Publishing Settings」内の Compression Format（圧縮形式）はデフォルトでは Brotli 圧縮が使われます。<strong>互換性のためGzip圧縮に変更するケース</strong>もあります（Unity公式のUnity Playや一部サーバーではBrotli未対応の場合があるため）。また Memory Size（デフォルト256MB）などWebGL固有の設定項目もありますが、必要に応じて調整します。初回は特に変更せずとも動作しますが、ビルドサイズや読み込み速度の最適化に関わる部分なので、公開時には検討するとよいでしょう。</p>



<p> Build and Run を使うと、ビルド完了後に<strong>自動でブラウザが起動しローカルホストでホスティングされたゲーム</strong>が開きます。Buildのみ実行した場合、出力されたフォルダ（デフォルトでは Build フォルダと Template データ）が生成され、その中のindex.htmlをブラウザで開いても直接は動作しません。WebGLビルドはセキュリティ上、ファイルシステムから直接読み込めないためです。必ずBuild and Runで確認するか、簡易なローカルHTTPサーバーを立ててホスティングしてください。</p>



<p>WebGLのビルド結果として、index.html ファイルと Buildフォルダ（中に .jsonや.wasm、.dataファイルなどが入っています）が生成されます。これら一式をWebサーバー上に配置すれば、ユーザーはブラウザでindex.htmlにアクセスするだけでゲームをプレイできます。UnityRoom（日本国内向けのUnityゲーム投稿サイト）や itch.io, GitHub Pages などにアップロードするのも簡単です。Unity公式の Unity Play や Game Server Hosting なども選択肢になります。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-check block-box has-border-color has-yellow-border-color">
<p><strong>WebGLビルドでは、使用できる機能にいくつか制限</strong>があります。例えばマルチスレッドやファイルシステムへのアクセス、一部プラグインは動作しません。またメモリ使用量にも注意が必要で、大きすぎるアセットはロードに時間がかかったりブラウザでメモリ不足になる場合があります。<strong>動作が重い場合はQuality設定を下げる、圧縮形式を見直す、不要なAssetを削減する</strong>等で最適化しましょう。基本的にはUnityエディタ上で問題なく動いていても、ブラウザの開発者コンソールでエラーが出ていないかを確認しつつテストを重ねることが大切です。</p>
</div>



<h2 class="wp-block-heading">ビルドできない時のトラブルシューティング</h2>



<p>ビルド実行中にエラーが発生し「Build failed」となってしまうことがあります。ここでは、「Unityでビルドができない！」となった場合によくある原因と解決策を紹介します。最終的には<strong>エラー文をChatGPTや検索してみるとQiitaやNoteに公開しているユーザーが多いので、これらで解決</strong>しましょう。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2025/11/errorcode.webp" alt="" class="wp-image-8803" srcset="https://alicia-ing.com/wp-content/uploads/2025/11/errorcode.webp 1200w, https://alicia-ing.com/wp-content/uploads/2025/11/errorcode-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/11/errorcode-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/11/errorcode-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p> 最初にチェックすべきは、<strong>スクリプトのコンパイルエラー</strong>です。Unityではスクリプトにエラーがある状態だとビルドは実行できません。<strong>エディタ下部のConsoleウィンドウに赤いエラーメッセージ</strong>が出ていないか確認し、出ている場合は内容に従ってコードを修正してください。典型的には文法ミス（セミコロンの付け忘れ等）や参照切れ、型の不一致などが原因です。コンパイルエラーはビルド以前にエディタ実行中から検知できますので、まずここをゼロにしましょう。</p>



<p>または、<strong>ビルド対象プラットフォームのモジュールが入っていない場合、ビルド自体が開始できませ</strong>ん（ビルド設定でビルドボタンが押せない状態になる）。例えば「WebGL Module」や「Android Build Support」などがUnityに追加されているかを確認し、入っていなければUnity Hubからインストールします。モジュール不足が原因の場合、エラーメッセージで指摘されることもあります。「Module not loaded」「SDK not found」等のログが出たら該当モジュール/SDKの導入を行ってください。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>Unityにおけるビルド手順と設定、そしてトラブル発生時の対処法について網羅的に解説しました。</p>



<p>開発途中でもこまめにビルドを行う習慣を付けましょう。Unityエディタ上では正常に動いていても、ビルドすると初めて表面化する不具合は少なくありません。大きな機能追加や変更をした際はその都度ビルドして、予期せぬエラーが出ないか確認することで、後になってエラーの山に悩まされるリスクを減らせます。</p>



<p> バージョン管理とバックアップ: ビルド前後で問題が発生した際に備え、Git等のバージョン管理システムでプロジェクトの変更履歴を残しておくことをお勧めします。特にビルド直前に入れた変更が原因でエラーになった場合、直前のコミットに戻すことで原因の切り分けが容易になります。</p>



<p>ビルドエラーに直面した場合、公式マニュアルのトラブルシューティングやUnityフォーラム、Qiita記事などコミュニティの情報も積極的に参考にしましょう。特にエラーメッセージで検索すると同様のケースに遭遇した開発者の知見が見つかることが多いです。英語で検索するとフォーラムの回答がヒットする場合もあります。</p>



<p>ビルドが無事完了したら、実際に他のPCやデバイスで動作確認をします。画面サイズ設定や挙動が開発機と異ならないか、想定通りフルスクリーン/ウィンドウ表示になるか、WebGLなら複数のブラウザで正常動作するか、といった点をチェックしましょう。問題があれば再度Unity側の設定を調整しビルドし直します。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/build-setting/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Unity】時間計測の方法｜ミリ秒・分秒タイマーを実装</title>
		<link>https://alicia-ing.com/programming/unity/game-time-measurement/</link>
					<comments>https://alicia-ing.com/programming/unity/game-time-measurement/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 04 May 2025 22:00:00 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8521</guid>

					<description><![CDATA[Unityでゲームを作成する際、時間管理やタイマーの導入はゲームの面白さを左右する重要な要素です。特にアクションゲームやパズルゲームなどでは、時間制限を設けたり、経過時間を計測したりすることでゲームプレイに緊張感や達成感 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p>時間計測を行い、ゲーム終了後にタイマーを停止してシーン切り替えて結果を表示</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/03/complete-1.gif" alt="" class="wp-image-8625"/></figure>
</div></div>



<p>Unityでゲームを作成する際、時間管理やタイマーの導入はゲームの面白さを左右する重要な要素です。特にアクションゲームやパズルゲームなどでは、時間制限を設けたり、経過時間を計測したりすることでゲームプレイに緊張感や達成感を与えられます。</p>



<p>本記事では、unityで時間管理するメソッドを紹介して、時間計測やタイマーをゲーム内に導入します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Unityで制限時間付きのゲームを作りたい方</li>



<li>ゲーム内で経過時間を表示したい方</li>



<li>ゲームオーバー処理を時間で制御したい方</li>



<li>ミリ秒単位の高精度タイマーが必要な方</li>



<li>時間経過で自動的にシーンを切り替えたい方</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">Unityで時間計測とタイマー</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1536" height="1024" src="https://alicia-ing.com/wp-content/uploads/2025/04/timer-metthod.webp" alt="" class="wp-image-8630" srcset="https://alicia-ing.com/wp-content/uploads/2025/04/timer-metthod.webp 1536w, https://alicia-ing.com/wp-content/uploads/2025/04/timer-metthod-300x200.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/04/timer-metthod-1024x683.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/04/timer-metthod-768x512.webp 768w" sizes="(max-width: 1536px) 100vw, 1536px" /></figure>



<p>Unityでのゲーム開発において、時間計測やタイマー機能は非常に重要な位置を占めます。</p>



<p><strong>ゲーム内で時間制限を明確に設定</strong>することにより、プレイヤーに対して緊張感や達成感を生み出し、ゲームのテンポを一定に保つことができるためです。</p>



<p>例えば、クイズゲームでは制限時間を設けることで迅速な判断を促し、制限時間内に答えられなければ不正解とする。カードゲームではプレイヤーが一定時間内に行動をしなければ自動的にターンが次のプレイヤーへと移る仕組みを作ることで、円滑な進行を促します。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Unityで４択クイズの作り方を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/4choice-csharp/" title="【Unity】４択クイズゲームの作り方-アセットなしで作成する" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/12/4-choice-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/12/4-choice-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/12/4-choice-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/12/4-choice-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】４択クイズゲームの作り方-アセットなしで作成する</div><div class="blogcard-snippet internal-blogcard-snippet">Unityで4択クイズを作成します。ゲーム内では、アニメーションやランダム、BGMを導入して質の高い作品を作ることができます。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.10.24</div></div></div></div></a>
</div>



<p>さらに、RPGゲームではクリアタイムを競うタイムアタック要素を設けることで、プレイヤーのモチベーションを維持したり、競争心を高めたりできます。また、時間制限がプレイヤーに明確に示されることで、プレイヤーがより戦略的にゲームを進めたり、瞬時の判断力が求められたりするため、ゲームへの没入感や興奮度を高めることにも繋がります。</p>



<p>こうした様々な側面から、<strong>時間管理はゲーム制作において不可欠な要素</strong>となっています。</p>



<p>以下で、Unityの時間計測やタイマー機能を実装するために必要な具体的メソッドを詳しく見ていきます。</p>



<h3 class="wp-block-heading">Time.time</h3>



<p><a target="_self" href="https://docs.unity3d.com/ja/2022.1/ScriptReference/Time-time.html">Time.time</a>は<strong>Unityにおける基本的な時間計測メソッド</strong>で、ゲームの開始時から現在までの経過時間を秒単位で取得できます。</p>



<p>初心者でも簡単に利用でき、主にシンプルな経過時間表示や簡単なタイマー機能の実装に使えます。</p>



<p>実際のコードでは次のように書きます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>void Update()
{
    float elapsedTime = Time.time;
    Debug.Log(&quot;経過時間: &quot; + elapsedTime + &quot;秒&quot;);
}</code></pre></div>



<p>毎フレームごとに経過時間をログに表示しています。素早く実装可能です。</p>



<p>ただし、この方法はあくまでも基本的な時間計測に向いており、細かい制御には不向きな場合があります。</p>



<h3 class="wp-block-heading">Time.deltaTime</h3>



<p><a target="_self" href="https://docs.unity3d.com/ja/2021.1/ScriptReference/Time-deltaTime.html">Time.deltaTime</a>は前フレームからの経過時間を取得する方法であり、特に動きのあるゲームや毎フレーム更新されるタイマーの実装に適しています。</p>



<p>実際のコードでは次のように書きます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>private float timer = 0f;
void Update()
{
    timer += Time.deltaTime;
    Debug.Log(&quot;累計時間: &quot; + timer + &quot;秒&quot;);
}</code></pre></div>



<p>このコードはフレームレートに依存しないため、異なる端末や環境でも均一な動きを提供できます。移動速度の制御やアニメーションの時間管理にも非常に有効です。</p>



<h4 class="wp-block-heading">Time.timeとTime.deltaTimeの違いは？</h4>



<p>コード例を見ると、両者に違いがなく<strong>Time.timeの方が短く記述でき</strong>るので、Time.deltaTimeの意味がなさそうに見えるでしょう。</p>



<p>Time.timeは<strong>ゲーム開始からずっと加算される絶対時間ベースの処理</strong>です。タイマー、経過時間判定などに使えますが、リセットをすることができないので色々と不便です。</p>



<p>一方Time.deltaTimeは、前のフレームから今まで何秒経ったか。<strong>移動・回転・アニメーションなどをフレーム依存なしで進める</strong>ことが可能です。</p>



<h3 class="wp-block-heading">Stopwatch</h3>



<p><a target="_self" href="https://docs.unity3d.com/Packages/com.unity.uiwidgets@1.0/api/Unity.UIWidgets.flow.Stopwatch.html">Stopwatch</a>はUnityで高精度の時間計測（ミリ秒単位）が可能なメソッドです。これは主にベンチマークテストや処理の最適化を目的とした精密な処理時間の測定に使われます。</p>



<p>実際のコードでは次のように書きます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>using System.Diagnostics;

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// 計測したい処理
stopwatch.Stop();
Debug.Log(&quot;処理時間: &quot; + stopwatch.ElapsedMilliseconds + &quot; ms&quot;);</code></pre></div>



<p>特定処理にかかる正確な時間をミリ秒単位で取得でき、パフォーマンス改善に役立ちます。特徴として、名前空間で「System.Diagnostics」が必要です。</p>



<h4 class="wp-block-heading">ミリ秒のタイマー</h4>



<p>Unityでミリ秒単位の高精度タイマーを導入する場合、Stopwatchが最も推奨されます。<br>特にリアルタイム性を求めるゲームや、処理精度を要求されるシミュレーションなどで有効です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>Stopwatch timer = new Stopwatch();
timer.Start();
// 時間を測る処理
timer.Stop();
long milliseconds = timer.ElapsedMilliseconds;
Debug.Log(&quot;経過時間: &quot; + milliseconds + &quot; ms&quot;);</code></pre></div>



<h3 class="wp-block-heading">番外編：Coroutine + WaitForSeconds</h3>



<p>一定時間後に処理を行う際に役立つのが、Coroutineと<a target="_self" href="https://docs.unity3d.com/ja/2019.4/ScriptReference/WaitForSeconds.html">WaitForSeconds</a>です。これは遅延処理やクールタイムの実装で頻繁に利用されます。したがって、<strong>時間計測には向かない</strong>です。例えば、クイズゲームで解答表示3秒後に次の問題を出題するというときに使います。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>コールチンについて解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/coroutine/" title="【Unity】coroutine（コルーチン）で停止や再開を解説" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】coroutine（コルーチン）で停止や再開を解説</div><div class="blogcard-snippet internal-blogcard-snippet">【アセット不要！Unityで作るノベルゲーム】第6回は、Invokeで引数を渡し、数秒後に動作させてオート機能を作ります。オートモードを導入すると、プレイヤーがわざわざクリック操作をせずにストーリーの流れを自動的に楽しむことができます。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<p>例として、3秒後に特定の処理を行うコードは以下です。</p>



<p>実際のコードでは次のように書きます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>IEnumerator DelayedAction()
{
    yield return new WaitForSeconds(3f);
    Debug.Log(&quot;3秒経過しました。&quot;);
}

void Start()
{
    StartCoroutine(DelayedAction());
}</code></pre></div>



<p>このように、指定した時間経過後に処理を自動的に実行できるため、<strong>イベント制御やゲームロジックの調整</strong>に非常に便利です。</p>



<h2 class="wp-block-heading">ゲームクリア後、シーン遷移して時間計測結果を表示する</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1536" height="1024" src="https://alicia-ing.com/wp-content/uploads/2025/04/clear-time.webp" alt="" class="wp-image-8631" srcset="https://alicia-ing.com/wp-content/uploads/2025/04/clear-time.webp 1536w, https://alicia-ing.com/wp-content/uploads/2025/04/clear-time-300x200.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/04/clear-time-1024x683.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/04/clear-time-768x512.webp 768w" sizes="(max-width: 1536px) 100vw, 1536px" /></figure>



<p>これまでの方法を踏まえて、<strong>実際のゲームでクリアタイムを分秒表示</strong>し、クリア後は<strong>タイマーを停止</strong>、<strong>シーンを移動して結果を表示する</strong>機能を作ります。</p>



<p>シーン移動やドラッグ＆ドロップは別記事で紹介していますので、本記事ではタイマーのみ解説をします。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>ドラッグ＆ドロップについて解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/drag-and-drop-object/" title="【Unity】ドラックアンドドロップでゲームオブジェクトを動かす" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/02/drag-and-drop-object-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/02/drag-and-drop-object-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/02/drag-and-drop-object-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/02/drag-and-drop-object-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】ドラックアンドドロップでゲームオブジェクトを動かす</div><div class="blogcard-snippet internal-blogcard-snippet">ゲームオブジェクトをドラッグアンドドロップするには、Camera.main.ScreenToWorldPoint()か、イベントシステムでIPointerDownHandler, IDragHandler, IPointerUpHandlerを使います。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.05.03</div></div></div></div></a>
</div>



<p>実装には<strong>Time.deltaTimeを使った簡易タイマー</strong>を使います。それぞれのオブジェクトにドラッグ＆ドロップ機能をつけて、クリア時にタイマー停止後シーンを遷移し、結果表示します。</p>



<h3 class="wp-block-heading">ソースコード1</h3>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>using UnityEngine;
using TMPro;

public class Timer : MonoBehaviour
{
    [SerializeField] private TMP_Text timerText; // ゲーム中のタイマー表示用
    private float elapsedTime = 0f;
    private bool isRunning = true;

    // クリア時の最終時間を保持する static 変数
    public static float finalTime = 0f;

    void Update()
    {
        if (isRunning)
        {
            elapsedTime += Time.deltaTime;
            int minutes = Mathf.FloorToInt(elapsedTime / 60f);
            int seconds = Mathf.FloorToInt(elapsedTime % 60f);
            timerText.text = string.Format(&quot;{0:00}:{1:00}&quot;, minutes, seconds);
        }
    }

    // タイマー停止時に最終時間を保存する
    public void StopTimer()
    {
        isRunning = false;
        finalTime = elapsedTime;
    }
}
</code></pre></div>



<h4 class="wp-block-heading">UdemyでUnityを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-micro-text aligncenter micro-text micro-copy micro-top"><span class="micro-text-content micro-content">＼Unityの学習から収益化の方法はこちらから！／</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/roadmap-cs/" title="【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！</div><div class="blogcard-snippet internal-blogcard-snippet">Unityを使って自作ゲームを作りたい方必見。ゲームエンジン選択から学習方法、収益化の手段まで初心者向けにわかりやすく解説します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-777game%2F">【Unity C# ゲーム開発超入門】7つのミニゲームを作っておぼえる！UnityとC#講座</a><br>Unityで頻出の機能を実際のゲーム作りで学習。<br><strong>何か作りたい、今後の開発で役立てたい初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-playing_cards%2F">【Unity C# ゲーム開発初心者レベルアップ】7つのトランプゲームを作っておぼえる！UnityとC#講座</a><br>トランプやボードゲーム作りに特化している講座。<br><strong>テーブルゲームを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" data-type="link" data-id="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F">【全行程を網羅！最初に学びたい総合学習】Unityワールド制作講座<br></a>Unityワールド制作の全工程を学習できる講座。<br><strong>RPGを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fstudio_shimazu_nfrpg%2F">Unity ゲーム開発：インディーゲームクリエイターが教える C#の基礎からゲームリリースまで【スタジオしまづ】</a><br>C#の文法やApp StoreとGoogle Playへゲームをリリース方法を解説。<br><strong>ゲームを出品したい人</strong>におすすめ。</li>
</ul>
</div>



<h3 class="wp-block-heading">解説</h3>



<ul class="wp-block-list">
<li><strong>名前空間</strong></li>
</ul>



<p>「UnityEngine」：Unityの基本機能を利用するために必要。GameObjectやMonoBehaviourクラス、Timeクラスなどが含まれる。<br>「<a target="_self" href="https://docs.unity3d.com/Packages/com.unity.textmeshpro@1.3/api/TMPro.html">TMPro</a>」：TextMeshProコンポーネントを使用し、高品質なテキスト表示を実現するために必要。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>TextMeshProの導入と日本語取り扱いの解説をしています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/textmeshpro/" title="【Unity】TextMeshPro-日本語表示とスクリプト制御" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】TextMeshPro-日本語表示とスクリプト制御</div><div class="blogcard-snippet internal-blogcard-snippet">UnityのTextMeshProは日本語のテキストを美しく表示し、スクリプトでテキストを動的に変更することも可能です。改行は&quot;\n&quot;でします。&quot;japanese_full.txt&quot;ファイルを読み込んでTextMeshProに適用します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<ul class="wp-block-list">
<li><strong>フィールド（メンバ変数）</strong></li>
</ul>



<p>「timerText」：ゲーム画面に経過時間を表示するTextMeshProコンポーネントへの参照。<br>「elapsedTime」：ゲーム開始から経過した時間（秒）を保持するための変数。<br>「isRunning」：タイマーが現在動作中かどうかを示すフラグ（trueで動作中、falseで停止）。<br>「finalTime」：ゲームクリア時に計測した最終時間を保持するstatic変数。他のクラスからも参照可能。</p>



<ul class="wp-block-list">
<li><strong>Updateメソッド</strong></li>
</ul>



<p>タイマーが動作中（isRunningがtrue）の場合、経過時間（elapsedTime）に前フレームからの経過時間（Time.deltaTime）を加算する。経過時間を分と秒に分解し、テキスト形式（MM:SS）でtimerTextに表示する処理を行う。</p>



<ul class="wp-block-list">
<li><strong>StopTimerメソッド</strong></li>
</ul>



<p>タイマーを停止する際に呼ばれ、isRunningフラグをfalseに設定して計測を停止させる。同時に、計測された経過時間をfinalTimeに格納し、クリア時の最終時間として保持する。</p>



<h2 class="wp-block-heading">実演</h2>



<p>タイマースクリプトはゲームマネージャーなど共通管理用オブジェクトにアタッチします。</p>



<p>ゲームを再生すると、冒頭で紹介したような挙動が可能になります。</p>



<p>経過時間を画面上に表示（TMP_Textコンポーネント）ゴールした時点でTimerクラスのStopTimerメソッドを呼び、タイマーを止めます。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>本記事ではUnityの時間管理やタイマー機能を詳しく解説しました。</p>



<p>Time.time、Time.deltaTimeの基本的な使い方から、Stopwatchを利用した高精度タイマー、Coroutineを利用した時間制御の方法まで、幅広くカバーしました。</p>



<p>これらの技術を活用し、より質の高い、魅力的なゲームを作りましょう。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/unity/game-time-measurement/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Unity】TextMeshProでテキストを1文字ずつ表示する</title>
		<link>https://alicia-ing.com/programming/unity/display-one-character-at-a-time/</link>
					<comments>https://alicia-ing.com/programming/unity/display-one-character-at-a-time/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 09 Mar 2025 22:00:00 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8458</guid>

					<description><![CDATA[Unityでノベルゲームのような会話シーンを制作するとき、「文字を1文字ずつ表示したい！」ことがあると思います。 突然テキストが表示されるのではなく、まるでキャラクターが実際に話しているかのような演出があれば、プレイヤー [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p>TextMeshProでテキストを一文字ずつ、文字送りする。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/03/complete.gif" alt="" class="wp-image-8465"/></figure>
</div></div>



<p>Unityで<strong>ノベルゲームのような会話シーンを制作</strong>するとき、「文字を1文字ずつ表示したい！」ことがあると思います。<br><br>突然テキストが表示されるのではなく、<strong>まるでキャラクターが実際に話しているかのような演出</strong>があれば、プレイヤーの没入感も大きくアップさせることができます。</p>



<p>しかし、「実際にどうやって実装するの？」や「初心者でも簡単にできる方法はないの？」と悩んでいる方も多いでしょう。</p>



<p>本記事では、UnityのTextMeshPro（TMP）を使って<strong>1文字ずつ表示する方法</strong>を分かりやすく解説します。</p>



<p>具体的な実装例や注意点も挙げながら、初心者の方でも迷わず実践できる内容にしています。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>文字を1文字ずつ流れるように表示する基本的な方法</li>



<li>コルーチンを使った効率的で簡単な実装方法</li>



<li>応用として、途中で一気に全文を表示する方法</li>



<li>注意すべきポイントやトラブルシューティング</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">文字送り表示</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2025/03/character-spacing.webp" alt="" class="wp-image-8466" srcset="https://alicia-ing.com/wp-content/uploads/2025/03/character-spacing.webp 1200w, https://alicia-ing.com/wp-content/uploads/2025/03/character-spacing-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/03/character-spacing-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/03/character-spacing-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>文字送りとは、テキストが一瞬で表示されるのではなく、1文字ずつ流れるように表示されるアニメーションのことを指します。</p>



<p>これはノベルゲームやアドベンチャーゲームなど、<strong>キャラクター同士が会話をするシーン</strong>でよく用いられています。</p>



<p>1文字ずつ表示されることによって、キャラクターが実際に言葉を話しているかのような臨場感を出すことができます。</p>



<p>プレイヤーの没入感を高める重要な要素なので、ゲームのクオリティを上げたいならぜひマスターしましょう。</p>



<p>また、RPGやチュートリアル表示など、幅広いジャンルのゲームにも応用可能です。</p>



<h3 class="wp-block-heading">コルーチンで実装</h3>



<p>Unityで1文字ずつの表示を効率的かつ簡単に実現するためには、<br>「<strong>コルーチン（Coroutine）</strong>」を使用します。</p>



<p>コルーチンとは、特定の処理を途中で待機（一定時間停止）させたり、<br>少しずつ処理を実行したりできるUnity特有の便利な機能です。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>コールチンで停止・再開を解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/coroutine/" title="【Unity】coroutine（コルーチン）で停止や再開を解説" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/01/coroutine-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】coroutine（コルーチン）で停止や再開を解説</div><div class="blogcard-snippet internal-blogcard-snippet">【アセット不要！Unityで作るノベルゲーム】第6回は、Invokeで引数を渡し、数秒後に動作させてオート機能を作ります。オートモードを導入すると、プレイヤーがわざわざクリック操作をせずにストーリーの流れを自動的に楽しむことができます。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<p>似た機能にInvokeというものがありますが、Invokeは指定した関数を一度または定期的に呼び出すシンプルな仕組みであるのに対し、コルーチンは細かな処理の制御に適しています。</p>



<p>本記事のような単純に文字送りをするだけならInvokeでも良いですが、<br>文字送りの速度を微調整したり、特定の文字だけ遅らせたりする場合は、コルーチンをおすすめします。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Invokeの使い方を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/invoke/" title="【Unity】Invokeで引数を渡す、途中で停止・中断。" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/02/invoke-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/02/invoke-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/02/invoke-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/02/invoke-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】Invokeで引数を渡す、途中で停止・中断。</div><div class="blogcard-snippet internal-blogcard-snippet">UnityのInvokeを使って引数を渡す方法や、処理を途中で停止するテクニックを解説。また、コールチンとの違いを紹介。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.05.18</div></div></div></div></a>
</div>



<h2 class="wp-block-heading">コルーチンを使った1文字ずつ表示する</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2025/03/character-a-time.webp" alt="" class="wp-image-8467" srcset="https://alicia-ing.com/wp-content/uploads/2025/03/character-a-time.webp 1200w, https://alicia-ing.com/wp-content/uploads/2025/03/character-a-time-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/03/character-a-time-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/03/character-a-time-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>今回紹介する方法は、TextMeshPro（テキストメッシュプロ）を使って、<br>簡単に実装できるシンプルな方法です。</p>



<p>ソースコードの大まかな流れは以下の通りです。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-blue-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#0095d9"><div class="tab-caption-box-label block-box-label box-label fab-bolt"><span class="tab-caption-box-label-text block-box-label-text box-label-text">機能の内容</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Resourcesフォルダに格納したテキストファイル（csv）を読み込み、表示するテキストを準備</li>



<li>コルーチンを利用して1文字ずつ表示し、表示間隔を調整</li>



<li>テキスト中のタグ（やなど）が途切れないように注意して処理</li>
</ul>
</div></div>



<p>Unityでテキストを表示するのは多種ありますが、TextMeshProが主流です。<br>制御もしやすく、フォントを自由に使うことができます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>TMPをインストールする方法を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/textmeshpro/" title="【Unity】TextMeshPro-日本語表示とスクリプト制御" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】TextMeshPro-日本語表示とスクリプト制御</div><div class="blogcard-snippet internal-blogcard-snippet">UnityのTextMeshProは日本語のテキストを美しく表示し、スクリプトでテキストを動的に変更することも可能です。改行は&quot;\n&quot;でします。&quot;japanese_full.txt&quot;ファイルを読み込んでTextMeshProに適用します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<p>stringを使用してスクリプト内のテキストで表示させる方法もありますが、<br>本記事では扱いやすくてより実践的なCSVファイルを読み込んで表示します。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Unityでcsvファイルを読み込む方法を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/csv-load/" title="【Unity】CSVファイルを読み込み、テキストを画面に表示する" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】CSVファイルを読み込み、テキストを画面に表示する</div><div class="blogcard-snippet internal-blogcard-snippet">UnityでのCSVファイルの読み込み方法を解説します。エクセルやGoogleスプレッドシートでcsvを作成し、データのインポート・読み書き・外部ファイル読み込みを簡単に実装する方法を紹介。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.12</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">ソースコード</h3>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>using System.Collections;
using UnityEngine;
using TMPro;
using System.IO;

public class typing : MonoBehaviour
{
    public TextMeshProUGUI LogText;
    public float typingInterval = 0.05f; // 文字表示の速度

    private string fullText;
    private bool isTyping = false;//タイピング開始

    void Start()
    {
        LoadCSV(&quot;Sample&quot;);
    }

    void LoadCSV(string fileName)
    {
        TextAsset csvFile = Resources.Load&lt;TextAsset&gt;(fileName);
        if (csvFile != null)
        {
            using (StringReader reader = new StringReader(csvFile.text))
            {
                fullText = reader.ReadLine();
            }
            StartCoroutine(TypeText());
        }
        else
        {
            Debug.LogError($&quot;CSVファイル({fileName})が見つかりません。&quot;);
        }
    }

    IEnumerator TypeText()
    {
        isTyping = true;
        LogText.text = &quot;&quot;;
        int i = 0;

        while (i &lt; fullText.Length)
        {
            if (fullText[i] == &#39;&lt;&#39;) // タグ開始の処理
            {
                int tagEnd = fullText.IndexOf(&#39;&gt;&#39;, i);
                if (tagEnd != -1)
                {
                    LogText.text += fullText.Substring(i, tagEnd - i + 1);
                    i = tagEnd + 1;
                }
            }
            else
            {
                LogText.text += fullText[i];
                i++;
                yield return new WaitForSeconds(typingInterval);
            }
        }

        isTyping = false;
    }
}</code></pre></div>



<h4 class="wp-block-heading">UdemyでUnityを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-micro-text aligncenter micro-text micro-copy micro-top"><span class="micro-text-content micro-content">＼Unityの学習から収益化の方法はこちらから！／</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/roadmap-cs/" title="【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！</div><div class="blogcard-snippet internal-blogcard-snippet">Unityを使って自作ゲームを作りたい方必見。ゲームエンジン選択から学習方法、収益化の手段まで初心者向けにわかりやすく解説します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-777game%2F">【Unity C# ゲーム開発超入門】7つのミニゲームを作っておぼえる！UnityとC#講座</a><br>Unityで頻出の機能を実際のゲーム作りで学習。<br><strong>何か作りたい、今後の開発で役立てたい初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-playing_cards%2F">【Unity C# ゲーム開発初心者レベルアップ】7つのトランプゲームを作っておぼえる！UnityとC#講座</a><br>トランプやボードゲーム作りに特化している講座。<br><strong>テーブルゲームを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" data-type="link" data-id="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F">【全行程を網羅！最初に学びたい総合学習】Unityワールド制作講座<br></a>Unityワールド制作の全工程を学習できる講座。<br><strong>RPGを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fstudio_shimazu_nfrpg%2F">Unity ゲーム開発：インディーゲームクリエイターが教える C#の基礎からゲームリリースまで【スタジオしまづ】</a><br>C#の文法やApp StoreとGoogle Playへゲームをリリース方法を解説。<br><strong>ゲームを出品したい人</strong>におすすめ。</li>
</ul>
</div>



<h3 class="wp-block-heading">解説</h3>



<ul class="wp-block-list">
<li><strong>名前空間</strong></li>
</ul>



<p>「System.Collections」：IEnumeratorとコルーチンを利用するために必要。<br>「UnityEngine」：MonoBehaviourを継承し、Unityの基本機能を使用するために必要。<br>「TMPro」：TextMeshProUGUIを使用し、UIにテキスト表示を行うために必要。<br>「System.IO」：文字列の読み込みや操作にStringReaderを使用するために必要。</p>



<ul class="wp-block-list">
<li><strong>フィールド（メンバ変数）</strong></li>
</ul>



<p>「LogText」：画面に表示するテキスト（TMP）を格納し、逐次テキストを追加表示するためのUI要素。<br>「typingInterval」：1文字表示ごとの待機時間（秒数）を指定することで、テキスト表示の速度を調整する。<br>「fullText」：CSVファイルから読み込んだ表示対象の文字列を格納する。<br>「isTyping」：現在タイピング表示処理が進行中か否かを判定するフラグ（真偽値）。</p>



<ul class="wp-block-list">
<li><strong>LoadCSVメソッド</strong></li>
</ul>



<p>引数として渡されたファイル名（Resources内にあるCSV形式のテキストファイル）を読み込む。</p>



<p>読み込みが成功すると、ファイルから取得した最初の行のテキストをfullTextに格納し、<br>TypeTextコルーチンを呼び出して文字列の逐次表示を開始する。</p>



<p>指定のファイルが存在しない場合は、エラーをログに表示する。</p>



<ul class="wp-block-list">
<li><strong>TypeTextメソッド</strong></li>
</ul>



<p>コルーチンを用いて、fullTextに格納されているテキストを1文字ずつ表示する。</p>



<p>文字列内にHTMLタグなどの特殊タグ（&lt;…>）があった場合はタグ全体をまとめて表示し、<br>タグが途切れないよう処理する。</p>



<p>タグではない通常の文字は、指定したインターバル（typingInterval）ごとに1文字ずつ追加表示される。<br></p>



<p>全ての文字を表示し終えると、isTypingフラグをfalseに戻し、処理を完了する。</p>



<h2 class="wp-block-heading">実演</h2>



<p>作成したスクリプトをInspectorウィンドウにアタッチして実行すると、<br>以下のような挙動を確認できます。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-yellow-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#ffd900"><div class="tab-caption-box-label block-box-label box-label fab-bolt"><span class="tab-caption-box-label-text block-box-label-text box-label-text">冒頭の挙動</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Resourcesフォルダに配置されたCSVファイルの最初の行が1文字ずつゆっくりと表示される</li>



<li>&lt;color&gt;や&lt;size&gt;などのTextMeshProタグは、文字送りの途中で途切れることなく正しく表示される</li>



<li>テキスト表示中は他の入力を受け付けない（ただし、後述の応用機能で回避可能）</li>
</ul>
</div></div>



<p>CSVはResourcesフォルダーに入れて管理しますが、現在は非推奨です。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Resourcesファイルの使い方とやめた方が良い理由を解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/resources/" title="【Unity】Resourcesフォルダの使い方と非推奨な理由" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/09/Resources-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/09/Resources-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/09/Resources-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/09/Resources-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】Resourcesフォルダの使い方と非推奨な理由</div><div class="blogcard-snippet internal-blogcard-snippet">UnityのResourcesフォルダは、アセットを動的に管理できる機能ですが、非推奨とされる。ビルドサイズの増加やメモリ管理の難しさ、アセット参照の追跡が困難になることなどで、「アドレッサブルシステム」を利用することが推奨とされる。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.04.29</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">文字送り中に、右クリックで全表示する</h3>



<p>さらに快適なユーザー体験を提供するために、応用機能として「右クリックすると瞬時に全テキストが表示される機能」も追加してみましょう。</p>



<p>これによりプレイヤーが待ち時間を自由にコントロールでき、ストレスを軽減できます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>void Update()
{
    if (Input.GetMouseButtonDown(1) && isTyping)
    {
        StopAllCoroutines();
        LogText.text = fullText;
        isTyping = false;
    }
}</code></pre></div>



<p>右クリックでコルーチンを途中停止することで、処理の完了を即時化します。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>この記事では、UnityのTextMeshProを使った1文字ずつ表示する方法を解説しました。</p>



<p>キャラクターが実際に会話しているような演出を実現することで、<br>ゲームのクオリティやプレイヤーの没入感が大幅に向上します。</p>



<p>また、「右クリック即時表示」機能を導入すれば、<br>ユーザーがさらに快適にゲームを楽しめます。</p>



<p>次のステップとして以下の記事もチェックして、さらなるスキルアップを目指しましょう！</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/unity/display-one-character-at-a-time/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Unity】ピッチで速度変更をしても高さを変えない方法</title>
		<link>https://alicia-ing.com/programming/unity/pitchshifter/</link>
					<comments>https://alicia-ing.com/programming/unity/pitchshifter/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 23 Feb 2025 22:00:00 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8410</guid>

					<description><![CDATA[Unityでゲームやアプリケーションを制作する際、音声の再生速度を変更することは演出や操作感の向上に非常に有効です。 しかし、再生速度を単純に上げると、音の高さも一緒に上がってしまい、思い通りのサウンドにならないケースが [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p>音程を高くすることなく、再生速度だけ変える。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/complete-1.gif" alt="" class="wp-image-8436"/></figure>
</div></div>



<p>Unityでゲームやアプリケーションを制作する際、<br><strong>音声の再生速度を変更する</strong>ことは演出や操作感の向上に非常に有効です。</p>



<p>しかし、<strong>再生速度を単純に上げると、音の高さも一緒に上がってしまい</strong>、<br>思い通りのサウンドにならないケースが多々あります。</p>



<p>本記事では、AudioSourceのピッチ設定を利用しつつ、<br>AudioMixerのPitch Shifterを併用することで、再生速度だけを変更し、<br>音程はそのまま維持する方法について詳しく説明します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Unityでオーディオ再生の速度調整に挑戦したい開発者</li>



<li>高品質なサウンドを保ちつつ再生速度を操作したいゲームクリエイター</li>



<li>AudioMixerを活用して音程補正を実現したいエンジニア</li>



<li>UIコンポーネントと連動した実装方法を学びたい初心者プログラマー</li>



<li>実践的なスクリプト例から学び、応用力を高めたい技術者</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">Pitch（AudioSource）</h2>



<p>AudioSourceの<strong>ピッチ（Pitch）</strong>は、音声の再生速度と周波数を決定する重要なパラメータです。</p>



<p>ピッチの値を上げると<strong>再生速度が速くなり、同時に音の高さ（周波数）も上昇</strong>します。<br>ピッチを上げるとこのサンプルレートが相対的に高くなり、<br>波形の周期が短縮されることで音程が上昇します。</p>



<p>たとえば、以下のようにピッチを1.5に設定すると、<br><strong>元の再生速度よりも50％速く再生</strong>され、音程も高く聞こえるようになります。</p>



<p>ピッチの変更は、<strong>Inspectorウィンドウ</strong>のAudioSourceで操作できますが、<br><strong>スクリプトを使う</strong>ことでも制御可能です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>// AudioSourceのピッチを1.5に変更する例
audioSource.pitch = 1.5f;</code></pre></div>



<h2 class="wp-block-heading">PitchShifter</h2>



<p>PitchShifterは、AudioMixer上で動作する<strong>オーディオエフェクト</strong>の一種です。<br>このエフェクトは、再生速度を変更した際に生じる<strong>音程の変化を補正</strong>するために利用されます。</p>



<p>音の高さを変えないためには、AudioSourceのピッチ操作によって速くなった再生速度に合わせ、<br><strong>逆数の値を用いてPitch Shifterを調整する</strong>ことで、音程を元の状態に近づけることが可能となります。</p>



<p>AudioSourceのピッチ操作と同様にInspectorウィンドウからだけではなく、<br><strong>スクリプト制御</strong>が可能です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>// AudioMixerのPitch Shifterパラメータを設定する例（パラメータ名：&quot;PitchShifter&quot;）
audioMixer.SetFloat(&quot;PitchShifter&quot;, 0.75f);</code></pre></div>



<h3 class="wp-block-heading">PitchShifterの作成方法</h3>



<p>PitchShifterを利用するためには、<strong>Unityエディタ内でAudioMixer</strong>を正しく設定し、<br>Pitch Shifterエフェクトを適用する必要があります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/audio_mixer.webp" alt="" class="wp-image-8417" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/audio_mixer.webp 1920w, https://alicia-ing.com/wp-content/uploads/2025/02/audio_mixer-300x147.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/audio_mixer-1024x501.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/audio_mixer-768x376.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/audio_mixer-1536x752.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p>作成したAudioMixerをダブルクリック、あるいはUnityエディタ上部のメニューから「Window」＞「AudioMixer」を選択し、新規または既存のAudioMixerを開きます。</p>



<p>AudioMixerは複数のオーディオグループをまとめて管理できるため、<br>エフェクトの適用や音量調整が容易になります。</p>



<p>作成したAudioMixer内の適用対象となるミキサーグループを選択します。<br>本記事では、「Master」を使用します。<br><strong>「Add…」ボタン</strong>をクリックし、リストから「Pitch Shifter」エフェクトを追加します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1915" height="944" src="https://alicia-ing.com/wp-content/uploads/2025/02/add_pitch_shifter.webp" alt="" class="wp-image-8418" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/add_pitch_shifter.webp 1915w, https://alicia-ing.com/wp-content/uploads/2025/02/add_pitch_shifter-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/add_pitch_shifter-1024x505.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/add_pitch_shifter-768x379.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/add_pitch_shifter-1536x757.webp 1536w" sizes="(max-width: 1915px) 100vw, 1915px" /></figure>



<p>Pitch Shifterエフェクトは、<strong>AudioSourceのピッチ変更に伴う音程のズレを補正</strong>する機能です。</p>



<h3 class="wp-block-heading">エフェクトパラメータのExpose</h3>



<p>Pitch Shifterエフェクトを導入して、ゲームを再生すると<strong>警告文</strong>が出てきます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1917" height="943" src="https://alicia-ing.com/wp-content/uploads/2025/02/alert_exposed.webp" alt="" class="wp-image-8422" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/alert_exposed.webp 1917w, https://alicia-ing.com/wp-content/uploads/2025/02/alert_exposed-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/alert_exposed-1024x504.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/alert_exposed-768x378.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/alert_exposed-1536x756.webp 1536w" sizes="(max-width: 1917px) 100vw, 1917px" /></figure>



<p>警告文の内容は、<strong>PitchShifterがない</strong>というもの。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Exposed name does not exist: PitchShifter<br>UnityEngine.StackTraceUtility:ExtractStackTrace ()</p>
</blockquote>



<p>エフェクト追加後、Pitch Shifterのパラメータをスクリプトから操作できるようにExposeします。</p>



<p>InspectorウインドウのPitch Shifterエフェクトで<strong>パラメータ名を右クリック</strong>します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/expose_pitch.webp" alt="" class="wp-image-8419" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/expose_pitch.webp 1920w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_pitch-300x147.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_pitch-1024x501.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_pitch-768x376.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_pitch-1536x752.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p>「Expose pitch to script」でスクリプト制御を可能にします。<br>さらに、「Exposed Parameters」で<strong>名前を「PitchShifter」に変更</strong>します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/expose_rename.webp" alt="" class="wp-image-8420" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/expose_rename.webp 1920w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_rename-300x147.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_rename-1024x501.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_rename-768x376.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/expose_rename-1536x752.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p>この設定でスクリプト側から<strong>AudioMixer.SetFloat(&#8220;PitchShifter&#8221;, 補正値)</strong>を利用して、<br>エフェクトのパラメータにアクセス可能となります。</p>



<h2 class="wp-block-heading">再生速度だけ上げて高さはそのまま</h2>



<p>再生速度だけを上げて音程（高さ）は変えないように、<br>AudioSourceとAudioMixerの両方を連動させる設定を行ってきました。</p>



<p>そこで、<strong>スライダーを操作して再生速度だけ上げる機能</strong>を作成します。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>スライダーの使い方を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/slider-bar/" title="【Unity】スライダー使い方｜制限時間ゲージ、HPバー、音量調整" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】スライダー使い方｜制限時間ゲージ、HPバー、音量調整</div><div class="blogcard-snippet internal-blogcard-snippet">Unityでスライダー（Slider）の使い方を解説。実用例として制限時間ゲージやHPバー・体力ゲージ、音量調整をスクリプトで紹介します。sliderを離したとき・押したときの処理やデザインの変更を紹介します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.05.03</div></div></div></div></a>
</div>



<p>方法はAudioSourceの<strong>pitch</strong>プロパティを変更して、再生速度を調整する。<br>同時に、AudioMixer上のPitchShifterパラメータに、AudioSourceのpitch値の逆数を設定する。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>csvでaudio再生する方法を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/csv-image-voice/" title="【Unity】csvファイルから画像と音声をパスで読み込み" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/01/csv-image-voice-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/01/csv-image-voice-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/01/csv-image-voice-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/01/csv-image-voice-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】csvファイルから画像と音声をパスで読み込み</div><div class="blogcard-snippet internal-blogcard-snippet">resourcesフォルダーは、Unityで画像や音声、プレハブ、csvを扱う際に便利な機能ですが、メモリの負担が多大きく非推奨な機能です。しかし、規模によっては使用に問題はありません。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">ソースコード</h3>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.Audio;

public class AudioPitchController : MonoBehaviour
{
    public AudioSource audioSource;  // 操作対象の AudioSource
    public Slider pitchSlider;       // スライダー
    public TMP_Text pitchText;       // 再生速度表示用の TMP
    public AudioMixer audioMixer;    // AudioMixer（Pitch Shifterを制御するため）

    private const string PitchShifterParam = &quot;PitchShifter&quot;; // Audio Mixer の Pitch パラメータ

    void Start()
    {
        if (pitchSlider != null)
        {
            pitchSlider.minValue = 0.5f; // スライダーの最小値を0.5
            pitchSlider.maxValue = 2.0f; // スライダーの最大値を2.0
            pitchSlider.value = 1.0f;    // 初期値を1.0
            pitchSlider.onValueChanged.AddListener(UpdatePitch);
        }

        UpdatePitch(pitchSlider.value); // 初期値の設定
    }

    void UpdatePitch(float value)
    {
        // AudioSource の pitch を変更
        if (audioSource != null)
        {
            audioSource.pitch = value; // 再生速度変更
            Debug.Log($&quot;AudioSource.pitch = {audioSource.pitch}&quot;);
        }
        else
        {
            Debug.LogWarning(&quot;AudioSource が設定されていません！&quot;);
        }

        // AudioMixer の Pitch Shifter を調整
        if (audioMixer != null)
        {
            float pitchShifterValue = 1.0f / value; // 逆数にすることで音程を一定に保つ
            audioMixer.SetFloat(PitchShifterParam, pitchShifterValue);
            Debug.Log($&quot;AudioMixer Pitch Shifter = {pitchShifterValue}&quot;);
        }
        else
        {
            Debug.LogWarning(&quot;AudioMixer が設定されていません！&quot;);
        }

        // Text 表示を更新
        if (pitchText != null)
        {
            pitchText.text = $&quot;×{value:F2}&quot;; // 小数2桁で表示
        }
    }
}</code></pre></div>



<h4 class="wp-block-heading">UdemyでUnityを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-micro-text aligncenter micro-text micro-copy micro-top"><span class="micro-text-content micro-content">＼Unityの学習から収益化の方法はこちらから！／</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/roadmap-cs/" title="【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！</div><div class="blogcard-snippet internal-blogcard-snippet">Unityを使って自作ゲームを作りたい方必見。ゲームエンジン選択から学習方法、収益化の手段まで初心者向けにわかりやすく解説します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-777game%2F">【Unity C# ゲーム開発超入門】7つのミニゲームを作っておぼえる！UnityとC#講座</a><br>Unityで頻出の機能を実際のゲーム作りで学習。<br><strong>何か作りたい、今後の開発で役立てたい初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-playing_cards%2F">【Unity C# ゲーム開発初心者レベルアップ】7つのトランプゲームを作っておぼえる！UnityとC#講座</a><br>トランプやボードゲーム作りに特化している講座。<br><strong>テーブルゲームを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" data-type="link" data-id="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F">【全行程を網羅！最初に学びたい総合学習】Unityワールド制作講座<br></a>Unityワールド制作の全工程を学習できる講座。<br><strong>RPGを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fstudio_shimazu_nfrpg%2F">Unity ゲーム開発：インディーゲームクリエイターが教える C#の基礎からゲームリリースまで【スタジオしまづ】</a><br>C#の文法やApp StoreとGoogle Playへゲームをリリース方法を解説。<br><strong>ゲームを出品したい人</strong>におすすめ。</li>
</ul>
</div>



<h3 class="wp-block-heading">解説</h3>



<ul class="wp-block-list">
<li><strong>名前空間</strong></li>
</ul>



<p>UnityEngine：ゲーム開発の基本機能（GameObject、Transform、MonoBehaviourなど）を利用するために必要です。<br>UnityEngine.UI：UIコンポーネント（スライダーなど）を利用するために必要です。<br>TMPro：TextMeshProのテキスト表示機能を利用するために必要です。<br>UnityEngine.Audio：オーディオの再生やミキシング、AudioMixerを操作するために必要です。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Unityで文字を表示する方法を紹介してます。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/textmeshpro/" title="【Unity】TextMeshPro-日本語表示とスクリプト制御" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】TextMeshPro-日本語表示とスクリプト制御</div><div class="blogcard-snippet internal-blogcard-snippet">UnityのTextMeshProは日本語のテキストを美しく表示し、スクリプトでテキストを動的に変更することも可能です。改行は&quot;\n&quot;でします。&quot;japanese_full.txt&quot;ファイルを読み込んでTextMeshProに適用します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<ul class="wp-block-list">
<li><strong>フィールド（メンバ変数）</strong></li>
</ul>



<p>audioSource：音声再生の制御を担うAudioSourceコンポーネントを参照します。<br>pitchSlider：再生速度（ピッチ）の調整に使用するスライダーコンポーネントを参照します。<br>pitchText：現在の再生速度をテキスト表示するためのTextMeshProコンポーネントを参照します。<br>audioMixer：ピッチシフターのパラメータを調整するためのAudioMixerコンポーネントを参照します。<br>PitchShifterParam：AudioMixer内のピッチシフターを制御するためのパラメータ名「PitchShifter」を保持する定数です。</p>



<ul class="wp-block-list">
<li><strong><strong>Startメソッド</strong></strong></li>
</ul>



<p>スライダーが存在する場合、最小値（0.5）、最大値（2.0）、初期値（1.0）を設定し、<br>スライダー値の変化でUpdatePitchメソッドが呼ばれるようリスナーを登録します。</p>



<p>その後、初期値をもとに一度UpdatePitchメソッドを実行し、<br>AudioSourceやAudioMixer、テキスト表示などの初期状態を反映させます。</p>



<ul class="wp-block-list">
<li><strong>UpdatePitchメソッド</strong></li>
</ul>



<p>AudioSourceが設定されていれば、その<strong>pitchプロパティを更新</strong>し、再生速度を変更します。<br>設定されていない場合は警告ログを出力します。</p>



<p>AudioMixerが設定されていれば、<strong>引数の逆数を計算</strong>してピッチシフターのパラメータを調整し、音程を一定に保つよう補正します。</p>



<p>設定されていない場合は警告ログを出力します。<br>TMPテキストが設定されていれば、計算された再生速度を<strong>小数点以下2桁でフォーマット</strong>し、<br>テキストに反映させます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>数値を文字として表示する方法を紹介します。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/object-tostring/" title="【Unity】カウントアップでリザルト画面にスコアを表示" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2022/12/object-tostring-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2022/12/object-tostring-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2022/12/object-tostring-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2022/12/object-tostring-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】カウントアップでリザルト画面にスコアを表示</div><div class="blogcard-snippet internal-blogcard-snippet">Unityでスコアを表示します。カウントアップ機能や別シーンに移動してリザルト画面を表示など紹介しています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.04.16</div></div></div></div></a>
</div>



<h2 class="wp-block-heading">実演</h2>



<p>初めに、シーン内に必要なUIコンポーネントを正しくアタッチしてください。</p>



<p>シーンが開始されると、スクリプトのStartメソッドが実行され、<br>まずUI（特にSlider）の初期設定が行われます。</p>



<p>スライダーの最小値（0.5）、最大値（2.0）、初期値（1.0）が設定され、<br>値が変更されるたびに<strong>UpdatePitchメソッドが呼ばれるようリスナーが登録</strong>されます。</p>



<p>スライダーの値が直接AudioSourceの<strong>pitch</strong>プロパティに反映され、再生速度が変わります。</p>



<p>音の高さが変わらないようにするため、AudioMixerのPitch Shifterパラメータには、<br><strong>スライダーの値の逆数</strong>が適用されます。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>本記事では、UnityにおけるAudioSourceのピッチ操作とAudioMixerのPitch Shifterエフェクトを組み合わせ、<strong>再生速度のみを変更しながらも音程を維持する</strong>方法について解説しました。</p>



<p>この技法は、ゲーム内のBGM、効果音、ナレーションなど、さまざまなシーンで応用可能です。<br>例えば、スローや早送りの演出、ユーザーの操作に応じたリアルタイムな音声変化など、音響面での表現の幅を大きく広げることができます。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/unity/pitchshifter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Unity】スクロールビューの使い方｜等間隔にレイアウト</title>
		<link>https://alicia-ing.com/programming/unity/scroll-view/</link>
					<comments>https://alicia-ing.com/programming/unity/scroll-view/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 16 Feb 2025 22:00:00 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8391</guid>

					<description><![CDATA[Unityのスクロールビュー（ScrollView）は、UI要素をスクロール可能にする便利な機能です。 特に、ゲームやアプリのメニュー画面、ランキング表示、チャットウィンドウなどでよく使われます。 しかし、「スクロールビ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p>スクロールビューの使い方をマスターできる。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/complete.gif" alt="" class="wp-image-8392"/></figure>
</div></div>



<p>Unityの<strong>スクロールビュー（ScrollView</strong>）は、UI要素をスクロール可能にする便利な機能です。</p>



<p>特に、ゲームやアプリの<strong>メニュー画面、ランキング表示、チャットウィンドウ</strong>などでよく使われます。</p>



<p>しかし、「スクロールビューの使い方が分からない」・「要素を等間隔にレイアウトしたい」と悩む人も多いでしょう。</p>



<p>本記事では、<strong>Unityのスクロールビューの基本的な使い方</strong>、要素を適切に配置する方法、スクロールの遅延や重さの解決策について詳細に解説します。</p>



<p>また、自動スクロールの実装、パフォーマンスを最適化するテクニックも紹介します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>UnityのUIシステムを使いこなしたい</li>



<li>ScrollViewの基本的な使い方を学びたい</li>



<li>要素を等間隔にレイアウトする方法を知りたい</li>



<li>スクロールが遅い、重いと感じる原因を知りたい</li>



<li>スマホアプリ開発においてスムーズなスクロールを実現したい</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">スクロールビュー（ScrollView）</h2>



<p>ScrollViewは、<strong>コンテンツが画面サイズを超える</strong>場合に、<br>スクロール可能な領域を提供するUIコンポーネントです。</p>



<p>主に以下のような場面で活用されます。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-light-blue-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#2ca9e1"><div class="tab-caption-box-label block-box-label box-label fab-pencil"><span class="tab-caption-box-label-text block-box-label-text box-label-text">スクロールビューを使用する場面</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li><strong>リスト表示</strong>（ランキングや設定画面など）</li>



<li><strong>インベントリー画面</strong>（アイテム一覧の表示）</li>



<li><strong>メニュー画面</strong>（オプションの多い設定メニューなど）</li>



<li><strong>チャットウィンドウ</strong>（メッセージの履歴を表示）</li>



<li><strong>ギャラリー</strong>（画像一覧やスライドショーなど）</li>



<li><strong>スコアボード</strong>（スコアや実績の表示）</li>
</ul>
</div></div>



<p>UIの中にスライダーがあります。<br><strong>スライダーはゲージとなる</strong>一方で、<strong>スクロールビューは一覧</strong>を表示します。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>スライダーの紹介をしています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/slider-bar/" title="【Unity】スライダー使い方｜制限時間ゲージ、HPバー、音量調整" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/01/slider-bar-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】スライダー使い方｜制限時間ゲージ、HPバー、音量調整</div><div class="blogcard-snippet internal-blogcard-snippet">Unityでスライダー（Slider）の使い方を解説。実用例として制限時間ゲージやHPバー・体力ゲージ、音量調整をスクリプトで紹介します。sliderを離したとき・押したときの処理やデザインの変更を紹介します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.05.03</div></div></div></div></a>
</div>



<h2 class="wp-block-heading">スクロールビューの使い方</h2>



<p>スクロールビューは、Hierarchyウィンドウの「UI」から「<strong>Scroll View</strong>」で追加します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/UI_scrollview.webp" alt="" class="wp-image-8393" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/UI_scrollview.webp 1920w, https://alicia-ing.com/wp-content/uploads/2025/02/UI_scrollview-300x147.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/UI_scrollview-1024x501.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/UI_scrollview-768x376.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/UI_scrollview-1536x752.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p>作成したスクロールビューが小さいので、画面にサイズが合うようにします。<br>自分でWidthとHeightを調整してもよいですが、「<strong>Anchor Presets</strong>」でサイズ変更もできます。</p>



<p>「Altキー」を押しながら、縦（高さ）を画面に自動調整を指示します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/scrollview_presets_0000.webp" alt="" class="wp-image-8394" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/scrollview_presets_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2025/02/scrollview_presets_0000-300x147.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/scrollview_presets_0000-1024x501.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/scrollview_presets_0000-768x376.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/scrollview_presets_0000-1536x752.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>画面サイズの変更を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/game-screen-size/" title="【Unity】画面サイズの変更、合わせる設定とおすすめの比率" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/03/game-screen-size-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/03/game-screen-size-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/03/game-screen-size-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/03/game-screen-size-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】画面サイズの変更、合わせる設定とおすすめの比率</div><div class="blogcard-snippet internal-blogcard-snippet">Unityで画面サイズのおすすめとUI設置を最適化する方法を解説。各プラットフォームやノベルゲーム、パズルゲーム、RPGなど各ゲームに合わせた画面比率で画面のサイズを変えて、さらに動的なUI操作のヒントを提供します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.05.03</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">Layout Group</h3>



<p>スクロールビュー内に画像UIのようなコンテンツを入れるには、<br>Viewportの配下<strong>「Content」の子要素</strong>にする必要があります。</p>



<p>しかし、ただ要素を入れるだけでは<strong>オブジェクトが重なってしまう問題</strong>が発生します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/Layout_Group_0000.webp" alt="" class="wp-image-8395" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/Layout_Group_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2025/02/Layout_Group_0000-300x147.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/Layout_Group_0000-1024x501.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/Layout_Group_0000-768x376.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/Layout_Group_0000-1536x752.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p>そこで、「<strong>Layout Group</strong>」のcomponentを使用して要素を配置します。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-light-green-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#8bc34a"><div class="tab-caption-box-label block-box-label box-label fab-graduation-cap"><span class="tab-caption-box-label-text block-box-label-text box-label-text">Layout Group</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Grid：格子状に配置</li>



<li>Horizontal：水平（横方向）に配置</li>



<li><strong>Vertical</strong>：垂直（縦方向）に配置</li>
</ul>
</div></div>



<p>縦方向のスクロールでは<strong>マウスのスクロールと対応しやすい</strong>ので、<br>ユーザーがストレスなく操作しやすくなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/Vertical_Layout_Group_0000.webp" alt="" class="wp-image-8396" srcset="https://alicia-ing.com/wp-content/uploads/2025/02/Vertical_Layout_Group_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2025/02/Vertical_Layout_Group_0000-300x147.webp 300w, https://alicia-ing.com/wp-content/uploads/2025/02/Vertical_Layout_Group_0000-1024x501.webp 1024w, https://alicia-ing.com/wp-content/uploads/2025/02/Vertical_Layout_Group_0000-768x376.webp 768w, https://alicia-ing.com/wp-content/uploads/2025/02/Vertical_Layout_Group_0000-1536x752.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-light-green-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#8bc34a"><div class="tab-caption-box-label block-box-label box-label fab-graduation-cap"><span class="tab-caption-box-label-text block-box-label-text box-label-text">Layout Groupプロパティ</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Padding：ScrollView 内の Content の余白を指定する。</li>



<li>Spacing：子オブジェクト（要素）間の間隔を指定する。</li>



<li>Child Alignment：子オブジェクトの整列位置を指定する。</li>



<li>Reverse Arrangemer：子オブジェクトの並び順を逆にする。</li>



<li>Control Child Scale：子オブジェクトの Scale を自動調整するかどうかを決める。</li>



<li>Use Child Size：子オブジェクトのサイズをそのままレイアウトに適用するかどうか。</li>



<li>Child Force Expand：子オブジェクトを親のサイズに合わせて強制的に拡張する。</li>
</ul>
</div></div>



<h3 class="wp-block-heading">スクロールできない</h3>



<p>Layout Groupを設定し、配列を整えました。<br>しかし、<strong>スクロールバーが消えて、下まで進めてもコンテンツが元に戻ってしまう</strong>。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/fail_scroll.gif" alt="" class="wp-image-8397"/></figure>



<p>原因は、<strong>「Content」の大きさが適切ではない</strong>ということです。<br><strong>決まった情報をプレイヤーに提供</strong>するならばはじめからサイズ指定が有効ですが、<br>プレイヤーの行動によって<strong>情報量が増える</strong>ならば大きさを指定することは難しいです。</p>



<p>スクロールバーをコンテンツに応じて変えるときは、<br>componentから「<strong>Content Size Fitter</strong>」を追加します。</p>



<p>Content Size Fitterは、UI 要素（RectTransform）の<strong>サイズをその内容に応じて自動調整する</strong>ための Layout Component です。</p>



<p>今回のように<strong>ScrollViewのContentに適用</strong>して、子要素に応じたサイズ変更を行うのに使われます。<br>特に、<strong>Layout Groupと併用</strong>すると効果的です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/scroll_sizefitter.gif" alt="" class="wp-image-8401"/></figure>



<h2 class="wp-block-heading">スクロールが重い</h2>



<p>初期のスクロールビューでは、<strong>スクロールしてもコンテンツが全く動きません</strong>。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="940" src="https://alicia-ing.com/wp-content/uploads/2025/02/scroll_sensitivity.gif" alt="" class="wp-image-8400"/></figure>



<p>要素が多すぎて動きが重いということもありますが、<br>基本的には「<strong>Scroll Sensitivity</strong>」で解決できます。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-light-green-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#8bc34a"><div class="tab-caption-box-label block-box-label box-label fab-thumbs-up"><span class="tab-caption-box-label-text block-box-label-text box-label-text">スクロールビュープロパティー</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li><strong>Viewport</strong>: 表示される領域を指定</li>



<li><strong>Content</strong>: スクロールするコンテンツを含むオブジェクト</li>



<li><strong>Scrollbar</strong>: 水平方向・垂直方向のスクロールバーの有無</li>



<li><strong>Movement Type</strong>: スクロールの挙動（Elastic, Clamped など）</li>



<li><strong>Inertia</strong>: 慣性スクロールのオン/オフ</li>



<li><strong>Scroll Sensitivity</strong>: スクロールの感度を調整</li>



<li><strong>Elasticity</strong>: 端に達したときの反動の強さを設定</li>
</ul>
</div></div>



<h2 class="wp-block-heading">まとめ</h2>



<p>また、ユーザーの操作なしにスクロールを自動で行う場合、以下のように Lerp を活用できます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>void Update()
{
    scrollRect.verticalNormalizedPosition = Mathf.Lerp(scrollRect.verticalNormalizedPosition, 0, Time.deltaTime * 0.5f);
}</code></pre></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/unity/scroll-view/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Python】進捗バーを自作、作成する方法｜tqdmの使い方</title>
		<link>https://alicia-ing.com/programming/python/tqdm-progress-bar/</link>
					<comments>https://alicia-ing.com/programming/python/tqdm-progress-bar/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 01 Dec 2024 22:00:00 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8257</guid>

					<description><![CDATA[Pythonで処理する際に、どれだけ処理が完了したのかコンソール画面に表示します。進捗バー（プログレスバー）を作成したい方に向けて、tqdmを使用した進捗表示の方法を解説します。 本記事では、tqdmの基本の使い方や実際 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p>Pythonで進捗バーを表示する。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1000" src="https://alicia-ing.com/wp-content/uploads/2024/12/complete.gif" alt="実行例" class="wp-image-8266"/></figure>
</div></div>



<p>Pythonで処理する際に、どれだけ<strong>処理が完了したのかコンソール画面に表示</strong>します。<br>進捗バー（プログレスバー）を作成したい方に向けて、tqdmを使用した進捗表示の方法を解説します。</p>



<p>本記事では、tqdmの基本の使い方や実際のソースコードを例示し、<br>処理の進捗をわかりやすく表示する方法を紹介します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Pythonで進捗バーを使いたい人</li>



<li>処理の進捗を視覚的に表示したい開発者</li>



<li>大量データを処理する際の進捗表示をスマートに実装したい方</li>



<li>tqdmの基本的な使い方を覚えたい人</li>



<li>Pythonで自動化処理を行う際に進捗ゲージを追加したい方</li>



<li>処理時間が長い作業の進捗をわかりやすく表示したい方</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">tqdmとは</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/12/tqdm.webp" alt="tqdmについて" class="wp-image-8268" srcset="https://alicia-ing.com/wp-content/uploads/2024/12/tqdm.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/12/tqdm-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/12/tqdm-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/12/tqdm-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>モジュールtqdmは、<strong>処理の進捗を視覚的に表示するための便利なライブラリ</strong>です。</p>



<p>大量のデータや複数の処理を行う際、その進捗を表示することで、<br><strong>開発者やユーザーに安心感を提供</strong>します。</p>



<p>進捗表示を使うことで、大規模なプロジェクトや複雑なタスクでも、<br>現在どの程度進行しているのかを一目で把握できるようになります。</p>



<p>例えば、データ処理の際にも、どれくらいの作業が完了したか、<br><strong>予定に対してどれだけ進んでいるのかを視覚化</strong>することが可能です。</p>



<p>tqdmをインストールするには、pipを使用します。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>pip install tqdm</code></pre></div>



<h3 class="wp-block-heading">基本的な機能</h3>



<p>基本的な使い方としては、<strong>forループにtqdmを追加するだけ</strong>で、<br>簡単に進捗バーを表示することができます。</p>



<p>tqdmは、処理の進行状況を正確に視覚化するだけでなく、<br>プログラムのパフォーマンスにほとんど負担をかけずに自然に表示できるので、非常に便利です。</p>



<p>また、進捗をリアルタイムで確認できるため、<br>長時間の処理でもユーザーに安心感を与えることができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from tqdm import tqdm
import time

for i in tqdm(range(10), desc=&quot;Processing&quot;):
    time.sleep(0.5)  # 一時停止を作る</code></pre></div>



<p>このコードでは、10回のループを繰り返している間に進捗バーが表示されます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>timeモジュールのsleep関数を使ったカウントダウンタイマーを解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/countdown-timer/" title="【Python】カウントダウンタイマー｜sleepでタイマー処理" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/02/countdown-timer-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/02/countdown-timer-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/02/countdown-timer-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/02/countdown-timer-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Python】カウントダウンタイマー｜sleepでタイマー処理</div><div class="blogcard-snippet internal-blogcard-snippet">Pythonでのタイマーとカウントダウンの作り方は、tkinterを使用してsleep関数とtimerを組み合わせ、使いやすいタイマーを実装できます。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<p><strong>descを使って処理内容を説明</strong>することで、<br>何をしているのかをユーザーにわかりやすく伝えることができます。</p>



<p>これにより、ユーザーにも進行状況が伝わり、処理が進んでいる感覚を共有できます。</p>



<h2 class="wp-block-heading">すべての処理の完了率をゲージで表示</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/12/completion-rate.webp" alt="完了率表示" class="wp-image-8269" srcset="https://alicia-ing.com/wp-content/uploads/2024/12/completion-rate.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/12/completion-rate-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/12/completion-rate-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/12/completion-rate-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>指定されたフォルダ内の画像ファイルを<strong>WebP形式に変換する処理</strong>を実行します。</p>



<p>処理は、フォルダ内のファイルを順次ループし、<br>PillowライブラリのImage関数を使って画像をWebP形式に変換します。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>webpに一括変換を解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/image-conversion/" title="【Python】pngやjpgの画像をwebpに一括で画像変換" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/06/image-conversion-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/06/image-conversion-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/06/image-conversion-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/06/image-conversion-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Python】pngやjpgの画像をwebpに一括で画像変換</div><div class="blogcard-snippet internal-blogcard-snippet">pngやjpeg、bmpを画像変換するためにフリーソフトを探しても求めるものがないときはPythonのpillow,osモジュールで一括でwebpにします。自作ならwindows、macの対応を気にせず、応用でheicやavifもできます。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<p>その際、<strong>tqdmを用いて進捗状況を一歩ずつ表示し、処理の完了までの時間を視覚化</strong>しています。</p>



<p>これにより、処理がどの程度進んでいるかを簡単に把握することができ、<br>使用者や開発者が実行時間を予測したり、<strong>処理の進行を確認することが可能</strong>です。</p>



<p>また、処理中にエラーが発生した場合、どのファイルで問題が発生したのかを明確に特定できるため、トラブルシューティングも容易です。</p>



<h3 class="wp-block-heading">ソースコード・解説</h3>



<ul class="wp-block-list">
<li><strong>モジュール名</strong></li>
</ul>



<p>「PIL (Pillow)」：Python Imaging Library（PIL）を拡張したPillowモジュールは、画像ファイルの読み込みや保存、編集を行うために必要です。インストールは「pip install Pillow」を使用します。<br>「os」：ファイルやディレクトリのパス操作を行うために必要です。特にフォルダの存在確認やファイルのパス取得に使用します。<br>「tqdm」：長時間実行する処理の進捗状況を視覚的に表示するために必要です。インストールは「pip install tqdm」を使用します。<br>「time」：処理に微小な遅延を持たせるために必要です。これにより進捗バーが滑らかに動くように見せる効果があります。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from PIL import Image
import os
from tqdm import tqdm
import time</code></pre></div>



<ul class="wp-block-list">
<li><strong>フィールド（メンバ変数）</strong></li>
</ul>



<p>「input_folder」：変換対象となる画像ファイルが格納されているフォルダのパスです。<br>「output_folder」：変換後の画像ファイルを保存するためのフォルダのパスです。<br>「file_list」：入力フォルダ内の変換対象画像ファイルのリストです。<br>「progress_bar」：tqdmによって生成される進捗バーオブジェクトで、処理の進捗を視覚的に表示するためのものです。<br>「input_path」：入力画像ファイルの絶対パスです。<br>「output_path」：変換後のWebP形式の画像ファイルの絶対パスです。</p>



<ul class="wp-block-list">
<li><strong>convert_to_webp関数</strong></li>
</ul>



<p>この関数は、指定されたフォルダ内の画像ファイルをWebP形式に変換する処理を行います。</p>



<p>最初に出力フォルダが存在しない場合は新たに作成し、<br>入力フォルダ内の画像ファイルを拡張子でフィルタリングして取得します。</p>



<p>取得したファイルリストを使って、<strong>一つずつ画像ファイルを開き</strong>、<br>WebP形式に変換して出力フォルダに保存します。</p>



<p><strong>処理の進捗状況はtqdmで表示</strong>し、<br>全てのファイルが処理されるとメッセージを表示します。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>def convert_to_webp(input_folder, output_folder):
    # 出力フォルダが存在しない場合は作成する
    if not os.path.exists(output_folder):
        os.makedirs(output_folder)

    # フォルダ内のファイルを取得する
    file_list = [f for f in os.listdir(input_folder) if f.lower().endswith((&#39;.png&#39;, &#39;.jpg&#39;, &#39;.jpeg&#39;, &#39;.gif&#39;, &#39;.bmp&#39;))]

    # ファイル数が0の場合、処理を終了
    if not file_list:
        print(&quot;画像ファイルが見つかりませんでした。&quot;)
        return

    # tqdmで進捗バーを作成
    progress_bar = tqdm(total=len(file_list), desc=&quot;変換中&quot;, unit=&quot;file&quot;, smoothing=0.1)

    for file_name in file_list:
        # ファイルの絶対パスを取得する
        input_path = os.path.join(input_folder, file_name)
        output_path = os.path.join(output_folder, os.path.splitext(file_name)[0] + &#39;.webp&#39;)

        # 画像を開いてWebP形式で保存する
        try:
            with Image.open(input_path) as image:
                image.save(output_path, &#39;webp&#39;)
        except Exception as e:
            print(f&quot;エラー: {file_name} ({e})&quot;)

        # 進捗バーを更新
        progress_bar.update(1)
        time.sleep(0.01)  # 流れる感覚を持たせるための微小な遅延

    progress_bar.close()
    print(&quot;全ての画像の変換が完了しました！&quot;)

# フォルダのパスを指定して変換を実行する
input_folder = &#39;Input&#39;
output_folder = &#39;Output&#39;

convert_to_webp(input_folder, output_folder)</code></pre></div>



<h4 class="wp-block-heading">UdemyでPythonを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython-beginner%2F">現役シリコンバレーエンジニアが教えるPython 3 入門 + 応用 +アメリカのシリコンバレー流コードスタイル</a><br>Pythonをインストールから環境設定、基本文法が学習<br>さらに暗号化、インフラ自動化、非同期処理についても学べます。<br><strong>Pythonを基礎から応用まで学びたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Flearning-ai%2F">みんなのAI講座 ゼロからPythonで学ぶ人工知能と機械学習 【2024年最新版】</a><br>機械学習ライブラリで文字認識や株価分析などを行う。<br><strong>人口知能やニューラルネットワーク、機械学習を学びたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fdatascience365%2F">【世界で55万人が受講】データサイエンティストを目指すあなたへ〜データサイエンス25時間ブートキャンプ〜</a><br>統計分析、機械学習の実装、ディープラーニングの実装を学習。<br><strong>データサイエンティストになりたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython_tkinter_master%2F">0から始めるTkinterの使い方完全マスター講座〜Python×GUIの基礎・応用〜</a><br>TkinterのGUIを作成から発展的な操作までアプリ実例を示して学習。<br><strong>アプリ開発したい人</strong>におすすめ。</li>
</ul>
</div>



<h2 class="wp-block-heading">実演</h2>



<p>プログラムを実行すると、冒頭で示したような進捗バーが表示されます。</p>



<p>本記事での例では、画像変換なのであまり進捗バーの役割を成さないですが、<br><strong>動画や人工知能などの大きいデータを扱う場合は進捗バー</strong>があるとプログラムが動いているのか把握できます。</p>



<p>必要に応じて、プログレスバーを導入してください。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>本記事では、Pythonで進捗バーを作成するためのライブラリ、tqdmの使い方を解説しました。</p>



<p>既存のスクリプトにtqdmを実装することで、処理の進捗を視覚的に確認しながら、<br>効率的に作業を進めることが可能になります。</p>



<p>tqdmを使うことで、従来の処理に比べてよりユーザーフレンドリーな体験を提供し、<br>開発者は実行中の処理を可視化しやすくなり、デバッグや評価時の助けにもなります。</p>



<p>次回の開発では、さらに複雑な処理にもこの進捗表示を実装して、便利さを向上させていきましょう。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/python/tqdm-progress-bar/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Python】Google-Text-to-SpeechのAPIを取得し発話</title>
		<link>https://alicia-ing.com/programming/python/google-text-to-speech/</link>
					<comments>https://alicia-ing.com/programming/python/google-text-to-speech/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 24 Nov 2024 22:00:00 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8095</guid>

					<description><![CDATA[GoogleのText-to-Speech APIを使えば、Pythonを用いて簡単にテキストを音声に変換できます。 本記事では初めての方にも分かりやすく、APIの取得方法からPythonでの実装までを詳しく解説していき [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p>Google Text-to-SpeechをPythonから制御する。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1000" src="https://alicia-ing.com/wp-content/uploads/2024/11/complete-1.gif" alt="" class="wp-image-8220"/></figure>
</div></div>



<p>GoogleのText-to-Speech APIを使えば、<br><strong>Pythonを用いて簡単にテキストを音声に変換</strong>できます。</p>



<p>本記事では初めての方にも分かりやすく、<br><strong>APIの取得方法からPythonでの実装</strong>までを詳しく解説していきます。</p>



<p>また、商用利用や料金、音声ファイルの保存方法など、<br>Pythonで自動音声生成を行う手順を完全に理解できる内容となっています。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Pythonでテキストを音声に変換したい方</li>



<li>Google Text-to-Speechを使って多言語対応の発話システムを作りたい方</li>



<li>商用プロジェクトで音声合成を利用したいと考えている方</li>



<li>音声データを自動生成してMP3形式で保存したい方</li>



<li>教育コンテンツや自動ナレーションを簡単に作成したい方</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">Google Text-to-Speechとは</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-1.webp" alt="Text-to-Speechについて" class="wp-image-8223" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-1.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-1-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-1-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-1-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>Google Text-to-Speechはテキストを音声に変換するサービスで、<br>無料で使える発話エンジンです。</p>



<p>日本語、英語、フランス語など、<strong>多くの言語に対応</strong>していて幅広い用途で利用できます。</p>



<p>Pythonと組み合わせることで、さまざまな<strong>音声アプリケーションを簡単に作成</strong>できます。<br>たとえば、ナビゲーションシステムや教育アプリ、自動応答システムなど用途は無限大です。</p>



<p>Google Text-to-SpeechはAI技術を駆使して、<strong>自然で高品質な音声を生成</strong>します。<br>これにより、ユーザーにとって使いやすく、聞き心地の良い音声を提供することが可能です。</p>



<p>また、Text-to-Speechはアクセントや話者のトーンなども調整可能なため、<br>さまざまな音声タイプをカスタマイズできます。</p>



<h3 class="wp-block-heading">Google Text-to-Speechの使い方</h3>



<p>Google Text-to-Speechを使うには、まず<strong>Google Cloudのアカウントを作成</strong>し、<br>Text-to-Speechを有効にする必要があります。</p>



<p>Pythonのプログラムから音声合成を行うためには、<br><strong>Google Cloudの認証情報（APIキー）を取得して設定する</strong>必要があります。</p>



<p>Pythonコードを用いることで、<strong>指定したテキストを音声に変換</strong>し、<br><strong>WAVやMP3形式で保存することが可能</strong>です。</p>



<p>これにより、手軽に音声ガイドやナレーションを自動生成することができます。<br>例えば、観光案内アプリでの音声案内や教育用の教材など、多種多様な用途で活用できます。</p>



<p>また、テキストの内容に基づいて<strong>発話速度やピッチも調整できる</strong>ため、<br>さまざまなシチュエーションに対応した音声を生成することが可能です。</p>



<h3 class="wp-block-heading">Google Text-to-Speechは商用利用できる？</h3>



<p>Google Text-to-Speechは<strong>商用利用も可能</strong>です。<br>ただし、Google Cloudの使用量に応じた料金が発生するため、<br><strong>商用プロジェクトで利用する際は料金体系に十分注意</strong>する必要があります。</p>



<p>また、Googleの利用規約に従って、適切に利用することが求められます。</p>



<p>商用利用する場合、特に注意すべきなのは<strong>利用料金と使用制限</strong>です。<br>料金は使用量に依存しているため、大量に音声を生成する場合は予算に応じて計画的に使うことが求められます。API使用数を確認しながら調整する必要があります。</p>



<p>また、商用利用に際しては、エンドユーザーに対する<strong>情報提供やプライバシーの保護</strong>に対しても責任を持つ必要があります。これらを十分に理解したうえで、商用利用を進めることが大切です。</p>



<h4 class="wp-block-heading">pyttsx3との比較</h4>



<p>合成音声pyttsx3の場合は、PC搭載の読み上げ機能を使うためAPIを必要としません。<br>ただし、<strong>pyttsx3自体は商用利用できます</strong>が、読み上げソフトが商用利用できません。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>pyttsx3の使い方を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/pyttsx3-text-to-speech/" title="【Python】合成音声pyttsx3使い方-テキストを読み上げ" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/09/pyttsx-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/09/pyttsx-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/09/pyttsx-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/09/pyttsx-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Python】合成音声pyttsx3使い方-テキストを読み上げ</div><div class="blogcard-snippet internal-blogcard-snippet">Pythonの合成音声ライブラリ「pyttsx3」の基本的な使い方とその機能について。pyttsx3は、テキストの読み上げから、音声ファイルの生成、プロパティの変更に対応します。さらに、商用利用可能（ソフトは別途）や日本語、英語に対応。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.11.26</div></div></div></div></a>
</div>



<p>要するに、個人で合成音声を使いたい場合は、pyttsx3を使用して、<br>ゲームやアプリのナレーションに追加したい場合は、<br><strong>Google Text-to-Speechを使う</strong>必要があります。</p>



<h3 class="wp-block-heading">Google Text-to-Speechの料金（無料枠）は？</h3>



<p>無料枠の利用では、<strong>月に400万文字（WaveNetは100万文字）</strong>まで音声合成が可能です。<br>それを<strong>超えた場合は従量課金制</strong>で料金が発生します。</p>



<p>商用利用を検討している場合、<a target="_self" href="https://cloud.google.com/text-to-speech/pricing?hl=ja">Google Cloudの料金表</a>を確認し、<br>必要な予算を見積もっておくことが重要です。</p>



<p>料金は、使用する声の種類や文字数に依存します。<br>例えば、<strong>標準的な音声とWaveNet音声</strong>（より自然な音声）では料金が異なります。</p>



<p>WaveNet音声はより高品質ですが、<strong>その分料金が高く</strong>なります。<br>また、<strong>使用する言語や地域によっても料金が変動</strong>することがありますので、<br>事前に詳細を確認することをお勧めします。</p>



<p>Google Cloudの無料利用枠を活用することで、コストを抑えながらプロトタイプを作成したり、個人プロジェクトで利用する際には、<strong>無料枠で十分対応できるケースが多い</strong>です。</p>



<p>ビジネス規模での利用に関しては、必要な予算を正確に把握し、<br>適切なプランを選択することが重要です。</p>



<h3 class="wp-block-heading">Google Text-to-SpeechはMP3保存できる？</h3>



<p>Google Text-to-Speechの音声合成はをMP3形式で保存することが可能です。</p>



<p>Pythonからテキストを取得して、そのままMP3またはWAV形式で保存することができます。この機能を使うことで、簡単に<strong>ナレーション用の音声ファイルを生成する</strong>ことが可能になります。</p>



<p>例えば、教育コンテンツやオーディオブックの自動生成に<strong>MP3保存機能を活用</strong>することができます。音声ファイルは高音質で保存され、聞き取りやすいものとなります。</p>



<p>また、MP3形式で保存することで、さまざまなデバイスで再生可能な音声ファイルを作成することができます。これにより、<strong>ユーザーの利便性を高める</strong>ことができ、プロジェクトの成功に寄与します。</p>



<p><strong>WAV形式に比べてMP3形式はファイルサイズが小さい</strong>ため、<br>オンラインでの共有やストレージの節約にも有利です。</p>



<p>Pythonを使用して<strong>MP3形式に保存する</strong>ことで、<br>音声ファイルの管理が簡単になり、アプリケーションの効率的な運用が可能となります。</p>



<p>作成した動画にナレーションを入れたい場合、<br><strong>moviepyを併用する</strong>ことで、簡単にナレーション音声を導入できます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>moviepyの機能をまとめています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/moviepy/" title="【Python】moviepyできること｜mp3・GIF編集変換" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/11/moviepy-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/moviepy-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/11/moviepy-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/11/moviepy-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Python】moviepyできること｜mp3・GIF編集変換</div><div class="blogcard-snippet internal-blogcard-snippet">MoviePyで動画編集を自動化！Pythonでカット、結合、リサイズからGIF変換まで簡単に行えるMoviePyの基本から応用的な使い方を徹底解説。動画編集を効率化したいプログラマーやSNS素材作成に挑戦したい方におすすめのガイドです。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.11.22</div></div></div></div></a>
</div>



<h2 class="wp-block-heading">Google Text-to-Speechの登録方法</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/how_to_register.webp" alt="アカウント作成について" class="wp-image-8224" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/how_to_register.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/how_to_register-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/how_to_register-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/how_to_register-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>Google Text-to-Speechを使うにはまずGoogle Cloudのアカウントを作成します。<br>「Google Cloud」にアクセスして、<strong>アカウント情報や支払い方法を入力</strong>します。</p>



<p>Cloud Speech-to-Textを有効にして、APIを取得します。</p>



<h3 class="wp-block-heading">アカウント作成</h3>



<p>「<a target="_self" href="https://cloud.google.com/text-to-speech/?hl=ja">Text-to-Speechの無料トライアル</a>」にアクセスし、Googleアカウントを用いてログインします。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="1879" height="953" src="https://alicia-ing.com/wp-content/uploads/2024/11/register_account.webp" alt="アカウント作成" class="wp-image-8205" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/register_account.webp 1879w, https://alicia-ing.com/wp-content/uploads/2024/11/register_account-300x152.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/register_account-1024x519.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/register_account-768x390.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/register_account-1536x779.webp 1536w" sizes="(max-width: 1879px) 100vw, 1879px" /></figure>



<p>アカウント作成する際に、<strong>支払い方法を登録</strong>（クレジットカード・デビットカードなど）する必要があります。</p>



<p>既に、Google広告やアドセンスに登録している場合は、再度追加しなくてもよいです。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="1884" height="1064" src="https://alicia-ing.com/wp-content/uploads/2024/11/register_card.webp" alt="" class="wp-image-8206" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/register_card.webp 1884w, https://alicia-ing.com/wp-content/uploads/2024/11/register_card-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/register_card-1024x578.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/register_card-768x434.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/register_card-1536x867.webp 1536w, https://alicia-ing.com/wp-content/uploads/2024/11/register_card-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/11/register_card-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/11/register_card-320x180.webp 320w" sizes="(max-width: 1884px) 100vw, 1884px" /></figure>



<p><br>アカウント作成が完了したら、Google Cloudのさまざまなサービスを利用するための準備が整います。</p>



<p>プロジェクトの管理は、<strong>Google Cloudコンソールから</strong>簡単に行えます。<br>プロジェクトの概要や利用状況の確認、APIの有効化など、必要な操作を行うことで、プロジェクトをスムーズに進められます。</p>



<h3 class="wp-block-heading">Text-to-Speechを有効にする</h3>



<p>ハンバーガーメニューから「APIとサービス&gt;ライブラリ」に移動して、<br>「<strong>Cloud Text-to-Speech API</strong>」を有効にします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1884" height="934" src="https://alicia-ing.com/wp-content/uploads/2024/11/library.webp" alt="ライブラリの場所" class="wp-image-8208" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/library.webp 1884w, https://alicia-ing.com/wp-content/uploads/2024/11/library-300x149.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/library-1024x508.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/library-768x381.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/library-1536x761.webp 1536w" sizes="(max-width: 1884px) 100vw, 1884px" /></figure>



<p>見つけることができない場合は、検索バーから探します。</p>



<div class="wp-block-cocoon-blocks-sticky-box blank-box block-box sticky st-red">
<p>Cloud <strong>Speech-to-Text</strong> APIというものがあります。<br>こちらは発話から文字に起こします。<br><strong>動画の音声を字幕を自動で書き起こしたい</strong>ときに使えます。</p>
</div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1884" height="875" src="https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech.webp" alt="APIを有効" class="wp-image-8209" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech.webp 1884w, https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-300x139.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-1024x476.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-768x357.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/Text-to-Speech-1536x713.webp 1536w" sizes="(max-width: 1884px) 100vw, 1884px" /></figure>



<p>APIの有効化後、実際に音声合成のリクエストを行えるようになります。APIの有効化は簡単に行うことができ、あとは<strong>必要な認証情報を設定する</strong>ことでPythonから操作が可能です。</p>



<h3 class="wp-block-heading">.jsonのAPIを取得</h3>



<p>サイドバーから「IAMと管理&gt;サービスアカウント」に進み、<br>サービスアカウントを作成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1468" height="1080" src="https://alicia-ing.com/wp-content/uploads/2024/11/service_account.webp" alt="" class="wp-image-8210" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/service_account.webp 1468w, https://alicia-ing.com/wp-content/uploads/2024/11/service_account-300x221.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/service_account-1024x753.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/service_account-768x565.webp 768w" sizes="(max-width: 1468px) 100vw, 1468px" /></figure>



<p>詳細情報に、サービスアカウント名を設定します。<br>指定すると<strong>自動でサービスアカウントIDが生成</strong>されます。</p>



<p>そのほかの情報は<strong>省略可能</strong>ですので、そのままで大丈夫です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1835" height="1080" src="https://alicia-ing.com/wp-content/uploads/2024/11/account_detail.webp" alt="" class="wp-image-8211" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/account_detail.webp 1835w, https://alicia-ing.com/wp-content/uploads/2024/11/account_detail-300x177.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/account_detail-1024x603.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/account_detail-768x452.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/account_detail-1536x904.webp 1536w" sizes="(max-width: 1835px) 100vw, 1835px" /></figure>



<p>作成後、「操作」の3点マークから「<strong>鍵を管理</strong>」に進みます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1558" height="1027" src="https://alicia-ing.com/wp-content/uploads/2024/11/make_key.webp" alt="" class="wp-image-8212" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/make_key.webp 1558w, https://alicia-ing.com/wp-content/uploads/2024/11/make_key-300x198.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/make_key-1024x675.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/make_key-768x506.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/make_key-1536x1012.webp 1536w" sizes="(max-width: 1558px) 100vw, 1558px" /></figure>



<p>「キー」タブから「鍵を追加」を選択して、<br><strong>JSONファイルを作成</strong>します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1080" src="https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API.webp" alt="" class="wp-image-8213" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API.webp 1920w, https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API-1024x576.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API-1536x864.webp 1536w, https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/11/JSON_API-320x180.webp 320w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p>JSONファイルには、<strong>APIにアクセスするための認証情報</strong>が含まれています。</p>



<p>このファイルを適切に管理することで、安全にGoogle Cloudのサービスを利用することが可能です。Pythonスクリプトからこのファイルを参照することで、<br><strong>音声合成のリクエストを安全に行う</strong>ことができます。</p>



<h2 class="wp-block-heading">PythonでGoogle Text-to-Speechを操作</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/operation.webp" alt="Pythonで動かすには" class="wp-image-8225" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/operation.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/operation-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/operation-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/operation-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>Google Text-to-Speech APIをPythonで操作することで、<br>CSVファイルに格納したテキストを音声ファイルに変換することができます。</p>



<p>CSVのA列に英単語を格納してそれを一行ずつ読み込んで音声合成し、<br><strong>WAVファイルとして保存</strong>することが可能です。</p>



<p>Pythonを使うことで、<strong>業務での自動化や学習教材の作成</strong>など、さまざまなシーンで活用できます。<br>特に、複数のテキストを一括で音声化したい場合に便利です。</p>



<p>例えば、数百行にわたるテキストデータを<strong>自動で音声ファイルに変換</strong>し、<br>ナレーションやガイドとして利用することができます。</p>



<p>手作業で音声を録音する<strong>手間を大幅に削減する</strong>ことができ、<br>生産性を向上させることができます。</p>



<p>また、教育機関での学習用資料の作成や、<strong>自動応答システムの開発にも応用</strong>できます。</p>



<h3 class="wp-block-heading">ソースコード</h3>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>import os
import csv
from google.cloud import texttospeech

# 認証情報のパスを設定
os.environ[&#39;GOOGLE_APPLICATION_CREDENTIALS&#39;] = &#39;key.json&#39;

# 音声生成関数
def generate_audio(csv_path):
    # 保存先ディレクトリをCSVファイルと同じ場所に設定
    save_directory = os.path.dirname(csv_path)
    
    # Google Cloud TTSクライアントの作成
    client = texttospeech.TextToSpeechClient()
    
    # CSVファイルの読み込み
    with open(csv_path, &#39;r&#39;, newline=&#39;&#39;, encoding=&#39;utf-8&#39;) as csvfile:
        reader = csv.reader(csvfile)
        
        # 各行のA列を順番に処理
        for index, row in enumerate(reader):
            if len(row) &gt; 0:  # A列に値があるか確認
                word = row[0]  # A列の単語を取得
                
                # テキスト入力の設定
                synthesis_input = texttospeech.SynthesisInput(text=word)
                
                # 音声の設定（en-US-Standard-J話者を使用）
                voice = texttospeech.VoiceSelectionParams(
                    language_code=&quot;en-US&quot;,
                    name=&quot;en-US-Standard-J&quot;
                )
                
                # オーディオ設定
                audio_config = texttospeech.AudioConfig(
                    audio_encoding=texttospeech.AudioEncoding.LINEAR16  # WAVフォーマット
                )
                
                # 音声合成のリクエスト
                response = client.synthesize_speech(
                    input=synthesis_input,
                    voice=voice,
                    audio_config=audio_config
                )
                
                # ファイル名をインデックスと単語で作成し、保存先パスを設定
                filename = os.path.join(save_directory, f&#39;{index+1}_{word}.wav&#39;)
                
                # 音声データの保存
                with open(filename, &#39;wb&#39;) as out:
                    out.write(response.audio_content)
                    print(f&#39;Saved: {filename}&#39;)

# メイン処理
if __name__ == &quot;__main__&quot;:
    # CSVファイルのパスを指定
    csv_path = &#39;voice.csv&#39;
    
    # ファイルが存在するか確認
    if os.path.exists(csv_path):
        generate_audio(csv_path)
        print(&quot;音声変換が完了しました。&quot;)
    else:
        print(&quot;エラー: 指定されたCSVファイルが存在しません。&quot;)</code></pre></div>



<h4 class="wp-block-heading">UdemyでPythonを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython-beginner%2F">現役シリコンバレーエンジニアが教えるPython 3 入門 + 応用 +アメリカのシリコンバレー流コードスタイル</a><br>Pythonをインストールから環境設定、基本文法が学習<br>さらに暗号化、インフラ自動化、非同期処理についても学べます。<br><strong>Pythonを基礎から応用まで学びたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Flearning-ai%2F">みんなのAI講座 ゼロからPythonで学ぶ人工知能と機械学習 【2024年最新版】</a><br>機械学習ライブラリで文字認識や株価分析などを行う。<br><strong>人口知能やニューラルネットワーク、機械学習を学びたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fdatascience365%2F">【世界で55万人が受講】データサイエンティストを目指すあなたへ〜データサイエンス25時間ブートキャンプ〜</a><br>統計分析、機械学習の実装、ディープラーニングの実装を学習。<br><strong>データサイエンティストになりたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython_tkinter_master%2F">0から始めるTkinterの使い方完全マスター講座〜Python×GUIの基礎・応用〜</a><br>TkinterのGUIを作成から発展的な操作までアプリ実例を示して学習。<br><strong>アプリ開発したい人</strong>におすすめ。</li>
</ul>
</div>



<h3 class="wp-block-heading">解説</h3>



<ul class="wp-block-list">
<li><strong>モジュール名</strong></li>
</ul>



<p>「os」：ファイルシステムのパスや環境変数を扱うために使用されている。ここでは環境変数を設定し、CSVファイルの場所を扱うために必要。<br>「csv」：CSVファイルを読み込むために使用される。スクリプトでは、各行のA列の内容を音声生成のために取得する必要がある。<br>「google.cloud.texttospeech」：Google Cloud Text-to-Speech APIを利用するために必要。音声合成のリクエストを送るために使用されている。</p>



<ul class="wp-block-list">
<li><strong>フィールド（メンバ変数）</strong></li>
</ul>



<p>「csv_path」：CSVファイルのパスを保持する。音声生成対象のファイルの場所を指定するために必要。<br>「save_directory」：音声ファイルの保存先ディレクトリのパスを保持する。CSVファイルと同じ場所に音声ファイルを保存するために使用。<br>「client」：Google Cloud Text-to-Speech APIクライアントのインスタンス。音声合成を行うために必要。<br>「word」：CSVファイルのA列から読み取った単語を保持する。この単語が音声合成の対象となる。<br>「synthesis_input」：音声合成に使用するテキストを保持する。Google Cloud Text-to-Speech APIに渡すために作成される。<br>「voice」：音声の設定を保持する。使用する言語コードと話者の情報が含まれ、どの話者を使って音声を生成するか指定する。<br>「audio_config」：オーディオ出力の設定を保持する。生成する音声のフォーマット（WAV形式）を指定する。<br>「filename」：生成した音声ファイルの保存先パスを保持する。インデックスと単語を使ってファイル名を作成。</p>



<p><strong>generate_audioクラス</strong></p>



<p>「csv_path」からCSVファイルを読み込み、A列の単語に対して音声を生成する関数。Google Cloud Text-to-Speech APIを利用して、各単語を音声ファイル（WAV形式）に変換し、CSVファイルと同じディレクトリに保存する。<br>まず「save_directory」をCSVファイルのディレクトリに設定し、APIクライアント「client」を生成する。</p>



<p>次に、CSVファイルを読み込み、<strong>各行に対してA列の単語を取得</strong>する。取得した単語を「synthesis_input」として設定し、音声の設定「voice」とオーディオ出力の設定「audio_config」を指定して「synthesize_speech」メソッドを呼び出し、音声を生成する。</p>



<p>最後に、<strong>生成した音声データを「filename」に保存</strong>する。ファイル名にはインデックスと単語を使っており、保存先ディレクトリに「.wav」ファイルとして保存する。</p>



<p>本ソースコードでは、「voice.csv」と先に指定しているが、<br>Tkinterを使うことでユーザーの設定によって決めることもできる。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>TkinterのEntryについて紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/python/tkinter-entry/" title="【Python】Tkinterエントリー作成、初期値の取得を解説" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/09/tkinter-entry-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/09/tkinter-entry-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/09/tkinter-entry-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/09/tkinter-entry-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Python】Tkinterエントリー作成、初期値の取得を解説</div><div class="blogcard-snippet internal-blogcard-snippet">PythonのTkinterでエントリーボックス（Entry）の解説をします。配置や文字列の取得、初期値、クリアなど基本事項を解説しながらログインフォームの制作しています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.04.29</div></div></div></div></a>
</div>



<h2 class="wp-block-heading">実演</h2>



<p>スクリプトを実行すると、csv（voice.csv）にのA列にあるテキストを読み込み、<br>wav形式で保存します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="683" height="333" src="https://alicia-ing.com/wp-content/uploads/2024/11/csv_data.webp" alt="csvデータ" class="wp-image-8226" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/csv_data.webp 683w, https://alicia-ing.com/wp-content/uploads/2024/11/csv_data-300x146.webp 300w" sizes="(max-width: 683px) 100vw, 683px" /></figure>



<p>wavファイルの保存先は、実行したPythonのコードと同じ断層です。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>Google Text-to-Speechは、テキストを簡単に音声に変換する強力なツールです。<br>特にPythonと組み合わせることで、柔軟に自動音声生成を行うことが可能になります。</p>



<p>本記事では、APIの取得からPythonによる実装までを詳細に解説しました。<br>業務の効率化や教育コンテンツの作成など、さまざまな用途で活用してみてください。</p>



<p>Google Text-to-Speechを使うことで、ナレーション、案内、教育用途、さらには商用プロジェクトでの音声合成など、多彩なシーンで活用することができます。</p>



<p>また、Pythonのコードを使えば、複数のテキストを自動的に音声ファイルに変換するプロセスを効率化でき、生産性を向上させることができます。</p>



<p>APIの設定や実装手順は一見複雑に思えますが、<br>本記事を参考にすれば初めての方でも問題なく取り組むことができるでしょう。</p>



<p>Google Cloudの無料枠を上手に利用し、まずは個人プロジェクトから始めてみるのも良いでしょう。音声合成の楽しさと可能性をぜひ体験してみてください。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/python/google-text-to-speech/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Python】moviepyできること｜mp3・GIF編集変換</title>
		<link>https://alicia-ing.com/programming/python/moviepy/</link>
					<comments>https://alicia-ing.com/programming/python/moviepy/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 17 Nov 2024 22:00:00 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=8067</guid>

					<description><![CDATA[PythonのライブラリであるMoviePyを使えば、動画編集が簡単に自動化できます。 面倒な手作業をスクリプトに置き換えることで効率的に編集作業を進められるこのライブラリは、動画のカットや結合、テキスト追加からGIFへ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>PythonのライブラリであるMoviePyを使えば、<br>動画編集が簡単に自動化できます。</p>



<p>面倒な手作業をスクリプトに置き換えることで<strong>効率的に編集作業を進められ</strong>るこのライブラリは、動画のカットや結合、テキスト追加からGIFへの変換まで多岐にわたる機能を提供します。</p>



<p>本記事では、MoviePyの基本的な使い方から応用的な操作までをわかりやすく解説します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>動画編集を自動化したいプログラマーやエンジニア</li>



<li>Pythonで動画編集に挑戦したい初心者</li>



<li>SNS用のショート動画やGIFを素早く作りたい方</li>



<li>自動化した動画編集パイプラインを構築したい方</li>



<li>動画編集ソフトを使わずにコードで柔軟に編集したい方</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">moviepy</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/movie.webp" alt="moviepyについて" class="wp-image-8158" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/movie.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/movie-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/movie-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/movie-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>MoviePyは、Pythonで<strong>動画や音声を編集するオープンソースライブラリ</strong>です。</p>



<p>動画のカットや結合、オーバーレイ、<br>速度変更など多くの機能を持ち、<br>mp4からGIFやmp3など他の形式への変換も簡単に行えます。</p>



<p>自動化された<strong>動画編集ワークフローを作るのに非常に役立つツール</strong>です。</p>



<h2 class="wp-block-heading">基本的な機能</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/basic-function.webp" alt="基本機能について" class="wp-image-8159" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/basic-function.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/basic-function-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/basic-function-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/basic-function-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>MoviePyを使って、基本的な動画編集を簡単に行うことができます。<br>以下に、主な機能とそれぞれのコード例を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-blue-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#0095d9"><div class="tab-caption-box-label block-box-label box-label fab-check"><span class="tab-caption-box-label-text block-box-label-text box-label-text">機能一覧</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>トリミング</li>



<li>結合</li>



<li>リサイズ</li>



<li>フレームレートの変更</li>
</ul>
</div></div>



<h3 class="wp-block-heading">動画のカット（トリミング）</h3>



<p>動画の特定の部分を切り取ることで、必要なシーンだけを抽出できます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;).subclip(10, 30)  # 10秒から30秒の部分を切り取る
clip.write_videofile(&quot;output_trimmed.mp4&quot;)</code></pre></div>



<p>input_video.mp4の10秒から30秒までの部分を切り取って、<br>新しい動画ファイルとして保存します。</p>



<h3 class="wp-block-heading">複数クリップの結合</h3>



<p>複数の動画を連結して1つの動画にすることも簡単です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, concatenate_videoclips

clip1 = VideoFileClip(&quot;video1.mp4&quot;).subclip(0, 10)
clip2 = VideoFileClip(&quot;video2.mp4&quot;).subclip(5, 15)

final_clip = concatenate_videoclips([clip1, clip2])
final_clip.write_videofile(&quot;output_concatenated.mp4&quot;)</code></pre></div>



<p>video1.mp4の最初の10秒間とvideo2.mp4の5秒から15秒の部分を結合して、<br>新しい動画を作成しています。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>最近のYouTubeは、総集編が多いので、<br>これで自動編集ができる！</p>
</div></div>



<h3 class="wp-block-heading">動画のリサイズ</h3>



<p>動画の解像度を変更して、<strong>特定のサイズにリサイズ</strong>することができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;)
resized_clip = clip.resize(height=720)  # 高さを720ピクセルにリサイズ
resized_clip.write_videofile(&quot;output_resized.mp4&quot;)</code></pre></div>



<p>動画の高さを720ピクセルに変更して、新しいファイルとして保存します。</p>



<h4 class="wp-block-heading">UdemyでPythonを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython-beginner%2F">現役シリコンバレーエンジニアが教えるPython 3 入門 + 応用 +アメリカのシリコンバレー流コードスタイル</a><br>Pythonをインストールから環境設定、基本文法が学習<br>さらに暗号化、インフラ自動化、非同期処理についても学べます。<br><strong>Pythonを基礎から応用まで学びたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Flearning-ai%2F">みんなのAI講座 ゼロからPythonで学ぶ人工知能と機械学習 【2024年最新版】</a><br>機械学習ライブラリで文字認識や株価分析などを行う。<br><strong>人口知能やニューラルネットワーク、機械学習を学びたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fdatascience365%2F">【世界で55万人が受講】データサイエンティストを目指すあなたへ〜データサイエンス25時間ブートキャンプ〜</a><br>統計分析、機械学習の実装、ディープラーニングの実装を学習。<br><strong>データサイエンティストになりたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fpython_tkinter_master%2F">0から始めるTkinterの使い方完全マスター講座〜Python×GUIの基礎・応用〜</a><br>TkinterのGUIを作成から発展的な操作までアプリ実例を示して学習。<br><strong>アプリ開発したい人</strong>におすすめ。</li>
</ul>
</div>



<h3 class="wp-block-heading">フレームレートの変更</h3>



<p>フレームレートを変更することで、<strong>スムーズさを調整</strong>したり、<strong>特殊な演出</strong>を加えることができます。<br>フレームレートとは、<strong>動画やゲームにおいて1秒間に表示される画像</strong>（フレーム）の数を示す単位です。</p>



<p>要するに、1秒の動きを表現するために30枚の画像を使うと30fpsになります。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;).set_fps(15) # フレームレートを15fpsに変更
clip.write_videofile(&quot;output_changed_fps.mp4&quot;)</code></pre></div>



<p>元の動画のフレームレートを15fpsに設定しています。</p>



<h2 class="wp-block-heading">動画・画像の加工</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/video-image.webp" alt="動画加工について" class="wp-image-8160" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/video-image.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/video-image-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/video-image-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/video-image-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>MoviePyでは、動画や画像に対してさらに多くの加工を行うことが可能です。</p>



<p>機能として備わっていますが、<br>トリミングやオーバーレイ、テキストの追加は、<br><strong>編集ソフトで動画作り</strong>した方がやりやすいです。</p>



<h3 class="wp-block-heading">クロッピング（トリミング）</h3>



<p>動画の一部を切り取ることで、<strong>不要な部分を削除</strong>し、必要な部分のみを残すことができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;)
cropped_clip = clip.crop(x1=100, y1=50, x2=400, y2=300)  # 指定したエリアをクロップ
cropped_clip.write_videofile(&quot;output_cropped.mp4&quot;)</code></pre></div>



<p>動画の特定のエリアをクロップして、新しい動画として保存します。</p>



<h3 class="wp-block-heading">画像のオーバーレイ</h3>



<p>動画の上に画像をオーバーレイすることが可能です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, ImageClip, CompositeVideoClip

video_clip = VideoFileClip(&quot;input_video.mp4&quot;)
image_clip = ImageClip(&quot;overlay_image.png&quot;).set_duration(video_clip.duration)
image_clip = image_clip.set_position((&quot;right&quot;, &quot;top&quot;))  # 画像の位置を右上に設定

composite_clip = CompositeVideoClip([video_clip, image_clip])
composite_clip.write_videofile(&quot;output_with_overlay.mp4&quot;)</code></pre></div>



<p>input_video.mp4の上にoverlay_image.pngを右上に表示させています。</p>



<h3 class="wp-block-heading">テキストの追加</h3>



<p>動画上にテキストを追加することができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, TextClip, CompositeVideoClip

video_clip = VideoFileClip(&quot;input_video.mp4&quot;)
text_clip = TextClip(&quot;Hello, World!&quot;, fontsize=70, color=&#39;white&#39;).set_duration(5)
text_clip = text_clip.set_position(&#39;center&#39;).fadein(1).fadeout(1)  # フェードイン・フェードアウト効果

composite_clip = CompositeVideoClip([video_clip, text_clip])
composite_clip.write_videofile(&quot;output_with_text.mp4&quot;)</code></pre></div>



<p><strong>動画の中央に5秒間表示されるテキスト</strong>を追加し、<br><strong>フェードインとフェードアウト効果</strong>を加えています。</p>



<h3 class="wp-block-heading">動画の回転</h3>



<p>動画を任意の角度に回転させることができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;)
rotated_clip = clip.rotate(90)  # 動画を90度回転
rotated_clip.write_videofile(&quot;output_rotated.mp4&quot;)</code></pre></div>



<p>動画を90度回転させています。</p>



<h2 class="wp-block-heading">動画・音声の効果</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/effect.webp" alt="動画音声の効果について" class="wp-image-8161" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/effect.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/effect-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/effect-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/effect-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>動画に視覚的な効果を加えることで、より魅力的なコンテンツを作成することができます。</p>



<p>また、音声を調整して臨場感がある動画作りができます。</p>



<h3 class="wp-block-heading">フェードイン/フェードアウト</h3>



<p><strong>フェード効果</strong>を使って、動画の始まりや終わりを滑らかに演出します。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip
from moviepy.video.fx import fadein, fadeout

clip = VideoFileClip(&quot;input_video.mp4&quot;)
clip_with_fadein = fadein.fadein(clip, 2)  # 最初の2秒をフェードイン
clip_with_fadeout = fadeout.fadeout(clip_with_fadein, 2)  # 最後の2秒をフェードアウト
clip_with_fadeout.write_videofile(&quot;output_fade.mp4&quot;)</code></pre></div>



<p>最初の2秒間のフェードインと最後の2秒間のフェードアウトを加えています。</p>



<h3 class="wp-block-heading">速度変更</h3>



<p>動画の再生速度を変更することができます（<strong>スローモーションや早送り</strong>）。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, vfx

clip = VideoFileClip(&quot;input_video.mp4&quot;)
sped_up_clip = clip.fx(vfx.speedx, 2)  # 2倍速にする
sped_up_clip.write_videofile(&quot;output_sped_up.mp4&quot;)</code></pre></div>



<p>動画を2倍速にして新しいファイルとして保存しています。</p>



<h3 class="wp-block-heading">ミラーリング（反転）</h3>



<p>動画を<strong>左右または上下に反転</strong>させることが可能です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;)
mirrored_clip = clip.fx(vfx.mirror_x)  # 左右反転
mirrored_clip.write_videofile(&quot;output_mirrored.mp4&quot;)</code></pre></div>



<p>動画を左右反転させています。</p>



<h3 class="wp-block-heading">カラー調整</h3>



<p>動画の色調（輝度、コントラスト、彩度など）を調整できます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip
from moviepy.video.fx import colorx

clip = VideoFileClip(&quot;input_video.mp4&quot;)
brightened_clip = colorx.colorx(clip, 1.5)  # 輝度を1.5倍に
brightened_clip.write_videofile(&quot;output_brightened.mp4&quot;)</code></pre></div>



<p><strong>動画の輝度</strong>を1.5倍に調整しています。</p>



<h3 class="wp-block-heading">音声の追加/削除</h3>



<p>動画の音声を削除したり、<strong>新しい音声を追加</strong>することができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, AudioFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;)
audio = AudioFileClip(&quot;new_audio.mp3&quot;).set_duration(clip.duration)
clip_with_new_audio = clip.set_audio(audio)
clip_with_new_audio.write_videofile(&quot;output_with_new_audio.mp4&quot;)</code></pre></div>



<p>input_video.mp4に新しい音声ファイルnew_audio.mp3を追加しています。</p>



<h3 class="wp-block-heading">音量調整</h3>



<p>動画や音声クリップの音量を変更することができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;)
quieter_clip = clip.volumex(0.5)  # 音量を半分に
quieter_clip.write_videofile(&quot;output_quieter.mp4&quot;)</code></pre></div>



<p>動画の音量を半分にしています。</p>



<h3 class="wp-block-heading">フェードイン/フェードアウト（音声）</h3>



<p>音声クリップにフェード効果を加えることが可能です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, AudioFileClip
from moviepy.audio.fx import audio_fadein, audio_fadeout

clip = VideoFileClip(&quot;input_video.mp4&quot;)
audio = clip.audio
faded_audio = audio_fadein.audio_fadein(audio, 2).fx(audio_fadeout.audio_fadeout, 2)
clip_with_faded_audio = clip.set_audio(faded_audio)
clip_with_faded_audio.write_videofile(&quot;output_faded_audio.mp4&quot;)</code></pre></div>



<p>音声に最初と最後の2秒間のフェードイン・フェードアウト効果を追加しています。</p>



<h2 class="wp-block-heading">応用例</h2>



<p>MoviePyを使って、さらに複雑な動画編集を行うことも可能です。<br>以下にいくつかの応用例を紹介します。</p>



<h3 class="wp-block-heading">動画に画像をオーバーレイ</h3>



<p>動画の上にロゴや他の画像を追加することで、カスタマイズされた動画を作成することができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>from moviepy.editor import VideoFileClip, ImageClip, CompositeVideoClip

video_clip = VideoFileClip(&quot;input_video.mp4&quot;)
image_clip = ImageClip(&quot;overlay_image.png&quot;).set_duration(video_clip.duration)
image_clip = image_clip.set_position((&quot;right&quot;, &quot;top&quot;))  # 画像の位置を右上に設定

composite_clip = CompositeVideoClip([video_clip, image_clip])
composite_clip.write_videofile(&quot;output_with_overlay.mp4&quot;)</code></pre></div>



<p>この例では、input_video.mp4の上にoverlay_image.pngを右上に表示させています。</p>



<h3 class="wp-block-heading">テキストのアニメーション</h3>



<p>動画上にアニメーション化されたテキストを追加して、より魅力的な演出を行います。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, TextClip, CompositeVideoClip

video_clip = VideoFileClip(&quot;input_video.mp4&quot;)
text_clip = TextClip(&quot;Hello, World!&quot;, fontsize=70, color=&#39;white&#39;).set_duration(5)
text_clip = text_clip.set_position(&#39;center&#39;).fadein(1).fadeout(1)  # フェードイン・フェードアウト効果

composite_clip = CompositeVideoClip([video_clip, text_clip])
composite_clip.write_videofile(&quot;output_with_text.mp4&quot;)</code></pre></div>



<p>このコードでは、動画の中央に5秒間表示されるテキストを追加し、<br>フェードインとフェードアウト効果を加えています。</p>



<h3 class="wp-block-heading">ピクチャー・イン・ピクチャー（PIP）効果</h3>



<p>メインの動画の中に別の小さな動画を配置することで、<br>ピクチャー・イン・ピクチャー効果を実現します。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip, CompositeVideoClip

main_clip = VideoFileClip(&quot;main_video.mp4&quot;)
small_clip = VideoFileClip(&quot;small_video.mp4&quot;).resize(height=150).set_position((10, 10)).set_duration(main_clip.duration)

pip_clip = CompositeVideoClip([main_clip, small_clip])
pip_clip.write_videofile(&quot;output_pip.mp4&quot;)</code></pre></div>



<p>main_video.mp4の左上に小さなsmall_video.mp4を配置しています。</p>



<h2 class="wp-block-heading">形式変換</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1200" height="630" src="https://alicia-ing.com/wp-content/uploads/2024/11/transformation.webp" alt="形式を変えるには" class="wp-image-8162" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/transformation.webp 1200w, https://alicia-ing.com/wp-content/uploads/2024/11/transformation-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/transformation-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/transformation-768x403.webp 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<p>MoviePyは動画のフォーマット変換もサポートしています。</p>



<p>MoviePyは多機能ですが、<strong>直感で編集できない</strong>ので、用途が限られます。<br>しかし、動画を結合して、それをmp3やGIFに変換することで、<br>色々な場所で使うことができます。</p>



<p>例えば、<strong>私の場合は動画をGIFに変換してブログ投稿</strong>したり、<br>逆にGIFをmp4に変換して動画編集したりしています。</p>



<p>このように、フォーマットの変換はかなり使いやすいです。</p>



<h3 class="wp-block-heading">mp3への変換</h3>



<p>動画から音声を抽出してmp3ファイルとして保存できます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;)
clip.audio.write_audiofile(&quot;output_audio.mp3&quot;)</code></pre></div>



<p>input_video.mp4の<strong>音声部分を抽出</strong>して、output_audio.mp3として保存します。</p>



<h3 class="wp-block-heading">GIFへの変換</h3>



<p>特定のシーンをGIFとしてエクスポートすることで、短いアニメーションを簡単に作成できます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

clip = VideoFileClip(&quot;input_video.mp4&quot;).subclip(0, 5)  # 最初の5秒をGIFに変換
clip.write_gif(&quot;output.gif&quot;)</code></pre></div>



<p>動画の最初の5秒間を<strong>GIFとしてエクスポート</strong>しています。</p>



<h3 class="wp-block-heading">GIFをmp4に変換</h3>



<p>GIFをインポートして、output.mp4をエクスポートしています。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>from moviepy.editor import VideoFileClip

# GIFをmp4に変換
clip = VideoFileClip(&quot;input.gif&quot;)  # 入力GIFファイルを指定
clip.write_videofile(&quot;output.mp4&quot;, codec=&quot;libx264&quot;)  # mp4形式で出力</code></pre></div>



<h2 class="wp-block-heading">まとめ</h2>



<p>MoviePyを使えば、Pythonで動画や音声を自由自在に編集することができます。</p>



<p>動画のカット、結合、リサイズ、エフェクト追加など、<br>MoviePyの基本機能を使いこなすことで、柔軟にコンテンツを作成することが可能です。</p>



<p>また、GIFやmp3などの形式に変換することも容易で、SNS用の素材作りにも最適です。</p>



<p>応用的な操作として、画像やテキストのオーバーレイ、ピクチャー・イン・ピクチャー効果などを利用することで、より高度で魅力的な動画編集が可能になります。</p>



<p>ぜひ本記事を参考に、MoviePyで様々な動画編集に挑戦してみてください！</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/python/moviepy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！</title>
		<link>https://alicia-ing.com/programming/unity/roadmap-cs/</link>
					<comments>https://alicia-ing.com/programming/unity/roadmap-cs/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 03 Nov 2024 22:00:00 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=7745</guid>

					<description><![CDATA[テレビゲームが好きな人の中には、自作ゲームを作りたい人も多いでしょう。 ゲーム作りは企業が大人数で取り組むイメージかあるでしょうが、個人でゲームを作成して爆発的ヒットを生み出している人もいます。 しかし個人でゲームを作っ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>テレビゲームが好きな人の中には、<strong>自作ゲームを作りたい人</strong>も多いでしょう。</p>



<p>ゲーム作りは企業が大人数で取り組むイメージかあるでしょうが、<br><strong>個人でゲームを作成して爆発的ヒット</strong>を生み出している人もいます。</p>



<p>しかし個人でゲームを作った彼らは、<br><strong>幼少期から</strong>プログラミングを始めている。<br>スクール通っていて、<strong>ゲーム会社で働いている</strong>ときに作成しているなど</p>



<p>個人で作るにしても専門的かつキャリアが物を言います。<br>このように<strong>個人のゲーム作りは難しい</strong>ものでした。</p>



<p>しかし、Unityを使うことで<strong>ノンコードでもプロ顔負けのゲームを作る</strong>ことができます。</p>



<p>Unityは最も人気で初心者からプロまで幅広く利用されるプラットフォームです。<br>最近では<strong>大手企業でも採用</strong>していています。</p>



<p>しかし高性能すぎて、いざインストールしてみても操作方法が分からない。<br>ある程度はC#が必要など<strong>Unityを挫折</strong>してしまう人が多いです。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-1 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/alicia.webp" alt="著者の体験談" class="speech-icon-image"/></figure><div class="speech-name">著者の体験談</div></div><div class="speech-balloon">
<p>自分も<strong>挫折して戻ってきた</strong>一人です。</p>
</div></div>



<p>本記事では、自作ゲームの開発を目指している方に向けて、<br>Unityでの学び方とキャリアの可能性を示します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>自作ゲームの開発に興味がある初心者</li>



<li>ゲームエンジンを迷っている人</li>



<li>Unityを使って収益化を目指す人</li>



<li>プログラミングの学習方法を探している方</li>



<li>ゲーム開発を通じてキャリアチェンジを考えている人</li>
</ul>
</div></div>



<h2 class="wp-block-heading">ゲーム作り</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/Game-Development-1.webp" alt="" class="wp-image-7820" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/Game-Development-1.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/Game-Development-1-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/Game-Development-1-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/Game-Development-1-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/Game-Development-1-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>ゲームには、滑らかな挙動が求められて、<br>使用言語は<strong>実行速度の速さ</strong>に注目されます。</p>



<p>例えば、ゲーム使用される言語は、C++やJavaなどがあります。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>プログラミング言語</th><th>特徴</th><th>個人的難易度</th></tr></thead><tbody><tr><td><strong>C++</strong></td><td>ゲームづくりではメジャー</td><td><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">4.0</span></span></td></tr><tr><td>Java</td><td>すべてのOSに対応し、家電、金融システムでも利用</td><td><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="rating-number">5.0</span></span></td></tr><tr><td><strong>C#</strong></td><td>アプリやゲーム、システムの開発</td><td><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">2.0</span></span></td></tr><tr><td>Swift</td><td>iPhone、iPadなどiOS向け</td><td><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">3.0</span></span></td></tr><tr><td>JavaScript</td><td>動きのあるWebサイト</td><td><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">1.0</span></span></td></tr></tbody></table></div></figure>



<p>表に挙げなかったPythonなどでも作ることができますが、<strong>マイナー</strong>です。</p>



<p>Javaは「<strong>Minecraft Java版</strong>」とあるようにマイクラが開発されたゲームですが、<br>環境を整えて、学習するには<strong>コストがかかりすぎ</strong>です。<br>メジャー言語の中ではトップクラスで難しいです。</p>



<p>したがって、基本的にゲーム開発は「C++」か「C#」のどちらかです。<br>両者の言語を使用した<strong>ゲームエンジン</strong>が提供されています。</p>



<ul class="wp-block-list">
<li>「C#」は、Unity。</li>



<li>「C++」は、Unreal Engine。</li>
</ul>



<p>「C#」は「C++」よりも<strong>難易度が低い</strong>です。</p>



<p>一方で、「PlayStation」や「Nintendo Switch」などを有名なコンシューマーゲームは「C++」が使用されています。<br>「C++」の方がメモリやCPUの<strong>利用効率が良い</strong>ことやゲーム開発言語として<strong>長年の歴史</strong>を持ちます。</p>



<h3 class="wp-block-heading">UnityかUnreal Engine</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/11/Unity-or-Unreal-Engine.webp" alt="" class="wp-image-7869" srcset="https://alicia-ing.com/wp-content/uploads/2024/11/Unity-or-Unreal-Engine.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/11/Unity-or-Unreal-Engine-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/11/Unity-or-Unreal-Engine-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/11/Unity-or-Unreal-Engine-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/11/Unity-or-Unreal-Engine-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>UnityとUnreal Engineは、どちらもゲーム開発においてトップクラスのエンジンです。</p>



<p>UnityとUnreal Engineを比較して、どちらが自作ゲームに適しているかを考えます。</p>



<p>初めに価格帯について。</p>



<p><strong>いずれも無料</strong>で始めることができます。<br>しかし、売り上げや資金調達金などによっては<strong>ロイヤリティー</strong>を請求されます。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-center" data-align="center">ゲームエンジン</th><th class="has-text-align-center" data-align="center">売り上げによる使用料</th></tr></thead><tbody><tr><td class="has-text-align-center" data-align="center">Unity</td><td class="has-text-align-center" data-align="center">20万ドル（資金調達も含む）超えると年に約30万</td></tr><tr><td class="has-text-align-center" data-align="center">Unreal Engine</td><td class="has-text-align-center" data-align="center">100万ドル超えると5％</td></tr></tbody></table></div></figure>



<p>ドルは変動するので、各サービスで1ドル130円、150円と示しています。</p>



<p>150円で計算すると、Unityは6千万円。<br>Unreal Engineは、1億5千万円で使用料が必要になります。</p>



<p><strong>閾値はUnityの方が低い</strong>（別プランあり）ですが、<br>Unreal Engine使用料は最低750万円（1億５千万×0.05）になります。</p>



<p>しかし１本1000円で販売した場合、６万本も販売するレベルになります。<br><strong>個人開発者だとなかなか届かない数字</strong>なので、あまり気にする必要はありません。</p>



<p>情報量の観点から見ます。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>ゲームエンジンの世界シェアは「<a target="_self" href="https://www.techfirm.co.jp/blog/unity">Unity</a>」が約46%を締め、次いで「Unreal Engine」が約17%を締めています。3位以下は企業独自に開発されたものが多いため、実質的には「Unity」と「Unreal Engine」の2つのゲームエンジンでほとんどのシェアを締めていると言ってもよいでしょう。ただし、最近ではXR分野においてUnityより有力との声もあります。</p>
<cite><a target="_self" href="https://www.techfirm.co.jp/blog/unreal-engine">https://www.techfirm.co.jp/blog/unreal-engine</a></cite></blockquote>



<p>引用元から判断すると、<strong>Unityの方が利用者が多い</strong>ようです。</p>



<p>利用者が多いということは情報量を示しているので、<br>分からないことやエラー文を調べれば<strong>解決しやすい</strong>です。</p>



<h3 class="wp-block-heading">私がUnityを選んだ理由</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/Reasons-I-Chose-Unity.webp" alt="" class="wp-image-7844" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/Reasons-I-Chose-Unity.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/Reasons-I-Chose-Unity-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/Reasons-I-Chose-Unity-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/Reasons-I-Chose-Unity-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/Reasons-I-Chose-Unity-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>私は、ノベルゲームを作りたくてゲーム作りに挑戦しました。<br>しかし、ノベルゲームは<a target="_self" href="https://b.tyrano.jp/">ティラノビルダー</a>というゲームエンジンがあります。</p>



<p>初めにどちらを使うか迷っていました。<br>また、ゲーム開発はC++である<strong>Unreal Engine</strong>に使用かと思っていました。</p>



<p>最終的に決定打となったのは<strong>大学での実習</strong>です。<br>大学でArduinoの実験で、制作発表することがありました。</p>



<p>私は、<strong>ソフトウェアとハードウェアを連携</strong>したいと考えて、<br>ネットで検索していたところ<strong>Unityの情報が多く</strong>制作を発表しました。<br>やはり、初学者には<strong>情報の多さはとても重要</strong>です。</p>



<p>Unityは、特に初心者にとって非常に学びやすく、多くのサポートリソースがあります。</p>



<p>豊富なチュートリアルやコミュニティの支援が受けられるため、<br>初学者でも独学しやすいのが特徴です。</p>



<p>また、Unityはクロスプラットフォーム対応が進んでおり、<br>一度の開発でさまざまな端末に対応できます。</p>



<h3 class="wp-block-heading">Unityが活躍している業界は？</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/Which-Industries-Use-Unity.webp" alt="" class="wp-image-7845" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/Which-Industries-Use-Unity.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/Which-Industries-Use-Unity-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/Which-Industries-Use-Unity-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/Which-Industries-Use-Unity-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/Which-Industries-Use-Unity-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Unityはゲーム業界以外にも、次のようなさまざまな業界で使用されています。</p>



<p>私は講義の１環としてUnityを使いましたが、<br>研究室によってUnityを使っています。</p>



<ul class="wp-block-list">
<li><strong>VR/AR</strong>：リアルな体験を提供するアプリケーションやシミュレーターに使用。</li>



<li><strong>建築</strong>：建築モデルや不動産シミュレーションに。</li>



<li><strong>教育</strong>：教育ゲームやインタラクティブな学習アプリとして。</li>
</ul>



<p>Unityは、様々な業界で活躍するので、個人利用だけではなく、<br><strong>就職や転職にも役立つスキル</strong>です。</p>



<h3 class="wp-block-heading">Unityで作られた有名タイトル</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/Popular-Titles-Made-with-Unity.webp" alt="" class="wp-image-7847" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/Popular-Titles-Made-with-Unity.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/Popular-Titles-Made-with-Unity-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/Popular-Titles-Made-with-Unity-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/Popular-Titles-Made-with-Unity-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/Popular-Titles-Made-with-Unity-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Unityで開発されたゲームには、多くの有名タイトルがあります。<br>例を４つ出すと、</p>



<div class="wp-block-cocoon-blocks-blank-box-1 blank-box block-box has-border-color has-red-border-color">
<ul class="wp-block-list">
<li>Among Us</li>



<li>原神</li>



<li>Super Mario Run</li>



<li>ポケモンGO</li>
</ul>
</div>



<p>紹介したゲームタイトルから分かるように、<br>Unityは、大手のゲームメーカーでも採用されていて、マルチプレイが可能です。<br>さらに、ニンテンドースイッチやPC、スマホなど様々なプラットフォームにも対応しています。</p>



<p>Unity（C#）で傑作を作ることは可能です！</p>



<h2 class="wp-block-heading">Unityの勉強方法</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Learn-Unity.webp" alt="" class="wp-image-7848" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Learn-Unity.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Learn-Unity-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Learn-Unity-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Learn-Unity-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Learn-Unity-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Unity以外にも<strong>プログラミングの学習方法</strong>は、<br>教本、ネット検索、生成AI、プログラミングスクール・専門学校、Udemyなどがあります。</p>



<p>各々は、学習という観点ではともに同じですが、<br><strong>身につく学習</strong>としては差が出てきてしまいます。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-center" data-align="center">勉強方法</th><th class="has-text-align-center" data-align="center">個人的評価</th><th class="has-text-align-center" data-align="center">相場</th><th class="has-text-align-center" data-align="center">学習期間・時間</th></tr></thead><tbody><tr><td class="has-text-align-center" data-align="center">教本</td><td class="has-text-align-center" data-align="center"><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">3.0</span></span></td><td class="has-text-align-center" data-align="center">2000円前後</td><td class="has-text-align-center" data-align="center">1か月</td></tr><tr><td class="has-text-align-center" data-align="center">ネット検索</td><td class="has-text-align-center" data-align="center"><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">3.0</span></span></td><td class="has-text-align-center" data-align="center"><strong>0円～</strong></td><td class="has-text-align-center" data-align="center">１か月</td></tr><tr><td class="has-text-align-center" data-align="center">生成AI</td><td class="has-text-align-center" data-align="center"><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star-half-alt" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">3.5</span></span></td><td class="has-text-align-center" data-align="center">0円～3000円</td><td class="has-text-align-center" data-align="center"><strong>数日</strong></td></tr><tr><td class="has-text-align-center" data-align="center">スクール</td><td class="has-text-align-center" data-align="center"><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="far fa-star" aria-hidden="true"></span><span class="rating-number">4.0</span></span></td><td class="has-text-align-center" data-align="center">数十万</td><td class="has-text-align-center" data-align="center">３か月～２年</td></tr><tr><td class="has-text-align-center" data-align="center"><strong>Udemy</strong></td><td class="has-text-align-center" data-align="center"><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="rating-number">5.0</span></span></td><td class="has-text-align-center" data-align="center">1500円～２万5千円</td><td class="has-text-align-center" data-align="center">２週間</td></tr><tr><td class="has-text-align-center" data-align="center"><strong>ブログ</strong></td><td class="has-text-align-center" data-align="center"><span class="rating-star"><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="fas fa-star" aria-hidden="true"></span><span class="rating-number">5.0</span></span></td><td class="has-text-align-center" data-align="center">月1000円</td><td class="has-text-align-center" data-align="center">∞</td></tr></tbody></table></div></figure>



<p>上のそれぞれの方法とその特徴、メリット、デメリットについて紹介します。</p>



<h3 class="wp-block-heading">教本</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/textbook.webp" alt="" class="wp-image-7849" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/textbook.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/textbook-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/textbook-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/textbook-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/textbook-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>教本はインストールの方法から実際の開発まで体系的学べます。<br>しかし、<strong>自分が作りたいものをつくれるようになるかは別の話</strong>です。</p>



<p>参考書の問題は解けるようになったけど、<strong>模試や試験では解答ができない</strong>状況に似ています。</p>



<p>数学のように、<strong>解法を覚えて組み合わせるスキルが必要</strong>です。<br>教本で基本文法と操作を覚えたら、ゲーム作りをしづつけましょう。</p>



<div class="wp-block-group is-layout-constrained wp-block-group-is-layout-constrained">
<p class="has-text-align-center"><span class="fz-24px"><span class="fz-28px"><strong>Unity学習ができる教本</strong></span></span></p>



<figure class="wp-block-table aligncenter"><div class="scrollable-table"><table><tbody><tr><td class="has-text-align-center" data-align="center">タイトル</td><td class="has-text-align-center" data-align="center">対象</td><td class="has-text-align-center" data-align="center">特徴</td></tr><tr><td class="has-text-align-center" data-align="center"><a target="_self" href="https://www.amazon.co.jp/Unity%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8-Unity-2022%E5%AE%8C%E5%85%A8%E5%AF%BE%E5%BF%9C%E7%89%88-%E5%8C%97%E6%9D%91-%E6%84%9B%E5%AE%9F-ebook/dp/B09ZTKKHMM?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=1SGVRFH12HQQ3&amp;dib=eyJ2IjoiMSJ9.pxFtS28RU4-axWQckbWgzfFd7pwP1u2fP4QvU8oAHoi8pNogisZg9tSoCBc2sUkAEtNlZa6IZUGrngJ--d-7cwneVQJxqVsic46qNRgNwYxDJvUZgmGX7vi87nuZJ0fnXsUl7pIMd9CroDZqpvPF4R7T2b9vXmboKjtVrI3boBKvnnzIHnXytWScLMCTtTqeBNT-e3r3z9BVWTV7105qt8g3pkKQ4SECkRuVSjV6IN-Ot_1R6PkcitnKgY73F-wUYsgL_ypGOiuGHh1Mh8kH0vFKfYshWmZ4GikvZB2gcOM.lUgUEef69h1v_epv2VZ6hLkZ3iYKrFMTIIweaDP2AI8&amp;dib_tag=se&amp;keywords=Unity%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8&amp;qid=1711710907&amp;sprefix=unity%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8%2Caps%2C251&amp;sr=8-4&amp;linkCode=ll1&amp;tag=b0420e-22&amp;linkId=156a75cc6969b95f851a1ea3a6c20e76&amp;language=ja_JP&amp;ref_=as_li_ss_tl" data-type="link" data-id="https://www.amazon.co.jp/Unity%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8-Unity-2022%E5%AE%8C%E5%85%A8%E5%AF%BE%E5%BF%9C%E7%89%88-%E5%8C%97%E6%9D%91-%E6%84%9B%E5%AE%9F-ebook/dp/B09ZTKKHMM?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=1SGVRFH12HQQ3&amp;dib=eyJ2IjoiMSJ9.pxFtS28RU4-axWQckbWgzfFd7pwP1u2fP4QvU8oAHoi8pNogisZg9tSoCBc2sUkAEtNlZa6IZUGrngJ--d-7cwneVQJxqVsic46qNRgNwYxDJvUZgmGX7vi87nuZJ0fnXsUl7pIMd9CroDZqpvPF4R7T2b9vXmboKjtVrI3boBKvnnzIHnXytWScLMCTtTqeBNT-e3r3z9BVWTV7105qt8g3pkKQ4SECkRuVSjV6IN-Ot_1R6PkcitnKgY73F-wUYsgL_ypGOiuGHh1Mh8kH0vFKfYshWmZ4GikvZB2gcOM.lUgUEef69h1v_epv2VZ6hLkZ3iYKrFMTIIweaDP2AI8&amp;dib_tag=se&amp;keywords=Unity%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8&amp;qid=1711710907&amp;sprefix=unity%E3%81%AE%E6%95%99%E7%A7%91%E6%9B%B8%2Caps%2C251&amp;sr=8-4&amp;linkCode=ll1&amp;tag=b0420e-22&amp;linkId=156a75cc6969b95f851a1ea3a6c20e76&amp;language=ja_JP&amp;ref_=as_li_ss_tl">Unityの教科書 2023完全対応版</a></td><td class="has-text-align-center" data-align="center">入門・初心者</td><td class="has-text-align-center" data-align="center">プログラミング未経験でも、ゲーム制作したい人</td></tr><tr><td class="has-text-align-center" data-align="center"><a target="_self" href="https://www.amazon.co.jp/%E3%83%9E%E3%83%B3%E3%82%AC%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8B-Unity%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80-%E3%82%82%E3%82%8A%E3%82%84%E3%81%BE%E3%82%86%E3%81%86%E3%81%9F/dp/4295015245?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=37GKE3H3V6ART&amp;dib=eyJ2IjoiMSJ9.IRtPVCkXx6UYTZJq5ofVF9Cuq0qTAO_T_L3VGwgXVo4c3LYNz3DEzObe_fBKs4Ou34-uQk46OCOZ4wh6QukhqNAQ-HII4zCnyBhS7BQi1ctIa3rfOJlaSXHdBtyToLJqIBlpuIZSFHvPsb3lk-PtroOkA1RymynP7JPfBcqvw4kQgQmwSA4I6toh65e93UHB_a_Mrq0Eh8adPG8FCE1AwlUOgHtAv8yMBDy-5K_jBzUMqSCa5jJ7tcmbWKbPQ4qx4WseI0cfAdbzqV0Oz0cq-zaMoigLI8i1d2JHMpPUfFg.bg-zNGriRy4RtZLa1dATBKkFLH4HpRdpi7GnOOw0gxg&amp;dib_tag=se&amp;keywords=%E3%83%9E%E3%83%B3%E3%82%AC%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8B+unity+%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80&amp;qid=1711710929&amp;sprefix=%E3%83%9E%E3%83%B3%E3%82%AC%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8B+unity%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80%2Caps%2C183&amp;sr=8-1-spons&amp;sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&amp;psc=1&amp;linkCode=ll1&amp;tag=b0420e-22&amp;linkId=0c15ab7ce57576d597d904b84d3f0b28&amp;language=ja_JP&amp;ref_=as_li_ss_tl" data-type="link" data-id="https://www.amazon.co.jp/%E3%83%9E%E3%83%B3%E3%82%AC%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8B-Unity%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80-%E3%82%82%E3%82%8A%E3%82%84%E3%81%BE%E3%82%86%E3%81%86%E3%81%9F/dp/4295015245?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=37GKE3H3V6ART&amp;dib=eyJ2IjoiMSJ9.IRtPVCkXx6UYTZJq5ofVF9Cuq0qTAO_T_L3VGwgXVo4c3LYNz3DEzObe_fBKs4Ou34-uQk46OCOZ4wh6QukhqNAQ-HII4zCnyBhS7BQi1ctIa3rfOJlaSXHdBtyToLJqIBlpuIZSFHvPsb3lk-PtroOkA1RymynP7JPfBcqvw4kQgQmwSA4I6toh65e93UHB_a_Mrq0Eh8adPG8FCE1AwlUOgHtAv8yMBDy-5K_jBzUMqSCa5jJ7tcmbWKbPQ4qx4WseI0cfAdbzqV0Oz0cq-zaMoigLI8i1d2JHMpPUfFg.bg-zNGriRy4RtZLa1dATBKkFLH4HpRdpi7GnOOw0gxg&amp;dib_tag=se&amp;keywords=%E3%83%9E%E3%83%B3%E3%82%AC%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8B+unity+%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80&amp;qid=1711710929&amp;sprefix=%E3%83%9E%E3%83%B3%E3%82%AC%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8B+unity%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80%2Caps%2C183&amp;sr=8-1-spons&amp;sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&amp;psc=1&amp;linkCode=ll1&amp;tag=b0420e-22&amp;linkId=0c15ab7ce57576d597d904b84d3f0b28&amp;language=ja_JP&amp;ref_=as_li_ss_tl">マンガでわかる Unityゲーム開発入門</a></td><td class="has-text-align-center" data-align="center">入門・初心者</td><td class="has-text-align-center" data-align="center">Unityを挫折したけど、もう一度挑戦したい人<br>２Dゲームの作成をマンガで丁寧に解説</td></tr><tr><td class="has-text-align-center" data-align="center"><a target="_self" href="https://www.amazon.co.jp/%E4%BD%9C%E3%81%A3%E3%81%A6%E5%AD%A6%E3%81%B9%E3%82%8B-Unity%E6%9C%AC%E6%A0%BC%E5%85%A5%E9%96%80-%EF%BC%BBUnity-2023%E5%AF%BE%E5%BF%9C%E7%89%88%EF%BC%BD-%E8%B3%80%E5%A5%BD-%E6%98%AD%E4%BB%81/dp/4297137410?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=1FXS96EO25J9X&amp;dib=eyJ2IjoiMSJ9.E1ITbpWRi0veMut_5dTfeeQYrczHoC1KTk2HNJQz71JU-qx0XpwbQDUVhuC8nv5G7-vQgdahmxiwOKImlF36czHBE3APZifySduZbH-GsG3nlt4gR4kLMnjpJuM_Jhp7ZOQKQbXldiRQ9KXIdBFsnS563HvYTK0NEzRIV6Rk2OGt_O8putDG3zvVfQB79v0NptLWk7Jchl4YsKdXbjSAwZoLEep6pSYMy45brZttvng-ZlC_ak9iT5wesUBJ6PHh6ajKX173OeIAWa4Nbry4gxpaTjSUEwL1VN5VcZPPiw4.1SoEJFWy43PbI6Ye5FamVxVbNeYaN4mj4q8QX1CQMgE&amp;dib_tag=se&amp;keywords=%E4%BD%9C%E3%81%A3%E3%81%A6%E5%AD%A6%E3%81%B9%E3%82%8B+Unity%E6%9C%AC%E6%A0%BC%E5%85%A5%E9%96%80&amp;qid=1711710961&amp;sprefix=%E4%BD%9C%E3%81%A3%E3%81%A6%E5%AD%A6%E3%81%B9%E3%82%8B+unity%E6%9C%AC%E6%A0%BC%E5%85%A5%E9%96%80%2Caps%2C218&amp;sr=8-1&amp;linkCode=ll1&amp;tag=b0420e-22&amp;linkId=0bdc992bdcf9e58de9b9cfd15a7e7282&amp;language=ja_JP&amp;ref_=as_li_ss_tl" data-type="link" data-id="https://www.amazon.co.jp/%E4%BD%9C%E3%81%A3%E3%81%A6%E5%AD%A6%E3%81%B9%E3%82%8B-Unity%E6%9C%AC%E6%A0%BC%E5%85%A5%E9%96%80-%EF%BC%BBUnity-2023%E5%AF%BE%E5%BF%9C%E7%89%88%EF%BC%BD-%E8%B3%80%E5%A5%BD-%E6%98%AD%E4%BB%81/dp/4297137410?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=1FXS96EO25J9X&amp;dib=eyJ2IjoiMSJ9.E1ITbpWRi0veMut_5dTfeeQYrczHoC1KTk2HNJQz71JU-qx0XpwbQDUVhuC8nv5G7-vQgdahmxiwOKImlF36czHBE3APZifySduZbH-GsG3nlt4gR4kLMnjpJuM_Jhp7ZOQKQbXldiRQ9KXIdBFsnS563HvYTK0NEzRIV6Rk2OGt_O8putDG3zvVfQB79v0NptLWk7Jchl4YsKdXbjSAwZoLEep6pSYMy45brZttvng-ZlC_ak9iT5wesUBJ6PHh6ajKX173OeIAWa4Nbry4gxpaTjSUEwL1VN5VcZPPiw4.1SoEJFWy43PbI6Ye5FamVxVbNeYaN4mj4q8QX1CQMgE&amp;dib_tag=se&amp;keywords=%E4%BD%9C%E3%81%A3%E3%81%A6%E5%AD%A6%E3%81%B9%E3%82%8B+Unity%E6%9C%AC%E6%A0%BC%E5%85%A5%E9%96%80&amp;qid=1711710961&amp;sprefix=%E4%BD%9C%E3%81%A3%E3%81%A6%E5%AD%A6%E3%81%B9%E3%82%8B+unity%E6%9C%AC%E6%A0%BC%E5%85%A5%E9%96%80%2Caps%2C218&amp;sr=8-1&amp;linkCode=ll1&amp;tag=b0420e-22&amp;linkId=0bdc992bdcf9e58de9b9cfd15a7e7282&amp;language=ja_JP&amp;ref_=as_li_ss_tl">作って学べる Unity本格入門</a></td><td class="has-text-align-center" data-align="center">中級者～</td><td class="has-text-align-center" data-align="center">RPG、特に3Dゲームを作りながら学習したい人</td></tr><tr><td class="has-text-align-center" data-align="center"><a target="_self" href="https://www.amazon.co.jp/%E3%82%B9%E3%82%BF%E3%83%BC%E3%83%88%E3%82%A2%E3%83%83%E3%83%97%E3%83%BB%E5%80%8B%E4%BA%BA%E3%81%A7%E4%BD%9C%E3%82%8C%E3%82%8B-%E3%82%B9%E3%83%9E%E3%83%9B%E5%90%91%E3%81%91Unity-%E3%82%BD%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E3%82%AC%E3%82%A4%E3%83%89-%E5%B9%B3%E9%87%8E%E8%A3%95%E4%BD%9C-ebook/dp/B083Z2Z6PH/ref=sr_1_1?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=1GHD6QUC9N6GT&amp;dib=eyJ2IjoiMSJ9.bT_L95Ci0EBPgr9Crdt79_w-ULqsd9Pig_oKSPbJ_6ML-unSoMsoBHny0Sq5L4f4od4b5OJmj5SETzgTDT72uqJqwzi1uvTGzSPh2WcL4bqjn_Xh9jbq2E4E4ea5DGeDB7WuZ7GKLKRgMZmiYs1VX0xzHZxrtQ6mknR2SU8FGycWGzMfOXHdDYSHYpIxhBnhAQzbWrAcJicScn-0LwaGr5awakJEzSfCXa-DbH8ElqnR0Cl7VzuNjyP7-loL0lTP34tPd1CQtIW4_jjvr4dqU8BuTHK5k-rdVEFFfyMJLrU.B9Np3pFbtgQojkxKgXrtPicTJh11zttMWuCGD6tS8fo&amp;dib_tag=se&amp;keywords=Unity+%E3%82%BD%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E3%82%AC%E3%82%A4%E3%83%89&amp;qid=1711711002&amp;sprefix=unity+%E3%82%BD%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E3%82%AC%E3%82%A4%E3%83%89%2Caps%2C191&amp;sr=8-1" data-type="link" data-id="https://www.amazon.co.jp/%E3%82%B9%E3%82%BF%E3%83%BC%E3%83%88%E3%82%A2%E3%83%83%E3%83%97%E3%83%BB%E5%80%8B%E4%BA%BA%E3%81%A7%E4%BD%9C%E3%82%8C%E3%82%8B-%E3%82%B9%E3%83%9E%E3%83%9B%E5%90%91%E3%81%91Unity-%E3%82%BD%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E3%82%AC%E3%82%A4%E3%83%89-%E5%B9%B3%E9%87%8E%E8%A3%95%E4%BD%9C-ebook/dp/B083Z2Z6PH/ref=sr_1_1?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;crid=1GHD6QUC9N6GT&amp;dib=eyJ2IjoiMSJ9.bT_L95Ci0EBPgr9Crdt79_w-ULqsd9Pig_oKSPbJ_6ML-unSoMsoBHny0Sq5L4f4od4b5OJmj5SETzgTDT72uqJqwzi1uvTGzSPh2WcL4bqjn_Xh9jbq2E4E4ea5DGeDB7WuZ7GKLKRgMZmiYs1VX0xzHZxrtQ6mknR2SU8FGycWGzMfOXHdDYSHYpIxhBnhAQzbWrAcJicScn-0LwaGr5awakJEzSfCXa-DbH8ElqnR0Cl7VzuNjyP7-loL0lTP34tPd1CQtIW4_jjvr4dqU8BuTHK5k-rdVEFFfyMJLrU.B9Np3pFbtgQojkxKgXrtPicTJh11zttMWuCGD6tS8fo&amp;dib_tag=se&amp;keywords=Unity+%E3%82%BD%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E3%82%AC%E3%82%A4%E3%83%89&amp;qid=1711711002&amp;sprefix=unity+%E3%82%BD%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%82%B2%E3%83%BC%E3%83%A0%E9%96%8B%E7%99%BA%E3%82%AC%E3%82%A4%E3%83%89%2Caps%2C191&amp;sr=8-1">Unity ソーシャルゲーム開発ガイド</a></td><td class="has-text-align-center" data-align="center">中・上級者</td><td class="has-text-align-center" data-align="center">ガチャ・ログインボーナスなどのソシャゲの機能を開発したい人</td></tr></tbody></table></div></figure>
</div>



<h3 class="wp-block-heading">ネット検索</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/Online-Search.webp" alt="" class="wp-image-7850" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/Online-Search.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/Online-Search-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/Online-Search-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/Online-Search-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/Online-Search-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Unityの開発者が多いので、ウェブページでソースコードを紹介している人が多いです。<br>Unity公式の学習マップもあります。</p>



<p>無料で大量の情報が手に入ります。<br>ただし、<strong>メモ代わりに公開</strong>する人が多いので、<br><strong>情報が断片的</strong>です。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>当サイトでは、Unityの役立つ情報を発信しています！<br><a target="_self" href="https://alicia-ing.com/category/programming/unity/">こちらから</a>どうぞ～</p>
</div></div>



<p>初心者の場合は、絶対にゲームを完成させるという<strong>強い意志がないと挫折しやすい</strong>です。</p>



<h3 class="wp-block-heading">生成AI</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/AI.webp" alt="" class="wp-image-7851" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/AI.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/AI-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/AI-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/AI-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/AI-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>AIを活用して、特定の問題やコードの解決します。<br>また、<strong>作りたい機能を指示するだけ</strong>で具体的な回答を得られることも特徴です。</p>



<p>ただし、AIの情報が不正確な場合があるため、<strong>何度も検証が必要</strong>になります。<br><strong>指示がAIにとって曖昧</strong>だと目的のプログラムは組めません。</p>



<p>さらに、有料版に課金しないと利用制限がくるので、<strong>完成までに時間がかかります</strong>。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-1 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/alicia.webp" alt="著者の体験談" class="speech-icon-image"/></figure><div class="speech-name">著者の体験談</div></div><div class="speech-balloon">
<p>まずは<strong>基本的な文法や機能を理解してから使う</strong>ことをおすすめします。</p>
</div></div>



<h3 class="wp-block-heading"> プログラミングスクール・専門学校</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/school.webp" alt="" class="wp-image-7852" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/school.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/school-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/school-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/school-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/school-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>独学では、<strong>学習が進まず勉強期間が不必要に長くなる</strong>ことがあります。</p>



<p>そんな時は、実際の現場で働くエンジニアに直接指導してもらえるプログラミングスクールや専門学校がおすすめです。</p>



<p>これらのスクールではコストがかかりますが、<br>「<strong>時間を買う</strong>」という観点で見れば、コストパフォーマンスは非常に良い選択肢です。</p>



<h3 class="wp-block-heading">Udemy</h3>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F" class="broken_link">Udemy</a>は、<strong>Benesseと提携</strong>を結ぶ<strong>LMSサイト</strong>で、<br>オンラインでプログラミングを学べる<strong>ビデオ講座を提供するプラットフォーム</strong>です。</p>



<p>非常に多くの講座があり、特定のスキルに特化したものから、包括的なプログラミングコースまで選ぶことができます。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-777game%2F" class="broken_link">【Unity C# ゲーム開発超入門】7つのミニゲームを作っておぼえる！UnityとC#講座</a><br>Unityで頻出の機能を実際のゲーム作りで学習。<br><strong>何か作りたい、今後の開発で役立てたい初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-playing_cards%2F" class="broken_link">【Unity C# ゲーム開発初心者レベルアップ】7つのトランプゲームを作っておぼえる！UnityとC#講座</a><br>トランプやボードゲーム作りに特化している講座。<br><strong>テーブルゲームを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" type="link" id="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" class="broken_link">【全行程を網羅！最初に学びたい総合学習】Unityワールド制作講座<br></a>Unityワールド制作の全工程を学習できる講座。<br><strong>RPGを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fstudio_shimazu_nfrpg%2F" class="broken_link">Unity ゲーム開発：インディーゲームクリエイターが教える C#の基礎からゲームリリースまで【スタジオしまづ】</a><br>C#の文法やApp StoreとGoogle Playへゲームをリリース方法を解説。<br><strong>ゲームを出品したい人</strong>におすすめ。</li>
</ul>
</div>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>実際の現場の人や大学教授が講師な場合もある！</p>
</div></div>



<p>頻繁にセールが開催されており、<br><strong>95%OFFの破格な価格</strong>（1500円前後）で高品質な講座を受講することができます。</p>



<p>また、返金ポリシーに該当すれば<strong>30日間途中まで視聴していても全額返金も可能</strong>です。</p>



<h3 class="wp-block-heading">ブログ運営</h3>



<p><strong>プログラミングの上達は、アウトプット</strong>です。</p>



<p>単純なアウトプットは製作物を作ることですが、<br><strong>ブログに自分の書いたコードを公開する</strong>ことがおすすめです。</p>



<p>勉強と同じで人に教えることで自分の理解も深まります。<br><strong>ブログでスクリプトを解説し、どの場面で使うかなど情報発信</strong>します。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-1 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/alicia.webp" alt="著者の体験談" class="speech-icon-image"/></figure><div class="speech-name">著者の体験談</div></div><div class="speech-balloon">
<p>忘れたときには自分のブログを見ています。</p>
</div></div>



<h4 class="wp-block-heading">UdemyでUnityを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F" class="broken_link">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-micro-text aligncenter micro-text micro-copy micro-top"><span class="micro-text-content micro-content">＼Unityの学習から収益化の方法はこちらから！／</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/roadmap-cs/" title="【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！</div><div class="blogcard-snippet internal-blogcard-snippet">Unityを使って自作ゲームを作りたい方必見。ゲームエンジン選択から学習方法、収益化の手段まで初心者向けにわかりやすく解説します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-777game%2F" class="broken_link">【Unity C# ゲーム開発超入門】7つのミニゲームを作っておぼえる！UnityとC#講座</a><br>Unityで頻出の機能を実際のゲーム作りで学習。<br><strong>何か作りたい、今後の開発で役立てたい初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-playing_cards%2F" class="broken_link">【Unity C# ゲーム開発初心者レベルアップ】7つのトランプゲームを作っておぼえる！UnityとC#講座</a><br>トランプやボードゲーム作りに特化している講座。<br><strong>テーブルゲームを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" type="link" id="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" class="broken_link">【全行程を網羅！最初に学びたい総合学習】Unityワールド制作講座<br></a>Unityワールド制作の全工程を学習できる講座。<br><strong>RPGを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fstudio_shimazu_nfrpg%2F" class="broken_link">Unity ゲーム開発：インディーゲームクリエイターが教える C#の基礎からゲームリリースまで【スタジオしまづ】</a><br>C#の文法やApp StoreとGoogle Playへゲームをリリース方法を解説。<br><strong>ゲームを出品したい人</strong>におすすめ。</li>
</ul>
</div>



<h2 class="wp-block-heading">Unityで稼ぐには？</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Earn-with-Unity.webp" alt="" class="wp-image-7857" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Earn-with-Unity.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Earn-with-Unity-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Earn-with-Unity-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Earn-with-Unity-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/How-to-Earn-with-Unity-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Unityを使ってスキルを身に付けたら、<br>その技術を使って<strong>収益化する</strong>ことができます。</p>



<p>Unityは非常に柔軟なゲームエンジンであり、<br>その活用次第で<strong>様々な形で収入を得ることが可能</strong>です。</p>



<p>ここでは、Unityを使った具体的な稼ぎ方について解説します。</p>



<h3 class="wp-block-heading">ゲームを公開する</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/Publishing-Games.webp" alt="" class="wp-image-7860" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/Publishing-Games.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/Publishing-Games-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/Publishing-Games-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/Publishing-Games-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/Publishing-Games-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Unityで作成したゲームを公開することで収益を得ることができます。</p>



<p>以下のようなプラットフォームでゲームをリリースすることで、<br>購入収益や広告収益を得ることが可能です。</p>



<p>各プラットフォームには、それぞれ<strong>異なる登録料や手数料が設定</strong>されています。<br>以下は、<strong>主なプラットフォームの手数料・登録料</strong>のまとめです。</p>



<figure class="wp-block-table is-style-regular"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>プラットフォーム</th><th>登録料</th><th>販売手数料</th></tr></thead><tbody><tr><td>Steam</td><td>100ドル/タイトル</td><td>~30%</td></tr><tr><td>BOOTH</td><td>無料</td><td>3.6% + 決済手数料</td></tr><tr><td>Dlsite</td><td>無料</td><td>~50%</td></tr><tr><td>App Store</td><td>99ドル/年</td><td>30%（15%に減額可能）</td></tr><tr><td>Google Play</td><td>25ドル（初回）</td><td>30%（15%に減額可能）</td></tr></tbody></table></div></figure>



<ul class="wp-block-list">
<li><strong>Steam</strong></li>
</ul>



<p>Steamは、Valve社が運営するインディーゲーム開発者向けの人気プラットフォームです。<br><strong>PCゲームのリリースには最適</strong>で、<strong>広いユーザー層</strong>を持っています。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>PCの場合はSteam一択！</p>
</div></div>



<p>手数料とは別に登録料が<strong>１タイトルごとに100ドル</strong>かかります。<br>ただし、そのタイトルが1000ドル売れることで<em>返金</em>されます。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p><strong>15万円売る</strong>のは意外と厳しそう&#8230;</p>
</div></div>



<ul class="wp-block-list">
<li><strong>BOOTH</strong></li>
</ul>



<p>BOOTHは、<strong>pixivが運営する</strong>クリエイター向けのマーケットプレイスで、<br>主に同人作品やデジタルコンテンツの販売に利用されています。</p>



<p>ゲームやアートワークなど、<strong>幅広い商品が販売</strong>されています。<br>pixivユーザーに向けて簡単に作品を宣伝・販売できる点が魅力です。</p>



<p>また、デジタルコンテンツを中心としたクリエイターが集まっているため、コミュニティ内での認知が得やすく、独自のターゲット層にアプローチできます。</p>



<p><strong>無料で販売を始められる</strong>ので、特に小規模での販売やテストマーケットに向いています。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>駆け出しの場合は、BOOTHがおすすめ！</p>
</div></div>



<ul class="wp-block-list">
<li><strong>Dlsite</strong></li>
</ul>



<p>Dlsiteは、日本で特に<strong>同人ゲームに強みを持つプラットフォーム</strong>です。<br>ニッチな市場にアプローチする場合に非常に有効です。</p>



<p>手数料は、販売価格が格安ほど上がり、<br>最低価格の<strong>100円だと50円</strong>になります。</p>



<p>BOOTHと同様に<strong>無料で販売を始められる</strong>ので、<br>とりあえず出品にも優しいです。</p>



<ul class="wp-block-list">
<li><strong>Google、Apple</strong></li>
</ul>



<p>それぞれスマホやタブレットでゲームを販売するときに使用します。<br>いずれも登録料がかかります。</p>



<p>年間収益が100万ドル以下の場合、販売手数料は15%に減額されます。</p>



<h3 class="wp-block-heading"> 案件を獲得する</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2024/10/Securing-Freelance-Jobs.webp" alt="" class="wp-image-7861" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/Securing-Freelance-Jobs.webp 1980w, https://alicia-ing.com/wp-content/uploads/2024/10/Securing-Freelance-Jobs-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/Securing-Freelance-Jobs-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/Securing-Freelance-Jobs-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/Securing-Freelance-Jobs-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p>Unityのスキルを活かして収入を得るには、案件を獲得する方法が効果的です。<br>そのためには、副業としての働き方と正社員としての転職活動、二つの選択肢があります。</p>



<p>それぞれの選択肢について、具体的にどのように活用できるかを詳しく説明します。</p>



<p>副業であれば、<a rel="nofollow" target="_self" href="//af.moshimo.com/af/c/click?a_id=4240861&#038;p_id=968&#038;pc_id=1262&#038;pl_id=13839" referrerpolicy="no-referrer-when-downgrade" attributionsrc>レバテックフリーランス</a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4240861&#038;p_id=968&#038;pc_id=1262&#038;pl_id=13839" width="1" height="1" style="border:none;" loading="lazy">がおすすめです。</p>



<p><a rel="nofollow" target="_self" href="//af.moshimo.com/af/c/click?a_id=4240861&#038;p_id=968&#038;pc_id=1262&#038;pl_id=13839" referrerpolicy="no-referrer-when-downgrade" attributionsrc>レバテックフリーランス</a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4240861&#038;p_id=968&#038;pc_id=1262&#038;pl_id=13839" width="1" height="1" style="border:none;" loading="lazy">は、ITエンジニアやクリエイター向けに<b>多くのフリーランス案件を提供</b>しており、<b>Unityを使ったゲーム開発案件も豊富</b>にあります。



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>在宅からでも仕事を受けることが可能！</p>
</div></div>



<p>Unityのスキルを持っていれば、<br>短期・中期の開発案件に携わりながら収入を得ることが可能です。</p>



<p>特にリモートワークに対応した案件が多く、<br><strong>自分のペースで働ける柔軟な働き方ができる</strong>のが大きな特徴です。</p>



<p>契約単価は比較的高いので、それなりの経験を求められます。<br><strong>実務経験が必要</strong>な場合もあります。</p>



<p>エージェントのサポートにより、企業とのマッチングや契約交渉がスムーズに進むため、営業に慣れていない方でも安心して<strong>案件に参加できる環境</strong>が整っています。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>ゲームを公開することで、実績を作ろう！</p>
</div></div>



<p>転職活動を通じてUnityのスキルを活かす場合、<br><a rel="nofollow" target="_self" href="//af.moshimo.com/af/c/click?a_id=4240859&#038;p_id=969&#038;pc_id=1263&#038;pl_id=13840" referrerpolicy="no-referrer-when-downgrade" attributionsrc>レバテックキャリア</a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4240859&#038;p_id=969&#038;pc_id=1263&#038;pl_id=13840" width="1" height="1" style="border:none;" loading="lazy">を利用するのが効果的です。</p>



<p><a rel="nofollow" target="_self" href="//af.moshimo.com/af/c/click?a_id=4240859&#038;p_id=969&#038;pc_id=1263&#038;pl_id=13840" referrerpolicy="no-referrer-when-downgrade" attributionsrc>レバテックキャリア</a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4240859&#038;p_id=969&#038;pc_id=1263&#038;pl_id=13840" width="1" height="1" style="border:none;" loading="lazy">ITエンジニア向けの転職エージェントであり、<br><b>特にIT業界への転職</b>に強みを持っています。</p>



<p>Unityを使ったゲーム会社のポジションには、モバイルゲームの開発からVRゲーム、メタバース関連の技術開発まで多様なプロジェクトがあります。</p>



<p>企業でのポジションを探す際に、キャリアアドバイザーのサポートを受けながら転職活動を進めることができます。</p>



<p><strong>履歴書や職務経歴書の添削、面接対策などの支援を受ける</strong>ことで、<br>企業とのマッチングの精度を高め、スムーズに転職活動を行えるのが特徴です。</p>



<p>業界に精通したアドバイザーからは、業界の情報や転職のアドバイスを得られるため、求人情報を集める手間が省けるだけでなく、<strong>自分に最適なポジションにアクセスできる利点</strong>があります。</p>



<div class="wp-block-cocoon-blocks-column-2 column-wrap column-2 column-2-2-1-1 layout-box">
<div class="wp-block-cocoon-blocks-column-left column-left">
<a rel="nofollow" target="_self" href="//af.moshimo.com/af/c/click?a_id=4240861&#038;p_id=968&#038;pc_id=1262&#038;pl_id=13876" referrerpolicy="no-referrer-when-downgrade" attributionsrc><img loading="lazy" decoding="async" src="//image.moshimo.com/af-img/0304/000000013876.jpg" width="250" height="250" style="border:none;"></a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4240861&#038;p_id=968&#038;pc_id=1262&#038;pl_id=13876" width="1" height="1" style="border:none;" loading="lazy">
</div>



<div class="wp-block-cocoon-blocks-column-right column-right">
<a rel="nofollow" target="_self" href="//af.moshimo.com/af/c/click?a_id=4240859&#038;p_id=969&#038;pc_id=1263&#038;pl_id=57639" referrerpolicy="no-referrer-when-downgrade" attributionsrc><img loading="lazy" decoding="async" src="//image.moshimo.com/af-img/0304/000000057639.gif" width="250" height="250" style="border:none;"></a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4240859&#038;p_id=969&#038;pc_id=1263&#038;pl_id=57639" width="1" height="1" style="border:none;" loading="lazy">
</div>
</div>



<p>Unityのスキルを活かして案件を獲得するためには、<br>自分のライフスタイルやキャリアの目標に合わせて、フリーランスでの柔軟な働き方を選ぶか、転職を通じて安定したポジションを探すかを決めることが重要です。</p>



<p>それぞれの方法には異なる特徴と利点があるため、<br>自分に合った方法でスキルを活かし、<strong>経験を積みながら収入を得る</strong>ことを目指してみてください。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p>個人で作るか、フリーランスか、正社員か&#8230;</p>
</div></div>



<h2 class="wp-block-heading">まとめ</h2>



<p>本記事では、Unityを使って自作ゲームを開発したい人に向けて、学習から収益化までの道のりを詳しく解説しました。</p>



<p>まず、UnityとUnreal Engineの比較を通して、Unityの特徴や選ぶ理由を示しました。</p>



<p>Unityを学ぶためのさまざまな方法を紹介し、<br>教本やオンライン講座、プログラミングスクールなど、それぞれの特徴を解説しました。</p>



<p>Unityのスキルを使って収益化する方法についても詳しく述べました。自作ゲームを公開するための主要プラットフォームについて、その手数料や登録料など具体的な情報を紹介し、どのプラットフォームがどのようなユーザーに適しているかについても触れました。</p>



<p>Unityを活用して案件を獲得する方法として、副業や転職の選択肢を説明しました。<br>フリーランスでの働き方、エージェントの活用方法、正社員としてゲーム業界でキャリアを築く手段について、それぞれの特徴を示しました。</p>



<p>Unityは初心者からプロフェッショナルまで幅広く活用できるゲームエンジンであり、正しい学習方法を選び、スキルをうまく活用することで、ゲーム開発の夢を実現すると同時に収入を得ることも可能です。</p>



<p>本記事を通じて、Unityでの学び方やキャリアの可能性について理解を深め、<br>自分の目標に合ったステップを踏み出してください。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/unity/roadmap-cs/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Unity】分岐可能！複数のcsvファイルをロードする方法</title>
		<link>https://alicia-ing.com/programming/unity/multi-csv-load/</link>
					<comments>https://alicia-ing.com/programming/unity/multi-csv-load/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 27 Oct 2024 22:00:00 +0000</pubDate>
				<category><![CDATA[Unity]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=7410</guid>

					<description><![CDATA[Unityでゲームやアプリを開発する際にCSVファイルシナリオやデータを簡単にロードできます。 特にシナリオ分岐や膨大なデータを管理する場合、CSVを活用することで、プロジェクトの管理が飛躍的に楽になります。 本記事では [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p>画面クリックすると、複数のcsvを読み込む</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="945" src="https://alicia-ing.com/wp-content/uploads/2024/10/complete-2.gif" alt="" class="wp-image-7416"/></figure>
</div></div>



<p>Unityでゲームやアプリを開発する際にCSVファイル<br>シナリオやデータを簡単にロードできます。</p>



<p>特にシナリオ分岐や膨大なデータを管理する場合、<br>CSVを活用することで、プロジェクトの管理が飛躍的に楽になります。</p>



<p>本記事では、複数のCSVファイルをロードして、<br>それらをシーンや選択肢に応じて動的に切り替える方法を詳しく解説します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Unityで分岐シナリオ(選択肢)を実装したい</li>



<li>複数のCSVファイルを簡単にロードしたい</li>



<li>シナリオ管理を効率化したい</li>



<li>テキストベースのノベルゲームを作成したい</li>



<li>Unityでのファイル管理を学びたい</li>
</ul>
</div></div>



<h2 class="wp-block-heading">.Clear()</h2>



<p>Clear()メソッドは、コレクション（リストや配列など）に<strong>格納されたデータを削除</strong>し、空にするために使用されます。</p>



<p><strong>複数のcsvを扱う</strong>際には、CSVデータを格納するリストcsvDataをクリアして、<br>次にロードされるCSVファイルのデータが重複しないように管理しています。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>基礎的なcsvファイルの読み込みを解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/csv-load/" title="【Unity】CSVファイルを読み込み、テキストを画面に表示する" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2022/12/csv-load-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】CSVファイルを読み込み、テキストを画面に表示する</div><div class="blogcard-snippet internal-blogcard-snippet">UnityでのCSVファイルの読み込み方法を解説します。エクセルやGoogleスプレッドシートでcsvを作成し、データのインポート・読み書き・外部ファイル読み込みを簡単に実装する方法を紹介。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.12</div></div></div></div></a>
</div>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>void LoadCSV(TextAsset csvFile)
{
    csvData.Clear(); // 前のデータをクリア
    Line = 0; // 行番号をリセット
    // CSVデータの読み込み処理
}</code></pre></div>



<p><strong>次のCSVファイルをロードする際に前</strong>のデータを一旦クリアすることで、<br>新しいデータが正常に読み込まれ、余計なバグを防ぐことができます。</p>



<h2 class="wp-block-heading">csvファイルの読み込みを変更する</h2>



<p>複数のCSVファイルを順に読み込む際に、<br>特定の条件やタイミングでファイルを変更したり、<br>次のCSVファイルに切り替える方法を学ぶことが重要です。</p>



<p>本スクリプトでは、index変数を使って現在のCSVファイルを追跡し、<br>すべての行を表示し終わったら次のファイルに自動的に切り替えます。</p>



<p>機能として、画面クリックでindex変数を進めます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>画面クリックしてcsvを進める方法を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/ui-text/" title="【Unity】UIテキスト表示と使い方ー画面を押して文字を変える" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2022/12/ui-text-unity-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2022/12/ui-text-unity-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2022/12/ui-text-unity-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2022/12/ui-text-unity-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】UIテキスト表示と使い方ー画面を押して文字を変える</div><div class="blogcard-snippet internal-blogcard-snippet">この記事は、Unityでのテキスト表示について解説しています。Debug.Log()とUIテキストの違い、TextMeshProの使用法を説明し、初心者向けにノベルゲームの基礎の機能を紹介。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.05.18</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">ソースコード</h3>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using TMPro; // TextMeshProの追加

public class Multicsv : MonoBehaviour
{
    public TextMeshProUGUI DisplayText; // 表示するテキストUI
    public TextAsset[] csvFiles; // CSVファイル配列

    private List&lt;string[]&gt; csvData = new List&lt;string[]&gt;();
    private int Line = 0;
    private int index = 0;

    void Start()
    {
        if (csvFiles.Length &gt; 0)
        {
            LoadCSV(csvFiles[index]); // 最初のCSVファイルをロード
            DisplayNextLine();
        }
        else
        {
            Debug.LogError(&quot;CSVファイルがアタッチされていません。&quot;);
        }
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0)) // クリックで次の行へ
        {
            DisplayNextLine();
        }
    }

    // CSVをロードするメソッド
    void LoadCSV(TextAsset csvFile)
    {
        csvData.Clear(); // 前のデータをクリア
        Line = 0; // 行番号をリセット

        StringReader reader = new StringReader(csvFile.text);

        while (reader.Peek() != -1)
        {
            string line = reader.ReadLine();
            csvData.Add(line.Split(&#39;,&#39;)); // CSVファイルの各行をリストに追加
        }

        Debug.Log(csvFile.name + &quot;をロードしました&quot;);
    }

    void DisplayNextLine()
    {
        if (Line &gt;= csvData.Count)
        {
            // 現在のCSVが終わったら次のCSVに切り替える
            index++;

            if (index &lt; csvFiles.Length)
            {
                LoadCSV(csvFiles[index]); // 次のCSVファイルをロード
                DisplayNextLine(); // 次の行を表示
            }
            else
            {
                Debug.Log(&quot;すべてのCSVファイルを表示しました。&quot;);
            }
            return;
        }

        string[] lineData = csvData[Line];

        // テキストの表示
        DisplayText.text = lineData[0]; // テキスト内容は2列目にあると仮定
        Line++;
    }
}</code></pre></div>



<h4 class="wp-block-heading">UdemyでUnityを学習</h4>



<p><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-micro-text aligncenter micro-text micro-copy micro-top"><span class="micro-text-content micro-content">＼Unityの学習から収益化の方法はこちらから！／</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/roadmap-cs/" title="【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/10/roadmap-cs-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】学習ロードマップ｜自作ゲームを作りたい人必見！</div><div class="blogcard-snippet internal-blogcard-snippet">Unityを使って自作ゲームを作りたい方必見。ゲームエンジン選択から学習方法、収益化の手段まで初心者向けにわかりやすく解説します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-777game%2F">【Unity C# ゲーム開発超入門】7つのミニゲームを作っておぼえる！UnityとC#講座</a><br>Unityで頻出の機能を実際のゲーム作りで学習。<br><strong>何か作りたい、今後の開発で役立てたい初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fild-unity-playing_cards%2F">【Unity C# ゲーム開発初心者レベルアップ】7つのトランプゲームを作っておぼえる！UnityとC#講座</a><br>トランプやボードゲーム作りに特化している講座。<br><strong>テーブルゲームを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F" data-type="link" data-id="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Funityworld%2F">【全行程を網羅！最初に学びたい総合学習】Unityワールド制作講座<br></a>Unityワールド制作の全工程を学習できる講座。<br><strong>RPGを作りたい人</strong>におすすめ。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fstudio_shimazu_nfrpg%2F">Unity ゲーム開発：インディーゲームクリエイターが教える C#の基礎からゲームリリースまで【スタジオしまづ】</a><br>C#の文法やApp StoreとGoogle Playへゲームをリリース方法を解説。<br><strong>ゲームを出品したい人</strong>におすすめ。</li>
</ul>
</div>



<h3 class="wp-block-heading">解説</h3>



<ul class="wp-block-list">
<li><strong>名前空間</strong></li>
</ul>



<p>「System.Collections」：コレクションを扱うために必要な名前空間で、リストなどのデータ構造を利用するために使います。<br>「System.Collections.Generic」：ジェネリックコレクションを扱うために必要な名前空間で、型指定したリストなどを使うために使用します。<br>「UnityEngine」：Unityの基本的なクラスや関数（例えば、MonoBehaviourやDebug.Logなど）を使うために必要です。<br>「System.IO」：ファイルの入出力操作を行うための名前空間で、CSVファイルの内容を読み込むために使用しています。<br>「TMPro」：TextMeshProを使ってUIにテキストを表示するために必要な名前空間です。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>textmeshproの使い方を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/textmeshpro/" title="【Unity】TextMeshPro-日本語表示とスクリプト制御" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2024/01/textmeshpro-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】TextMeshPro-日本語表示とスクリプト制御</div><div class="blogcard-snippet internal-blogcard-snippet">UnityのTextMeshProは日本語のテキストを美しく表示し、スクリプトでテキストを動的に変更することも可能です。改行は&quot;\n&quot;でします。&quot;japanese_full.txt&quot;ファイルを読み込んでTextMeshProに適用します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<ul class="wp-block-list">
<li><strong>フィールド（メンバ変数）</strong></li>
</ul>



<p>「DisplayText」：ゲーム内に表示するテキストUIコンポーネントを参照します。<br>「csvFiles」：複数のCSVファイルを配列として保持し、順に読み込むために使います。<br>「csvData」：現在読み込まれているCSVファイルのデータを行ごとに保持するリストです。<br>「Line」：現在表示しているCSVデータの行番号を管理します。<br>「index」：現在読み込んでいるCSVファイルのインデックスを管理します。</p>



<ul class="wp-block-list">
<li><strong>Startメソッド</strong></li>
</ul>



<p>csvFilesに<strong>アタッチされたCSVファイルをロード</strong>し、1行目を表示します。<br>もしファイルがアタッチされていなければエラーメッセージを表示します。</p>



<ul class="wp-block-list">
<li><strong>Updateメソッド</strong></li>
</ul>



<p>ユーザーの<strong>クリック入力を検知</strong>します。<br>クリックされるとDisplayNextLineメソッドを呼び出して次の行を表示します。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>マウスクリックについてまとめています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/unity/mouse-input/" title="【Unity】マウス操作をゲームに導入する画面クリックで処理" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2022/12/mouse-input-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2022/12/mouse-input-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2022/12/mouse-input-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2022/12/mouse-input-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Unity】マウス操作をゲームに導入する画面クリックで処理</div><div class="blogcard-snippet internal-blogcard-snippet">UnityでCSVのテキストをマウスクリックで１つずつ進めるには、if文でメソッド「Input.GetMouseButtonDown(0)」を使用します。ノベルゲームは画面のクリック回数に応じてテキストを表示するシステムに近づきます。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<ul class="wp-block-list">
<li><strong>LoadCSVメソッド</strong></li>
</ul>



<p>指定されたCSVファイルの内容をリストcsvDataに読み込みます。<br>リスト<strong>csvDataをクリア</strong>し、行番号をリセットします。</p>



<p>StringReaderを用いてCSVファイルの各行を読み込み、<br>それを<strong>カンマ区切りで分割してリストに格納</strong>します。</p>



<ul class="wp-block-list">
<li><strong>DisplayNextLineメソッド</strong></li>
</ul>



<p>現在の行番号に対応するCSVデータをUIに表示します。<br>すべての行を表示し終わったら<strong>次のCSVファイルに切り替え</strong>ます。</p>



<p>全てのCSVファイルを表示し終わった場合、処理が終了します。</p>



<h2 class="wp-block-heading">実演</h2>



<p>画面上にテキストUIを配置します。</p>



<p>Resourcesフォルダー内にcsvを用意し、<br>これらをアタッチします。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="489" src="https://alicia-ing.com/wp-content/uploads/2024/10/attach-1024x489.webp" alt="UIやデータのアタッチ" class="wp-image-7418" srcset="https://alicia-ing.com/wp-content/uploads/2024/10/attach-1024x489.webp 1024w, https://alicia-ing.com/wp-content/uploads/2024/10/attach-300x143.webp 300w, https://alicia-ing.com/wp-content/uploads/2024/10/attach-768x367.webp 768w, https://alicia-ing.com/wp-content/uploads/2024/10/attach-1536x734.webp 1536w, https://alicia-ing.com/wp-content/uploads/2024/10/attach.webp 1915w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>クリックごとにUpdateメソッドが呼ばれ、<br>現在のCSVファイルのすべての行を表示し終わったら、次のCSVファイルをロードします。</p>



<p>すべてのCSVファイルを表示し終わった場合は、終了メッセージを表示します。</p>



<p>CSVファイルは、LoadCSVメソッドを使ってテキストとして読み込まれ、<br>その内容をカンマ区切りでリストに保存します。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>Unityで複数のCSVファイルをロードして分岐シナリオを作成する方法を解説しました。</p>



<p>Clear()メソッドを使って前のデータをクリアしたり、index変数で次のファイルを動的に切り替えることで、柔軟にファイル管理ができます。</p>



<p>このシステムを使うことで、分岐シナリオや大規模なデータを効率的に管理し、スムーズなゲーム体験を提供できます。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/unity/multi-csv-load/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
