Version: 2021.1
언어: 한국어

AssetDatabase.IsMainAssetAtPathLoaded

매뉴얼로 전환
public static bool IsMainAssetAtPathLoaded (string assetPath);

파라미터

assetPath Filesystem path of the asset to load.

설명

Returns true if the main asset object at assetPath is loaded in memory.

All paths are relative to the Project folder, for example: "Assets/MyTextures/hello.png".

See Also: AssetDatabase.LoadMainAssetAtPath, Resources.UnloadAsset.

using UnityEditor;
using UnityEngine;

public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Is Main Asset At Path Loaded")] static void IsMainAssetAtPathLoadedExample() { //Create a material and unload it var materialPath = "Assets/Materials/NewMat0.mat"; var material = new Material(Shader.Find("Standard")); AssetDatabase.CreateAsset(material, materialPath); Resources.UnloadAsset(material);

//This will be false Debug.Log(AssetDatabase.IsMainAssetAtPathLoaded(materialPath)); //Load material into memory AssetDatabase.LoadAssetAtPath(materialPath, typeof(Object)); //This will be true Debug.Log(AssetDatabase.IsMainAssetAtPathLoaded(materialPath)); } }