码迷,mamicode.com
首页 > 编程语言 > 详细

Unity--- 资源路径问题

时间:2018-11-09 10:50:48      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:资源管理   ret   path   win   return   pat   var   ace   data   

使用 System.IO.Path 这个API得到的路径,其实也是以"\"分隔路径的。
我们在windows下打开资源管理器,某个目录或文件的路径为:E:\uniuProject5.6.2\plan\配置表
使用Unity的API,打印Application.dataPath 时,打印出:E:/LgsTest/XDanceLearn/Art/Art/Assets,是以“/”为分隔符的

/// <summary>
    /// 格式化路径成Asset的标准格式
    /// </summary>
    /// <param name="filePath"></param>
    /// <returns></returns>
    public static string GetAssetPath(string filePath)
    {
        var newFilePath1 = filePath.Replace("\\", "/");
        var newFilePath2 = newFilePath1.Replace("//", "/").Trim();
        newFilePath2 = newFilePath2.Replace("///", "/").Trim();
        newFilePath2 = newFilePath2.Replace("\\\\", "/").Trim();
        return newFilePath2;
    }

 

Unity--- 资源路径问题

标签:资源管理   ret   path   win   return   pat   var   ace   data   

原文地址:https://www.cnblogs.com/luguoshuai/p/9933452.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!