Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Unityt超入門解説編1 / Unity_introduction_about_getcom...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
shota-yano
October 05, 2020
Technology
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unityt超入門解説編1 / Unity_introduction_about_getcomponent
社内勉強会向け資料
this.GetComponentについて
shota-yano
October 05, 2020
More Decks by shota-yano
See All by shota-yano
M5Stackハンズオン概要
shotayano
0
97
Kumamoto HoloLens ミートアップ v7 / KumamotoHoloLensMeetupv7
shotayano
0
330
PowerAppsハンズオン準備 / 20220527_PowerApps_Preparation
shotayano
0
130
PowerAppsハンズオン / 20220527_PowerApps_Handson
shotayano
1
410
Power Automate Desktop ハンズオン / powerautomatedesktophandson
shotayano
0
220
PowerAutomateDesktopハンズオン準備 / PowerAutomateDesktopSetup
shotayano
0
170
HoloLens2ハンズオン(MRTKを触ってみる) / hololens2_and_mrtk_demo_handson
shotayano
1
410
HoloLens2開発環境構築 / dev-env-construction-for-hololens2
shotayano
0
260
Spatial Anchorsを活用した経路探索の検討
shotayano
0
1.2k
Other Decks in Technology
See All in Technology
視野はAIに、視座は人に / ai-for-breadth-humans-for-perspective
nkzn
6
3.1k
自律的なチームを作るためにTechPMがやらないこと
ny7760
1
510
AIエージェント時代、Kaggleにどう取り組むか
takanao
2
500
AI時代に求められる優秀なTechLeadの振る舞い
pospome
10
13k
20261031_IoTLT_vol140_kitazaki_v1.pdf
kitazaki
0
170
"AWSはちょっと苦手"でも大丈夫。AWS Blocks で手軽に作る Flutter のバックエンド #FlutterKaigi
tacck
PRO
0
150
新米を「売り越さない」、Aurora DSQLで作る在庫ゼロ死守の限定ドロップEC
yama3133
0
180
リアクションエンジニア ― 小さなリアクションから、話しかけやすい組織をつくる ―
ryuguyana
1
130
新卒エンジニア、 介護士になる
ryu1013
1
690
デザインレビューは自動化できるのか?─ Flutter × Figma で UI 品質保証を考える
techiro
2
790
レガシーコードに対する loop engineering的なAI開発プロセス導入について
kubell_hr
0
240
増え続けるプロダクトの品質をどう担保するか。ProductSpecとTypeScriptによる取り組み
joere
3
390
Featured
See All Featured
Faster Mobile Websites
deanohume
310
32k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
280
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Building Applications with DynamoDB
mza
96
7.3k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
300
How GitHub (no longer) Works
holman
316
150k
Deep Space Network (abreviated)
tonyrice
0
410
Paper Plane
katiecoart
PRO
5
55k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Building the Perfect Custom Keyboard
takai
2
950
KATA
mclloyd
PRO
35
16k
Transcript
2020/10/05 Unity超入門 解説編1
解説 • GetComponentの解説 • ふわっとした解説ですが…
• Hierarchyウィンドウにある1つ1つがオブジェクト • それぞれが別オブジェクトとして独立 • Cubeが2つあるがこれは形状は同じだが別々のオブジェクト • カメラやライトも1つのオブジェクトとして存在 • 実行ボタンを押した瞬間、各オブジェクトがゲーム内でCreate
オブジェクト オブジェクト オブジェクト オブジェクト オブジェクト オブジェクトの解説
• Sphereオブジェクトの構成要素(コンポーネント) ※どんな機能を持っているか • Transform • Mesh Filter • Mesh
Renderer • Sphere Collider コンポーネントの解説
• Sphereオブジェクトの構成要素(コンポーネント) • Transformコンポーネントの設定項目 • Position:位置を決める • X:水平位置 • Rotation:回転を決める
• Scale:大きさを決める • 他のコンポーネントによってどんな設定ができるのかが決まっている • わからないときは「?」を見ること(もしくは公式ドキュメント) わからないとき コンポーネントの解説
• Textオブジェクトを追加 • わかりやすいよう「DisplayText1」に名前を変更 • Textオブジェクト「 DisplayText1 」のコンポーネント • Rect
Transform • CanvasRenderer • Text コンポーネントの解説
• Textオブジェクト「 DisplayText1 」のコンポーネントについて • Textコンポーネントの設定項目 • Text:表示する文字列を設定する • Character:フォントやフォントサイズなどを設定する
• Paragraph:左寄せなどを設定する • Color:色を設定する • Etc… などが設定可能 コンポーネントの解説
• Textオブジェクトの「DisplayText1」にスクリプトを追加 • DisplayText1のコンポーネントに「StartText(Script)」が追加される • スクリプト名:StartText • 同時にAssetsフォルダに追加される • ここでコンポーネントの中身を管理する
スクリプトの解説
• DisplayText1の「StartText(Script)」コンポーネントについて • DisplayText1オブジェクトのTextコンポーネントのTextの値を変更 • New Text ⇒ GAME START
• デフォルトで2つの関数が作成される • Start関数:オブジェクトがCreateされたときに1回だけ実行 • Update関数:オブジェクトの更新処理(1フレームごと) • ※60FPSなら1秒間に60回実行 スクリプトの解説
• this : このコンポーネントを実行しているオブジェクト • DisplayText1オブジェクト • this.GetComponent<Text>() • DisplayText1オブジェクトに設定されたTextコンポーネントを取得する
• <>はコンポーネント名を指定する • ()はコンポーネントの型。今回はないので指定しない。 • .text : TextコンポーネントのTextという要素を指定 this.GetComponent<Text>().Textの解説
DisplayText1オブジェクト • this : このコンポーネントを実行しているオブジェクト • DisplayText1オブジェクト • this.GetComponent<Text>() •
DisplayText1オブジェクトに設定されたTextコンポーネントを取得する • <>はコンポーネント名を指定する • ()はコンポーネントの型。今回はないので指定しない。 • .text : TextコンポーネントのTextという要素(変数)を指定 this.GetComponent<Text>().Textの解説 Rect Transformコンポーネント PosX:100 PosY:200 PosZ:0 CanvasRenderer コンポーネント Textコンポーネント Text:New Text Width:500 Height:200 Color:383838 StartText コンポーネント
DisplayText2オブジェクト • DisplayText1とDisplayText2は別オブジェクト • DisplayText2オブジェクトにはStartTextコンポーネントはない • 実行後はDisplayText1オブジェクトのみ変化がある DisplayText2を作成 Rect Transformコンポーネント
PosX:100 PosY:100 PosZ:0 Textコンポーネント Text:New Text2 Width:500 Height:200 Color:383838 CanvasRenderer コンポーネント DisplayText1オブジェクト Rect Transformコンポーネント PosX:100 PosY:200 PosZ:0 StartText コンポーネント Textコンポーネント Text:New Text Width:500 Height:200 Color:383838 CanvasRenderer コンポーネント
• https://docs.unity3d.com/ja/current/ScriptReference/GameObject.GetComponent.html リファレンス
END