Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do you create game objects from script?

Discussion in 'Scripting' started by Boogz, Dec 13, 2014.

  1. Boogz

    Boogz

    Joined:
    Dec 9, 2014
    Posts:
    42
    I'm trying to learn the Unity engine by creating a game 100% from script. No GUI shortcuts.

    Question though: How do I execute a script without a gameobject already in the scene?? As in...how do I create that first gameobject?
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    UnityEditor.Callbacks.PostProcessScene
     
  3. Boogz

    Boogz

    Joined:
    Dec 9, 2014
    Posts:
    42
    And where do I type that in if none of my scripts will execute because I don't have an object in the scene?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Instantiate prefabs. Or use the GameObject constructor.

    --Eric