Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Location
    Fryslân
    Posts
    95

    Load objects in game

    Hi,

    I've been working with Unity3D for a while now and still learning to script, mainly trying to figure out GUI for now.. But i was wondering if it would be possible for Unity to load a object when clicked on a button in game, so that the user can place the object somewhere in the scene

  2. #2
    Join Date
    Aug 2002
    Location
    Vancouver Island
    Posts
    59
    Yes!

    Simply create a new GameObject. You can then add components like in the editor.
    Code:
    using UnityEngine;
    using System.Collections;
    
    public class example : MonoBehaviour {
        public GameObject player;
        void Example() {
            player = new GameObject();
            player.AddComponent("Rigidbody");
            player.AddComponent("BoxCollider");
        }
    }
    This is from the unity3d site. http://unity3d.com/support/documenta...ameObject.html

  3. #3
    Join Date
    May 2006
    Location
    Fryslân
    Posts
    95
    oh nice! thank you, my bad that i didnt check out the unity site thourghly!
    Ill try to see if i get it to work

    EDIT: Got it working but changed it so that it loots a prefab from the Resources folder.
    Last edited by Redmer; 03-01-2012 at 03:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •