概要
using System.Text.RegularExpressions;
namespace Kogane
{
public static class ResourcesPath
{
private static readonly Regex REGEX = new( @"^.*Resources/(.*)\..*" );
public static string ToResourcesPath( string assetPath )
{
return REGEX.Replace( assetPath, "$1" );
}
}
}
使用例
using Kogane;
using UnityEngine;
public class Example : MonoBehaviour
{
private void Start()
{
Debug.Log( ResourcesPath.ToResourcesPath( "Assets/@Project/Resources/Materials/New Material.mat" ) );
Debug.Log( ResourcesPath.ToResourcesPath( "Resources/New Material.mat" ) );
Debug.Log( ResourcesPath.ToResourcesPath( "Assets/Plugins/Demigiant/DOTween/Resources/DOTweenSettings.asset" ) );
Debug.Log( ResourcesPath.ToResourcesPath( "Assets/Plugins/Demigiant/DOTween/Editor/DOTweenEditor.dll" ) );
}
}