public AssetBundleAnalyzerController(AssetBundleCollection assetBundleCollection) { m_AssetBundleCollection = (assetBundleCollection != null ? assetBundleCollection : new AssetBundleCollection()); m_AssetBundleCollection.OnLoadingAssetBundle += delegate(int index, int count) { OnLoadingAssetBundle?.Invoke(index, count); }; m_AssetBundleCollection.OnLoadingAsset += delegate(int index, int count) { OnLoadingAsset?.Invoke(index, count); }; m_AssetBundleCollection.OnLoadCompleted += delegate() { OnLoadCompleted?.Invoke(); }; m_DependencyDatas = new Dictionary <string, DependencyData>(); m_ScatteredAssets = new Dictionary <string, List <Asset> >(); m_AnalyzedStamps = new HashSet <Stamp>(); }
private bool LoadConfig() { Debug.Log("Loading configurations"); string configString = File.Exists(configPath) ? File.ReadAllText(configPath) : "[]"; try { m_ConfigContainer = JsonConvert.DeserializeObject <List <AppConfig> >(configString); Debug.Log("Loaded. Now populating App container and initializing apps."); foreach (AppConfig appConfig in m_ConfigContainer) { SetupApp(appConfig); } AppConfig.OnConfiguationChanged += SaveConfig; SaveConfig(this, null); OnLoadCompleted?.Invoke(this, null); } catch (Exception e) { Debug.Error("Couldn't load Neustart config: " + e.Message); if (MessageBox.Show(null, "Configuration file is corrupt. Would you like to reset it?", "Neustart", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { File.Move(configPath, configPath + ".bak"); Debug.Warning("Configuration file has been deleted. Trying again.."); return(LoadConfig()); } else { Debug.Error("Cannot proceed."); MessageBox.Show(null, "Please inspect " + configPath + " for JSON errors and correct them. Neustart will now close.", "Neustart"); Core.ForceQuit(); return(false); } } return(true); }
/// <summary> /// Loads the contents of this Memento into the provided object. /// </summary> /// <param name="ism">The object to receive the contents of the memento.</param> public void Load(ISupportsMementos ism) { Substance substance = (Substance)ism; substance.m_mass = m_mass; substance.Temperature = m_temperature; substance.m_type = m_materialType; if (m_matlSpecs != null) { substance.SetMaterialSpecs(m_matlSpecs); } else { substance.ClearMaterialSpecs(); } OnLoadCompleted?.Invoke(this); }
public AssetBundleEditorController() { m_AssetBundleCollection = new AssetBundleCollection(); m_AssetBundleCollection.OnLoadingAssetBundle += delegate(int index, int count) { OnLoadingAssetBundle?.Invoke(index, count); }; m_AssetBundleCollection.OnLoadingAsset += delegate(int index, int count) { OnLoadingAsset?.Invoke(index, count); }; m_AssetBundleCollection.OnLoadCompleted += delegate() { OnLoadCompleted?.Invoke(); }; m_SourceAssetSearchPaths = new List <string>(); m_SourceAssetSearchRelativePaths = new List <string>(); m_SourceAssets = new Dictionary <string, SourceAsset>(); m_SourceAssetRoot = null; m_SourceAssetRootPath = null; m_SourceAssetUnionTypeFilter = null; m_SourceAssetUnionLabelFilter = null; m_SourceAssetExceptTypeFilter = null; m_SourceAssetExceptLabelFilter = null; m_AssetSorter = AssetSorterType.Path; SourceAssetRootPath = DefaultSourceAssetRootPath; }
// GameClientComponent will wire this up to the IClientInterface.OnPlayerStateSaveReceived event. // We assume that Load will have been called already by the time this is fired. private void StateLoaded(PlayerSaveStatePacket packet) { string state = packet.state.state.state; // We need to capture the lastLoadSaveName before we null it out // so that the closures below work string saveName = lastLoadSaveName; try { JObject saveData = JObject.Parse(state); OnLoadCompleted?.Invoke(this, new GameStateStoreLoadResult(saveName, true, saveData)); } catch (Exception) { OnLoadCompleted?.Invoke(this, new GameStateStoreLoadResult(saveName, false, null)); } finally { lastLoadSaveName = null; } }
IEnumerator AsynchronousLoad(string scene) { isLoading = true; prevScene = SceneManager.GetActiveScene().name; OnBeginLoad?.Invoke(); yield return(null); AsyncOperation ao = SceneManager.LoadSceneAsync(scene); ao.allowSceneActivation = false; while (!ao.isDone) { //float progress = Mathf.Clamp01(ao.progress / 0.9f); //OnProgress?.Invoke(progress); int i = 0; while (i <= 10) { float progress = Mathf.Clamp01(i / 10f); OnProgress?.Invoke(progress); yield return(new WaitForSeconds(0.3f)); i++; } // Loading completed; if (ao.progress == 0.9f) { ao.allowSceneActivation = true; isLoading = false; OnLoadCompleted?.Invoke(); } yield return(null); } }
public bool Load() { Clear(); string configurationName = Utility.Path.GetCombinePath(Application.dataPath, ConfigurationName); if (!File.Exists(configurationName)) { return(false); } try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(configurationName); XmlNode xmlRoot = xmlDocument.SelectSingleNode("UnityGameFramework"); XmlNode xmlCollection = xmlRoot.SelectSingleNode("AssetBundleCollection"); XmlNode xmlAssetBundles = xmlCollection.SelectSingleNode("AssetBundles"); XmlNode xmlAssets = xmlCollection.SelectSingleNode("Assets"); XmlNodeList xmlNodeList = null; XmlNode xmlNode = null; int count = 0; xmlNodeList = xmlAssetBundles.ChildNodes; count = xmlNodeList.Count; for (int i = 0; i < count; i++) { OnLoadingAssetBundle?.Invoke(i, count); xmlNode = xmlNodeList.Item(i); if (xmlNode.Name != "AssetBundle") { continue; } string assetBundleName = xmlNode.Attributes.GetNamedItem("Name").Value; string assetBundleVariant = xmlNode.Attributes.GetNamedItem("Variant") != null?xmlNode.Attributes.GetNamedItem("Variant").Value : null; int assetBundleLoadType = 0; if (xmlNode.Attributes.GetNamedItem("LoadType") != null) { int.TryParse(xmlNode.Attributes.GetNamedItem("LoadType").Value, out assetBundleLoadType); } bool assetBundlePacked = false; if (xmlNode.Attributes.GetNamedItem("Packed") != null) { bool.TryParse(xmlNode.Attributes.GetNamedItem("Packed").Value, out assetBundlePacked); } if (!AddAssetBundle(assetBundleName, assetBundleVariant, (AssetBundleLoadType)assetBundleLoadType, assetBundlePacked)) { string assetBundleFullName = assetBundleVariant != null?string.Format("{0}.{1}", assetBundleName, assetBundleVariant) : assetBundleName; Debug.LogWarning(string.Format("Can not add AssetBundle '{0}'.", assetBundleFullName)); continue; } } xmlNodeList = xmlAssets.ChildNodes; count = xmlNodeList.Count; for (int i = 0; i < count; i++) { OnLoadingAsset?.Invoke(i, count); xmlNode = xmlNodeList.Item(i); if (xmlNode.Name != "Asset") { continue; } string assetGuid = xmlNode.Attributes.GetNamedItem("Guid").Value; string assetBundleName = xmlNode.Attributes.GetNamedItem("AssetBundleName").Value; string assetBundleVariant = xmlNode.Attributes.GetNamedItem("AssetBundleVariant") != null?xmlNode.Attributes.GetNamedItem("AssetBundleVariant").Value : null; if (!AssignAsset(assetGuid, assetBundleName, assetBundleVariant)) { string assetBundleFullName = assetBundleVariant != null?string.Format("{0}.{1}", assetBundleName, assetBundleVariant) : assetBundleName; Debug.LogWarning(string.Format("Can not assign asset '{0}' to AssetBundle '{1}'.", assetGuid, assetBundleFullName)); continue; } } OnLoadCompleted?.Invoke(); return(true); } catch { File.Delete(configurationName); OnLoadCompleted?.Invoke(); return(false); } }
public bool Load() { Clear(); if (!File.Exists(m_ConfigurationPath)) { return(false); } try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(m_ConfigurationPath); XmlNode xmlRoot = xmlDocument.SelectSingleNode("UnityGameFramework"); XmlNode xmlCollection = xmlRoot.SelectSingleNode("ResourceCollection"); XmlNode xmlResources = xmlCollection.SelectSingleNode("Resources"); XmlNode xmlAssets = xmlCollection.SelectSingleNode("Assets"); XmlNodeList xmlNodeList = null; XmlNode xmlNode = null; int count = 0; xmlNodeList = xmlResources.ChildNodes; count = xmlNodeList.Count; for (int i = 0; i < count; i++) { OnLoadingResource?.Invoke(i, count); xmlNode = xmlNodeList.Item(i); if (xmlNode.Name != "Resource") { continue; } string name = xmlNode.Attributes.GetNamedItem("Name").Value; string variant = xmlNode.Attributes.GetNamedItem("Variant") != null?xmlNode.Attributes.GetNamedItem("Variant").Value : null; string fileSystem = xmlNode.Attributes.GetNamedItem("FileSystem") != null?xmlNode.Attributes.GetNamedItem("FileSystem").Value : null; byte loadType = 0; if (xmlNode.Attributes.GetNamedItem("LoadType") != null) { byte.TryParse(xmlNode.Attributes.GetNamedItem("LoadType").Value, out loadType); } byte assetCategory = 0; if (xmlNode.Attributes.GetNamedItem("AssetCategory") != null) { byte.TryParse(xmlNode.Attributes.GetNamedItem("AssetCategory").Value, out assetCategory); } bool packed = false; if (xmlNode.Attributes.GetNamedItem("Packed") != null) { bool.TryParse(xmlNode.Attributes.GetNamedItem("Packed").Value, out packed); } string[] resourceGroups = xmlNode.Attributes.GetNamedItem("ResourceGroups") != null?xmlNode.Attributes.GetNamedItem("ResourceGroups").Value.Split(',') : null; if (!AddResource(name, variant, fileSystem, (LoadType)loadType, packed, resourceGroups, (AssetCategory)assetCategory)) { Debug.LogWarning(Utility.Text.Format("Can not add resource '{0}'.", GetResourceFullName(name, variant))); continue; } } xmlNodeList = xmlAssets.ChildNodes; count = xmlNodeList.Count; for (int i = 0; i < count; i++) { OnLoadingAsset?.Invoke(i, count); xmlNode = xmlNodeList.Item(i); if (xmlNode.Name != "Asset") { continue; } string guid = xmlNode.Attributes.GetNamedItem("Guid").Value; string name = xmlNode.Attributes.GetNamedItem("ResourceName").Value; string variant = xmlNode.Attributes.GetNamedItem("ResourceVariant") != null?xmlNode.Attributes.GetNamedItem("ResourceVariant").Value : null; if (!AssignAsset(guid, name, variant)) { Debug.LogWarning(Utility.Text.Format("Can not assign asset '{0}' to resource '{1}'.", guid, GetResourceFullName(name, variant))); continue; } } OnLoadCompleted?.Invoke(); return(true); } catch { File.Delete(m_ConfigurationPath); if (OnLoadCompleted != null) { OnLoadCompleted(); } return(false); } }
public void CallOnLoadComplete(object sender, LoadCompletedEventArgs args) { OnLoadCompleted?.Invoke(sender, args); }
protected void InvokeOnLoadCompletedEvent() { OnLoadCompleted?.Invoke(); }