SlideShare a Scribd company logo
Unity + C#発展講座②
ゆゆ
この講座でやること
• 前の講座の復習やるよ
• C# 変数 , 型 , 真偽値 , if , while, for , 配列 , リスト , 関数
• Unity GameObject , Component , uGUI
• Nanka Emoi Shootingをもっとエモくするよ
• Unity 音声再生 , uGUI , エフェクト , アニメーション
• QGJで書いてもらったプログラムを見てみるよ
• ここはこう書く手もある みたいな話をします
この講座でやること
• 前の講座の復習やるよ
• C# 変数 , 型 , 真偽値 , if , while, for , 配列 , リスト , 関数
• Unity GameObject , Component , uGUI
• Nanka Emoi Shootingをもっとエモくするよ
• Unity 音声再生 , uGUI , エフェクト , アニメーション
• QGJで書いてもらったプログラムを見てみるよ
• ここはこう書く手もある みたいな話をします
音声再生
音声再生
• 以下の2つのComponentが必要
• AudioListner 耳。世界に1つあればいい。
• AudioSource 音源。いくつあってもいい。
耳側
音源側
音源側
音源側
音源側
音声再生
• 以下の2つのComponentが必要
• AudioListner 耳。世界に1つあればいい。
• AudioSource 音源。いくつあってもいい。
耳側
音源側
音源側
音源側
音源側
音声再生 (BGM)
• Nanka Emoi ShootingにBGMをつけよう
• やり方
1. 音源再生用の GameObject を作る
2. AudioSource をアタッチする
3. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
音声再生 (BGM)
• Nanka Emoi ShootingにBGMをつけよう
• やり方
1. 音源再生用の GameObject を作る
2. AudioSource をアタッチする
3. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
音声再生 (BGM)
• Nanka Emoi ShootingにBGMをつけよう
• やり方
1. 音源再生用の GameObject を作る
2. AudioSource をアタッチする
3. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
音声再生 (BGM)
• Nanka Emoi ShootingにBGMをつけよう
• やり方
1. 音源再生用の GameObject を作る
2. AudioSource をアタッチする
3. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
音声再生 (効果音)
• Nanka Emoi Shootingに効果音をつけよう
• 「敵を倒した時」に爆発音を鳴らす
• 自動再生じゃだめ
• スクリプトから音声を鳴らしたい!!
• やり方
1. 音が出るGameObjectにAudioSource をアタッチする
2. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
音声再生 (効果音)
• Nanka Emoi Shootingに効果音をつけよう
• 「敵を倒した時」に爆発音を鳴らす
• 自動再生じゃだめ
• スクリプトから音声を鳴らしたい!!
• やり方
1. 音が出るGameObjectにAudioSource をアタッチする
2. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
音声再生 (効果音)
• Nanka Emoi Shootingに効果音をつけよう
• 「敵を倒した時」に爆発音を鳴らす
• 自動再生じゃだめ
• スクリプトから音声を鳴らしたい!!
• やり方
1. 音が出るGameObjectにAudioSource をアタッチする
2. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
音声再生 (効果音)
• Nanka Emoi Shootingに効果音をつけよう
• 「敵を倒した時」に爆発音を鳴らす
• 自動再生じゃだめ
• スクリプトから音声を鳴らしたい!!
• やり方
1. 音が出るGameObjectにAudioSource をアタッチする
2. 以下の2箇所を設定する
• AudioClip 再生する音源
• PlayOnAwake シーン開始時に自動的に再生するか
3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
uGUI
uGUI
• Unity で GUI を簡単に実装するためのシステム
• 画面に張り付いた感じのもの
• 文字、ボタン、スライダー、画像、文字入力欄、スクロールビュー、……
• 会話ウィンドウ、HPバーとかに使える
uGUI (ボタン)
• タイトル画面に「ゲームスタート」のボタンを付けてみよう!
• 必要なもの
• ボタンそのもの
• ボタンを押したときの処理
uGUI (ボタン)
• ボタンの作り方
1. Hierarcyで右クリック
2. UI → Button をクリック
3. 場所を指定
4. テキストを指定 「ゲームスタート」
• 押したときの処理の設定の仕方
1. スクリプトにpublic関数として書く
• 今回はゲーム用のシーンを読み込む処理
2. ボタンの Event に設定
public void GameStart() {
SceneManager.LoadScene("GameScene");
}

More Related Content

Featured

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 

