Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

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

Resources.LoadAssetAtPath

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function LoadAssetAtPath(assetPath: string, type: Type): Object;
public static Object LoadAssetAtPath(string assetPath, Type type);
public static def LoadAssetAtPath(assetPath as string, type as Type) as 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 & 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); }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public GameObject prefab;
    void Start() {
        prefab = Resources.LoadAssetAtPath("Assets/Artwork/mymodel.fbx", typeof(GameObject));
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public prefab as GameObject

	def Start() as void:
		prefab = Resources.LoadAssetAtPath('Assets/Artwork/mymodel.fbx', typeof(GameObject))

public static function LoadAssetAtPath(assetPath: string): T;
public static T LoadAssetAtPath(string assetPath);
public static def LoadAssetAtPath(assetPath as string) as 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 & 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"); }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public GameObject prefab;
    void Start() {
        prefab = Resources.LoadAssetAtPath<GameObject>("Assets/Artwork/mymodel.fbx");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public prefab as GameObject

	def Start() as void:
		prefab = Resources.LoadAssetAtPath[of GameObject]('Assets/Artwork/mymodel.fbx')