Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Resources.LoadAssetAtPath

static function LoadAssetAtPath(assetPath: string, type: Type): Object;

Parameters

assetPathPathname of the target asset.
typeType filter for objects returned.

Description

Returns a resource at an asset path (Editor Only).

This function always return null in the standalone player or web player. This is useful for quickly accessing an asset for use in the editor only.

Note:
All asset names & paths in Unity use forward slashes, paths using backslashes will not work.

	var prefab : GameObject;

function Start () { prefab = Resources.LoadAssetAtPath("Assets/Artwork/mymodel.fbx", GameObject); }

static function LoadAssetAtPath(assetPath: string): T;

Parameters

assetPathPathname of the target asset.

Description

Returns a resource at an asset path (Editor Only).

This function always return null in the standalone player or web player. This is useful for quickly accessing an asset for use in the editor only.

Note:
All asset names & paths in Unity use forward slashes, paths using backslashes will not work.

	var prefab : GameObject;

function Start () { prefab = Resources.LoadAssetAtPath.<GameObject>("Assets/Artwork/mymodel.fbx"); }