/// <summary> /// target patch will be loaded and locked until unlocked and next regular unload cycle /// </summary> /// <param name="point">load patch that contains this point</param> /// <param name="OnFinished">will be called when the patch is loaded</param> public void LoadAndLockPatch(Vector3 point, Action OnFinished = null) { if (PatchConfiguration == null) { throw new NullReferenceException("Patch Configuration null"); } var x = RoundToInt(point.x / PatchConfiguration.PatchSize); var z = RoundToInt(point.z / PatchConfiguration.PatchSize); var pName = PatchConfiguration.FormatPatchName(x, z); if (IsPatchLoaded(pName)) { if (OnFinished != null) { OnFinished(); } return; } LockPatch(pName); LoadPatch(x, z, true, OnFinished); }
void RemovePatch(int x, int z, PatchConfiguration ps) { if (!EditorUtility.DisplayDialog("Remove Patch?", string.Format("The patch ({0}) will be deleted!", ps.FormatPatchName(x, z)), "Remove", "Cancel")) { return; } var s = SceneManager.GetSceneByPath(ps.FormatLocalAssetPathPatchName(x, z)); if (s.IsValid()) { EditorSceneManager.CloseScene(s, true); } //remove from build settings var path = ps.FormatLocalAssetPathPatchName(x, z); var settingsScenes = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes); for (var i = 0; i < settingsScenes.Count; i++) { if (!settingsScenes[i].path.Equals(path)) { continue; } settingsScenes.RemoveAt(i); break; } EditorBuildSettings.scenes = settingsScenes.ToArray(); //end remove from build settings EditorUtility.SetDirty(ps); AssetDatabase.DeleteAsset(path); }