public static void SetupWatcher() { try { SubscriptionManager.Register(); HotloadManager.Register(); CustomDeserializer.Hook(); Loader = new HotLoader(); //UIView.library.ShowModal<MessageBoxPanel>( "MessageBoxPanel" ); // Even though both events fire when an install / download is made, // it wont be loaded twice since eventWorkshopSubscriptionChanged // fires first and that HotLoad gracefully fails because the package files // haven't been downloaded by then PlatformService.workshop.eventWorkshopItemInstalled += ( PublishedFileId packageId ) => { Profiler.Trace("eventWorkshopItemInstalled {0}", packageId); HotloadItem(packageId); }; // need for deferred loading PlatformService.workshop.eventWorkshopSubscriptionChanged += (PublishedFileId packageId, bool subscribed) => { Profiler.Trace("eventWorkshopSubscriptionChanged {0} {1}", packageId, subscribed); if (subscribed) { HotloadItem(packageId); } }; } catch (Exception ex) { Profiler.Error("SetupWatcher", ex); } }
public static void HotloadItem(PublishedFileId packageId, bool reloaded = false) { Profiler.Info("New Workshop-Item installed: {0} (reloaded: {1})", packageId, reloaded); try { if (Settings.instance.installSubscriptions) { if (Loader.HotloadPackage(packageId)) { Profiler.Info("Hotloaded package {0}", packageId); Loader.PostInstall(); HotloadManager.ReportProcessed(packageId); } else { Profiler.Trace("Hotload failed with {0} dependencies", AssetLoader.instance.notFoundIndirect.Count); // in case of zero dependencies the loading really failed if (AssetLoader.instance.notFoundIndirect.Count == 0) { Profiler.Trace("no deps"); // so we need to get if out of the dependency lists HotloadManager.ReportProcessed(packageId); } } } else { Profiler.Info("Skipped package {0} due to settings", packageId); } } catch (Exception ex) { Profiler.Error("HotloadItem", ex); } }
public static void Register() { instance = new HotloadManager(); SimulationManager.RegisterSimulationManager(instance); }
public bool LoadAsset(string fullName, Package.Asset asset, bool mainAsset = false) { if (asset == null) { return(StoreNotFoundName(fullName)); } Profiler.Info("Loading asset {0}", asset.fullName); try { Profiler.Trace("Clearing stack"); stack.Clear(); if (mainAsset) { Profiler.Info("Pushing {0} on stack", fullName); stack.Push(fullName); } Profiler.Info("Stack count {0}, current {1}", stack.Count, Current); CustomAssetMetaData assetMetaData = InstantiateAssetMetaData(asset); // Always remember: assetRef may point to another package because the deserialization method accepts any asset with a matching checksum. // There is a bug in the 1.6.0 game update in this. fullName = asset.package.packageName + "." + assetMetaData.assetRef.name; //impl GameObject assetGameObject = InstantiateAssetGameObject(assetMetaData); assetGameObject.name = fullName; PrefabInfo assetPrefabInfo = InstantiateAssetPrefab(assetGameObject); if (mainAsset && Settings.instance.installDependencies && notFoundIndirect.Count > 0) { return(HotloadManager.DeferLoad(fullName, notFoundIndirect.Keys.ToList())); } RegisterPrefab(fullName, asset, assetMetaData, assetPrefabInfo, assetGameObject); //impl if (mainAsset) { Profiler.Trace("Popping {0} from stack", stack.Peek()); stack.Pop(); } Profiler.Info("Stack count {0}", stack.Count); return(StorePrefabInfo(assetPrefabInfo)); } catch (Exception e) { if (mainAsset) { Profiler.Trace("Popping {0} from stack due to error {1}", stack.Peek(), e.Message); stack.Pop(); } Profiler.Error("Cannot load " + fullName, e); StoreFailedAssetName(fullName ?? asset.fullName, e); return(false); } }