Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Unityt超入門解説編1 / Unity_introduction_about_getcom...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
shota-yano
October 05, 2020
Technology
150
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
79
Kumamoto HoloLens ミートアップ v7 / KumamotoHoloLensMeetupv7
shotayano
0
320
PowerAppsハンズオン準備 / 20220527_PowerApps_Preparation
shotayano
0
120
PowerAppsハンズオン / 20220527_PowerApps_Handson
shotayano
1
380
Power Automate Desktop ハンズオン / powerautomatedesktophandson
shotayano
0
190
PowerAutomateDesktopハンズオン準備 / PowerAutomateDesktopSetup
shotayano
0
150
HoloLens2ハンズオン(MRTKを触ってみる) / hololens2_and_mrtk_demo_handson
shotayano
1
390
HoloLens2開発環境構築 / dev-env-construction-for-hololens2
shotayano
0
250
Spatial Anchorsを活用した経路探索の検討
shotayano
0
1.2k
Other Decks in Technology
See All in Technology
秘密度ラベル初心者が第1歩でつまづかないための「設計・運用」ポイント
seafay
PRO
0
270
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
180
徹底討論!ECS vs EKS!
daitak
2
780
ロボティクスの技術 / Robotics Technology
ks91
PRO
0
110
ザ・データベース、MySQL ~ OSC 2026 Sendai ~
sakaik
0
140
SteampipeとExcel Power QueryでAWS構成定義書の作成を自動化する
jhashimoto
0
160
10年間のブログ発信を振り返って見えたWebアプリケーションエンジニアとしての軌跡
stefafafan
0
170
【Snowflake Summit 2026 Recap!!】Snowflake Summit Deep Dive: Security & Governance
civitaspo
1
270
AWS Security Agent といっしょに脅威モデリングをやってみよう
amarelo_n24
1
180
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
1.3k
スタートアップにAmazon EKSは早すぎる? マルチプロダクト戦略を加速する Platform Engineeringの実践 / Is Amazon EKS Too Soon for Startups? Practical Platform Engineering to Accelerate a Multi-Product Strategy
elmodev09
1
460
Kiroで書いた 設計書 が AI レビューの 採点基準 になる
ezaki
0
130
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
How to make the Groovebox
asonas
2
2.2k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
250
How to Talk to Developers About Accessibility
jct
2
240
The Invisible Side of Design
smashingmag
302
52k
Crafting Experiences
bethany
1
180
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
RailsConf 2023
tenderlove
30
1.5k
Become a Pro
speakerdeck
PRO
31
6k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
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