Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

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

Removed in version 5.1.0p1
Use AssetDatabase.LoadAssetAtPath instead (UnityUpgradable)

Resources.LoadAssetAtPath

Switch to Manual
public static function LoadAssetAtPath(assetPath: string, type: Type): Object;

Parameters

assetPath Pathname of the target asset.
type Type 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 and paths in Unity use forward slashes, paths using backslashes will not work.
This returns only asset object that is visible in the Project view.

	var prefab : GameObject;

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

public static function LoadAssetAtPath(assetPath: string): T;

Parameters

assetPath Pathname 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 and paths in Unity use forward slashes, paths using backslashes will not work.
This returns only asset object that is visible in the Project view.

	var prefab : GameObject;

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