コード例 #1
0
ファイル: Recs.cs プロジェクト: midgithub/BaseToolsForUnity
 /// <summary>完整构造</summary>
 /// <param name="strPath"></param>
 /// <param name="RecsPathType"></param>
 /// <param name="RecsFromType"></param>
 /// <param name="isAsync"></param>
 public RecsLoadInfo(string strPath, RecsPathType RecsPathType, RecsFromType RecsFromType, bool isAsync)
 {
     this.strPath      = strPath;
     this.RecsPathType = RecsPathType;
     this.RecsFromType = RecsFromType;
     this.isAsync      = isAsync;
 }
コード例 #2
0
ファイル: Recs.cs プロジェクト: midgithub/BaseToolsForUnity
 /// <summary></summary>
 public RecsLoadInfoAssetBundle(string strPath, string strRecsPath, RecsPathType RecsPathType, bool isAsync) : this()
 {
     this.strPath      = strPath;
     this.RecsPathType = RecsPathType;
     this.strRecsPath  = strRecsPath;
     this.isAsync      = isAsync;
 }
コード例 #3
0
        /// <summary></summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strPath"></param>
        /// <param name="pathType"></param>
        /// <param name="OnError"></param>
        /// <param name="OnSuccess"></param>
        /// <returns></returns>
        public static T LoadRecs <T>(string strPath, RecsPathType pathType, Action <string> OnError, Action <Object> OnSuccess = null) where T : UnityEngine.Object
        {
            if (string.IsNullOrEmpty(strPath))
            {
                return(null);
            }

            switch (RecsAssetBundleMgr.GetRecsSources())
            {
            case RecsSource.FromRecsources:
                //准备路径Resources下
                if (pathType != RecsPathType.ResourcesPath)
                {
                    strPath = FileTool.RecsPathSwitch(strPath, pathType, RecsPathType.ResourcesPath);
                }

                //尝试加载
                T asset = null;
                try
                {
                    asset = Resources.Load <T>(strPath);
                }
                catch (Exception ex)
                {
                    if (OnError != null)
                    {
                        OnError(ex.Message);
                    }
                }

                if (asset != null)
                {
                    OnSuccess(asset);
                }
                return(asset);

            case RecsSource.FormAssetBundleServer:
                break;

            case RecsSource.FormAssetBundleLocal:
                GetIns().StartCoroutine(AssetBundleTool.ILoadAssetBundle(FileTool.RecsPathSwitch(strPath, pathType, RecsPathType.PhysicalFullPath), true, OnError,
                                                                         (AssetBundle a) =>
                {
                    if (OnSuccess != null)
                    {
                        OnSuccess.Invoke(a);
                    }
                }));
                break;

            default:
                break;
            }

            return(null);
        }
コード例 #4
0
        /// <summary>资源路径转换</summary>
        /// <param name="strPath">资源路径</param>
        /// <param name="from">资源路径类型</param>
        /// <param name="to">目标资源路径类型</param>
        /// <returns></returns>
        public static string RecsPathSwitch(string strPath, RecsPathType from, RecsPathType to)
        {
            if (string.IsNullOrEmpty(strPath))
            {
                return(null);
            }

            string strFullPath = RecsPathToPhySicalFullPath(strPath, from);

            return(PhySicalFullPathToRecsPath(strFullPath, to));
        }
コード例 #5
0
        /// <summary>将指定类型的路径转换为物理完整路径</summary>
        /// <param name="strPath">指定路径</param>
        /// <param name="to">指定路径类型</param>
        /// <returns></returns>
        public static string PhySicalFullPathToRecsPath(string strPath, RecsPathType to)
        {
            if (string.IsNullOrEmpty(strPath))
            {
                return(null);
            }

            switch (to)
            {
            case RecsPathType.None:
                break;

            case RecsPathType.PhysicalFullPath:
                return(strPath);

            case RecsPathType.AssetPath:
                return(PhysccalFullPathToAssetPath(strPath));

            case RecsPathType.AssetCutPath:
                return(FullPathToAssetCutPath(strPath));

            case RecsPathType.ResourcesPath:
                return(ToRecsourcesPath(strPath));


            case RecsPathType.StreamingPath:
                return(PhysccalFullPathToStreamingPath(strPath));

            case RecsPathType.NetUrl:
                break;

            case RecsPathType.PhysicalUrl:
                return(FullPhysicalPathToPhysicalUrl(strPath));

            case RecsPathType.Url:
                break;

            default:
                break;
            }

            return(strPath);
        }
コード例 #6
0
 /// <summary>更安全更和谐的判定文件是否存在》》》待深入开发</summary>
 /// <param name="strPath">待检查的路径</param>
 /// <param name="RecsPathType">资源路径类型</param>
 /// <returns></returns>
 public static bool FileExist(string strPath, RecsPathType RecsPathType = RecsPathType.PhysicalFullPath)
 {
     return(!(string.IsNullOrEmpty(strPath) || !File.Exists(strPath)));
 }
コード例 #7
0
ファイル: Recs.cs プロジェクト: midgithub/BaseToolsForUnity
 /// <summary></summary>
 public RecsLoadInfoResources(string strPath, RecsPathType RecsPathType, bool isAsync) : this()
 {
     this.strPath      = strPath;
     this.RecsPathType = RecsPathType;
     this.isAsync      = isAsync;
 }