Featured (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Unity + C#講座②

  • 2. この講座でやること • 前の講座の復習やるよ • C# 変数 , 型 , 真偽値 , if , while, for , 配列 , リスト , 関数 • Unity GameObject , Component , uGUI • Nanka Emoi Shootingをもっとエモくするよ • Unity 音声再生 , uGUI , エフェクト , アニメーション • QGJで書いてもらったプログラムを見てみるよ • ここはこう書く手もある みたいな話をします
  • 3. この講座でやること • 前の講座の復習やるよ • C# 変数 , 型 , 真偽値 , if , while, for , 配列 , リスト , 関数 • Unity GameObject , Component , uGUI • Nanka Emoi Shootingをもっとエモくするよ • Unity 音声再生 , uGUI , エフェクト , アニメーション • QGJで書いてもらったプログラムを見てみるよ • ここはこう書く手もある みたいな話をします
  • 5. 音声再生 • 以下の2つのComponentが必要 • AudioListner 耳。世界に1つあればいい。 • AudioSource 音源。いくつあってもいい。 耳側 音源側 音源側 音源側 音源側
  • 6. 音声再生 • 以下の2つのComponentが必要 • AudioListner 耳。世界に1つあればいい。 • AudioSource 音源。いくつあってもいい。 耳側 音源側 音源側 音源側 音源側
  • 7. 音声再生 (BGM) • Nanka Emoi ShootingにBGMをつけよう • やり方 1. 音源再生用の GameObject を作る 2. AudioSource をアタッチする 3. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか
  • 8. 音声再生 (BGM) • Nanka Emoi ShootingにBGMをつけよう • やり方 1. 音源再生用の GameObject を作る 2. AudioSource をアタッチする 3. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか
  • 9. 音声再生 (BGM) • Nanka Emoi ShootingにBGMをつけよう • やり方 1. 音源再生用の GameObject を作る 2. AudioSource をアタッチする 3. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか
  • 10. 音声再生 (BGM) • Nanka Emoi ShootingにBGMをつけよう • やり方 1. 音源再生用の GameObject を作る 2. AudioSource をアタッチする 3. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか
  • 11. 音声再生 (効果音) • Nanka Emoi Shootingに効果音をつけよう • 「敵を倒した時」に爆発音を鳴らす • 自動再生じゃだめ • スクリプトから音声を鳴らしたい!! • やり方 1. 音が出るGameObjectにAudioSource をアタッチする 2. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか 3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
  • 12. 音声再生 (効果音) • Nanka Emoi Shootingに効果音をつけよう • 「敵を倒した時」に爆発音を鳴らす • 自動再生じゃだめ • スクリプトから音声を鳴らしたい!! • やり方 1. 音が出るGameObjectにAudioSource をアタッチする 2. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか 3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
  • 13. 音声再生 (効果音) • Nanka Emoi Shootingに効果音をつけよう • 「敵を倒した時」に爆発音を鳴らす • 自動再生じゃだめ • スクリプトから音声を鳴らしたい!! • やり方 1. 音が出るGameObjectにAudioSource をアタッチする 2. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか 3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
  • 14. 音声再生 (効果音) • Nanka Emoi Shootingに効果音をつけよう • 「敵を倒した時」に爆発音を鳴らす • 自動再生じゃだめ • スクリプトから音声を鳴らしたい!! • やり方 1. 音が出るGameObjectにAudioSource をアタッチする 2. 以下の2箇所を設定する • AudioClip 再生する音源 • PlayOnAwake シーン開始時に自動的に再生するか 3. AudioSourceが代入された変数.PlayOneShot(音源が代入された変数);
  • 15. uGUI
  • 16. uGUI • Unity で GUI を簡単に実装するためのシステム • 画面に張り付いた感じのもの • 文字、ボタン、スライダー、画像、文字入力欄、スクロールビュー、…… • 会話ウィンドウ、HPバーとかに使える
  • 17. uGUI (ボタン) • タイトル画面に「ゲームスタート」のボタンを付けてみよう! • 必要なもの • ボタンそのもの • ボタンを押したときの処理
  • 18. uGUI (ボタン) • ボタンの作り方 1. Hierarcyで右クリック 2. UI → Button をクリック 3. 場所を指定 4. テキストを指定 「ゲームスタート」 • 押したときの処理の設定の仕方 1. スクリプトにpublic関数として書く • 今回はゲーム用のシーンを読み込む処理 2. ボタンの Event に設定 public void GameStart() { SceneManager.LoadScene("GameScene"); }