AssetDatabase.GetAssetPath 获取资源路径


static function GetAssetPath (assetObject : Object) : string
static function GetAssetPath (instanceID : int) : string

Description描述

Returns the path name relative to the project folder where the asset is stored

返回相对于工程资源位置的路径名。

All paths are relative to the project folder. Like: "Assets/MyTextures/hello.png"

所有的路径都是相对于工程目录文件。 例如” Assets/MyTextures/hello.png”

@MenuItem("GameObject/Create Material")static function CreateMaterial () {// Create a simple material asset//新建一个简单的材质资源var material = new Material (Shader.Find("Specular"));AssetDatabase.CreateAsset(material, "Assets/MyMaterial.mat");// Print the path of the created asset//打印新建资源的路径Debug.Log(AssetDatabase.GetAssetPath(material));}


,