B1 中級 1468 タグ追加 保存
Tags are a way of identifying game objects in Unity.
As a name of a single object could identify it,
it can be useful to set tags also.
For example you may have an object called Ork or Tank
but these could all be tagged Enemy,
and in your code you could check for any objects
that have the tag Enemy.
Likewise a script on an enemy could check for a player character
by looking for a player tag.
To assign a tag to an object, select it and use the
drop-down menu at the top of the inspector.
If the tag you want isn't already present then add a new tag.
You can add a tag by clicking the option at the bottom of the menu
and then entering it in the list of tags at the top
of the tag manager.
Once you've done this, return to the object you
wish to place the tag on
and select it from the drop-down.
There are a number of functions in code,
which will allow you to find objects with tags,
the simplest one of these is GameObject.FindWithTag,
which allows you to specify a string with the name
of the tag inside it.
This script is attached to my enemy object
and I can use that to find an object with the tag Player.
So I'll set my robot to be tagged Player
and when the game starts my enemy is seeking out that
object and looking at it.
Likewise you could find multiple objects with the same tag
by using FindGameObjectWithTag.
See the scripting reference for more examples of this.


タグ-Unity公式チュートリアル (Tags - Unity Official Tutorials)

1468 タグ追加 保存
朱瑛 2014 年 5 月 2 日 に公開
  1. 1. クリック一つで単語を検索


  2. 2. リピート機能


  3. 3. ショートカット


  4. 4. 字幕の表示/非表示


  5. 5. 動画をブログ等でシェア


  6. 6. 全画面再生


  1. クイズ付き動画


  1. クリックしてメモを表示

  1. UrbanDictionary 俚語字典整合查詢。一般字典查詢不到你滿意的解譯,不妨使用「俚語字典」,或許會讓你有滿意的答案喔