Search Unity

Adding components to scene in 2d game programly

Discussion in 'Getting Started' started by riaron86, Nov 14, 2019.

  1. riaron86

    riaron86

    Joined:
    Nov 14, 2019
    Posts:
    6
    How to add components to scene programly
     
  2. riaron86

    riaron86

    Joined:
    Nov 14, 2019
    Posts:
    6
    Can you write example, for moreunderstandability
     
    Last edited: Nov 14, 2019
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,440
    Joe-Censored and JoeStrout like this.
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You don't add components to scenes. Components are attached to GameObjects, and GameObjects can be added to scenes. As already mentioned, you'd create a prefab with your component and Instantiate that prefab.