Resources.LoadAssetAtPath 加载所在路径的资源

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


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 are with forward slashes, if you use backward slashes for paths you will get errors.


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public GameObject prefab;
	void Start() {
		prefab = Resources.LoadAssetAtPath("Assets/Artwork/mymodel.fbx", typeof(GameObject));
var prefab : GameObject;

function Start () {
	prefab = Resources.LoadAssetAtPath("Assets/Artwork/mymodel.fbx", GameObject);
Page last updated: 2011-3-13