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
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
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?
What "library"? If you mean your project, you can only reference things there by name if they are a Resource (I.e. n a folder named Resources. I'll update my answer for that case.
Note that this name-based asset look-up is really a poor approach, I merely gave the literal answer regardless of the sense of doing such look-ups. Unless you have an actual good reason to use that Resource approach, I would strongly recommend the more direct dependency declarative approach of using an explicit variable rather than some untraceable string and Resources.
It's safer from a code management standpoint, better in performance, better for WebPlayer scene size minimisation, and allows tracing the dependency with a single click.
What "library"? If you mean your project, you can only reference things there by name if they are a Resource (I.e. n a folder named Resources. I'll update my answer for that case.
– Waz