Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is It Possible To Give Unique Tags to Items In An Array Built From a Prefab?

Discussion in 'Scripting' started by joe_04_04, Sep 15, 2017.

  1. joe_04_04

    joe_04_04

    Joined:
    Sep 15, 2017
    Posts:
    14
    I have a prefab. That prefab is used to create an array of objects. I'm able to tag the prefab with my tag name, "Brick," but I'm unsure how to uniquely tag each of the elements in the array (that is built during run-time). I have a for loop that instantiates a new brick, through a reference to the prefab. Any help would be greatly appreciated.
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,514
    Tags are defined at design time. The list of available tags is static once you've built the game. There are no ways to create new tags at runtime (well technically you can at editor runtime, but not at true runtime... and such implementations will fail when you do the actual build of your game).
     
  3. joe_04_04

    joe_04_04

    Joined:
    Sep 15, 2017
    Posts:
    14
    Thanks.

    Would there be any way to identify those objects in the array? I have an array of objects with box colliders and I need to know which one is hit during a collision.
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,514
  5. joe_04_04

    joe_04_04

    Joined:
    Sep 15, 2017
    Posts:
    14
    You know, that makes perfect sense. I'm fairly new to game design, so trying to understand the calls and interaction between objects is a bit confusing, but that makes sense. My objects in the array are now being deactivated by using a script attached to them. Thanks