I can't see runtime GameObject

Well, never mind if I pass for an idiot but this is a moment I’m looking for a reply -__-.

I try to create an object on the fly and display it in the viewer.
I have this piece of code, and when I run the apply, I have my Maison1 in addition to the camera and the light already present in the scene (in Hierarchy) …don’t understand what is wrong :frowning:

void createHouse () 
{
	GameObject Maison1 = new GameObject ("Maison1");
	if(Maison1)
	{	
		Debug.Log("set position");
		//Maison1.transform.position = new Vector3(0,0,0);
	}
}

Whatever I do I can not see my house in the viewer

That just creates an empty object that has the name Maison1. Are you meaning to Instantiate a prefab? That would be something like this:

public GameObject dragHouseHere;

void createHouse () 
{
    GameObject Maison1 = Instantiate(dragHouseHere);
    if(Maison1)
    {   
        Debug.Log("set position");
        //Maison1.transform.position = new Vector3(0,0,0);
    }
}

Then drag your house to the variable in the Inspector window.

If you really want to load it by name, it has to be a Resource, then you can:

GameObject Maison1 = Instantiate(Resources.Load("Maison1"));

Note that resources are loaded for every level in a WebPlayer, so I wouldn’t advise using them in that case.

Ok, I understand that the object that I created is an empty object nome “House” but I get to create an object by getting it directly from my library without having to put it in a public variable or having to make a prefab.
I drag & drop a file in my library max and I use it as is, is this possible?

No idea, without using public var?

At least in C#, if you do like this:

GameObject go = new GameObject();
go.name = "myNewGameObject";

It will create a new empty gameObject named “myNewGameObject” in the scene.

But this way, you will create a gameObject only with a Transform component.

If you want to Instantiate (place an existent object) use the code that Warwick Allison writed.