public void Init(string resRootDir) { ResRootDir = resRootDir; if (!ResRootDir.EndsWith("/")) { ResRootDir += "/"; } #if UNITY_EDITOR StreamingAssetsPath = Application.dataPath + "/../AssetBundles/" + RunPlatform + "/"; //editor下的streaming就是打包的目录,稍微改了下(并不是工程目录下Streaming下的目录 ResourceLoadPath = Application.persistentDataPath + "/AssetBundles/" + RunPlatform + "/"; FILE_SYMBOL = @"file://"; OUTER_FILE_SYMBOL = @"file:///"; #elif (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) StreamingAssetsPath = Application.dataPath + "/StreamingAssets/AssetBundles/" + RunPlatform + "/"; ResourceLoadPath = Application.persistentDataPath + "/AssetBundles/" + RunPlatform + "/"; FILE_SYMBOL = @"file://"; OUTER_FILE_SYMBOL = @"file:///"; #elif UNITY_IOS StreamingAssetsPath = Application.dataPath + "/Raw/AssetBundles/" + RunPlatform + "/"; ResourceLoadPath = Application.persistentDataPath + "/AssetBundles/" + RunPlatform + "/"; FILE_SYMBOL = "file://"; OUTER_FILE_SYMBOL = "file://"; #elif UNITY_ANDROID StreamingAssetsPath = Application.dataPath + "!/assets/AssetBundles/" + RunPlatform + "/"; ResourceLoadPath = Application.persistentDataPath + "/AssetBundles/" + RunPlatform + "/"; FILE_SYMBOL = "jar:file://"; OUTER_FILE_SYMBOL = "file://"; #endif _resourceContainer = gameObject.AddComponentOnce <ResourceContainer>(); _assetBundleMgr = gameObject.AddComponentOnce <AssetBundleFile>(); }
public void Init(bool resourceLoadMode, string resRootDir) { _succCallbacks = new Dictionary <Resource, List <ResourceHandler> >(); _failCallbacks = new Dictionary <Resource, List <ResourceHandler> >(); _mapRes = new Dictionary <string, Resource>(); _resLoader = ResourceLoader.GetResLoader(this.gameObject); _resLoader.OnDone += OnResourceDone; ResourcesLoadMode = resourceLoadMode; ResourceFileUtil resUtil = gameObject.AddComponentOnce <ResourceFileUtil>(); _resRootDir = resRootDir; resUtil.Init(resRootDir); _assetBundleFile = gameObject.AddComponentOnce <AssetBundleFile>(); }
public void Init(bool directLoadMode, string resRootDir) { _resRootDir = resRootDir; Resource.BundlePreRootDir = _resRootDir.EndsWith("/") ? _resRootDir.ToLower() : (_resRootDir + "/").ToLower(); //根据传入的目录判断是直接用Resources.Load还是外部加载 _dirInResources = _resRootDir == "Assets/Resources"; _succCallbacks = new Dictionary <Resource, List <ResourceHandlerStruct> >(); _failCallbacks = new Dictionary <Resource, List <ResourceHandlerStruct> >(); _mapRes = new Dictionary <string, Resource>(); _resLoader = ResourceLoader.GetResLoader(this.gameObject); _resLoader.OnDone += OnResourceDone; DirectLoadMode = directLoadMode; ResourceFileUtil resUtil = gameObject.AddComponentOnce <ResourceFileUtil>(); resUtil.Init(resRootDir); _assetBundleFile = gameObject.AddComponentOnce <AssetBundleFile>(); }