42 lines
850 B
C#
42 lines
850 B
C#
using System;
|
|
using UnityEditor;
|
|
|
|
namespace NegUtils.Editor
|
|
{
|
|
public class EditorUtils
|
|
{
|
|
}
|
|
|
|
public class AssetPath
|
|
{
|
|
private readonly string filter;
|
|
|
|
private string path;
|
|
|
|
|
|
public AssetPath(string filter)
|
|
{
|
|
this.filter = filter;
|
|
TryFindPath();
|
|
}
|
|
|
|
public string Path
|
|
{
|
|
get
|
|
{
|
|
if (path != null)
|
|
return path;
|
|
TryFindPath();
|
|
return path;
|
|
}
|
|
}
|
|
|
|
private void TryFindPath()
|
|
{
|
|
string[] candidates = AssetDatabase.FindAssets(filter);
|
|
if (candidates.Length == 0)
|
|
throw new Exception("Missing layout asset!");
|
|
path = AssetDatabase.GUIDToAssetPath(candidates[0]);
|
|
}
|
|
}
|
|
} |