Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // variables to notify the reloading status via GetGraphicsReloadStatus
- private bool _isContentBeingReloaded;
- private int _currentReloadedAsset;
- /// returns true when the graphics are being reloaded. False otherwise.
- public bool GetGraphicsReloadStatus (out int currentAsset,out int totalAssets)
- {
- if (_isContentBeingReloaded)
- {
- currentAsset=_currentReloadedAsset;
- totalAssets=LoadedAssets.Count;
- return true;
- }
- else
- {
- currentAsset=0;
- totalAssets=0;
- return false;
- }
- }
- protected virtual void ReloadGraphicsAssets()
- {
- _currentReloadedAsset=0;
- _isContentBeingReloaded=true;
- foreach (var asset in LoadedAssets)
- {
- // This never executes as asset.Key is never null. This just forces the
- // linker to include the ReloadAsset function when AOT compiled.
- if (asset.Key == null)
- ReloadAsset(asset.Key, Convert.ChangeType(asset.Value, asset.Value.GetType()));
- #if WINDOWS_STOREAPP
- var methodInfo = typeof(ContentManager).GetType().GetTypeInfo().GetDeclaredMethod("ReloadAsset");
- #else
- var methodInfo = typeof(ContentManager).GetMethod("ReloadAsset", BindingFlags.NonPublic | BindingFlags.Instance);
- #endif
- var genericMethod = methodInfo.MakeGenericMethod(asset.Value.GetType());
- genericMethod.Invoke(this, new object[] { asset.Key, Convert.ChangeType(asset.Value, asset.Value.GetType()) });
- _currentReloadedAsset++;
- }
- _isContentBeingReloaded=false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement