#region Copyright RenGuiYou. All rights reserved. //===================================================== // NeatlyFrameWork // Author: RenGuiyou // Feedback: mailto:750539605@qq.com //===================================================== #endregion using System; using UnityEngine; using Object = UnityEngine.Object; namespace Neatly.Load { public class AssetFileLoader : Loader { Object m_data; protected override void Init(string path, Action callback, bool sync = true) { var pathAtlasTp = NeatlyConfig.PATH_ATLAS_TP; IsAtlas = path.IndexOf(pathAtlasTp, StringComparison.Ordinal) != -1; if (IsAtlas) { AtlasName = path.Replace(pathAtlasTp, string.Empty).SubstringTo("."); } base.Init(path, callback, sync); } public override void Load() { #if UNITY_EDITOR base.Load(); string m_Name = string.Format("{0}/{1}", NeatlyConfig.ASSETS_ROOT, Path); if (m_Sync) { m_data = UnityEditor.AssetDatabase.LoadAssetAtPath(m_Name); if (IsAtlas) { var gameObject = m_data as GameObject; AtlasInfo = gameObject.GetComponent(); AtlasInfo.Init(); } OnLoadCompleted(m_data); } else { //暂时不做异步模拟... m_data = UnityEditor.AssetDatabase.LoadAssetAtPath(m_Name); OnLoadCompleted(m_data); } #endif } } }