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;
static Object LoadAssetAtPath(string assetPath, Type type);
static def LoadAssetAtPath(assetPath as string, type as Type) as 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); }

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))

static function LoadAssetAtPath(assetPath: string): T;
static T LoadAssetAtPath(string assetPath);
static def LoadAssetAtPath(assetPath as string) as 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"); }

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')