Create Transform from prefab file in a project

How can load a prefab for example from “Assets\Tower Defense Pack\Prefabs\Turret\Turret.prefab”
into a:

public Transform building;

using C# script, but not a drug and drop method through the inspector? thx)

You need to put your files in a folder called “Resources” and use:

public Transform building;
void Start(){
    building = Resources.Load("File") as Transform;
}

Don’t include the file extension.

If you want to load a resouce dynamicly you must place it in your ‘resources’ directory and load it via ‘Resource.Load()’, please refer to the documentation about resources.

Example:

var instance : GameObject = Instantiate(Resources.Load("enemy"));

If you have your gameObject in any way (instantiated, drag and drop via inspector) you can access the transform of the gameObject with the ‘transform’ property.

Example:

public GameObject myGameObject; // drag'dropped via inspector or load it via resources
public Transform building;
building = myGameObject.transform;

thanks a lot, already done so:))

Thanks a lot, already done so:))