/** * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary> * <param name = "stringData">The data, serialised as a string</param> */ public override void LoadData(string stringData) { NavMesh2DData data = Serializer.LoadScriptData <NavMesh2DData> (stringData); if (data == null) { return; } SavePrevented = data.savePrevented; if (savePrevented) { return; } if (GetComponent <NavigationMesh>()) { NavigationMesh navMesh = GetComponent <NavigationMesh>(); navMesh.polygonColliderHoles.Clear(); KickStarter.navigationManager.navigationEngine.ResetHoles(navMesh); if (!string.IsNullOrEmpty(data._linkedIDs)) { int[] linkedIDs = StringToIntArray(data._linkedIDs); for (int i = 0; i < linkedIDs.Length; i++) { PolygonCollider2D polyHole = Serializer.returnComponent <PolygonCollider2D> (linkedIDs[i]); if (polyHole != null) { navMesh.AddHole(polyHole); } } } } }
/** * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary> * <param name = "stringData">The data, serialised as a string</param> */ public override void LoadData(string stringData) { NavMesh2DData data = Serializer.LoadScriptData <NavMesh2DData> (stringData); if (data == null) { return; } if (GetComponent <NavigationMesh>()) { NavigationMesh navMesh = GetComponent <NavigationMesh>(); navMesh.polygonColliderHoles.Clear(); if (data._linkedIDs.Length > 0) { int[] linkedIDs = StringToIntArray(data._linkedIDs); for (int i = 0; i < linkedIDs.Length; i++) { PolygonCollider2D polyHole = Serializer.returnComponent <PolygonCollider2D> (linkedIDs[i]); if (polyHole != null) { navMesh.AddHole(polyHole); } } } } }
override public float Run() { if (sceneSetting == SceneSetting.DefaultNavMesh) { if (KickStarter.sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider && changeNavMeshMethod == ChangeNavMeshMethod.ChangeNumberOfHoles && hole != null) { NavigationMesh currentNavMesh = KickStarter.sceneSettings.navMesh; if (holeAction == InvAction.Add) { currentNavMesh.AddHole(hole); } else if (holeAction == InvAction.Remove) { currentNavMesh.RemoveHole(hole); } else if (holeAction == InvAction.Replace) { currentNavMesh.AddHole(hole); currentNavMesh.RemoveHole(replaceHole); } } else if (newNavMesh != null) { NavigationMesh oldNavMesh = KickStarter.sceneSettings.navMesh; oldNavMesh.TurnOff(); newNavMesh.TurnOn(); KickStarter.sceneSettings.navMesh = newNavMesh; // Bugfix: Need to cycle this otherwise weight caching doesn't always work newNavMesh.TurnOff(); newNavMesh.TurnOn(); if (newNavMesh.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new NavMesh with no ConstantID - change will not be recognised by saved games."); } } } else if (sceneSetting == SceneSetting.DefaultPlayerStart && playerStart) { KickStarter.sceneSettings.defaultPlayerStart = playerStart; if (playerStart.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new default PlayerStart with no ConstantID - change will not be recognised by saved games."); } } else if (sceneSetting == SceneSetting.SortingMap && sortingMap) { KickStarter.sceneSettings.sortingMap = sortingMap; KickStarter.sceneSettings.UpdateAllSortingMaps(); if (sortingMap.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new SortingMap with no ConstantID - change will not be recognised by saved games."); } } else if (sceneSetting == SceneSetting.TintMap && tintMap) { KickStarter.sceneSettings.tintMap = tintMap; // Reset all FollowSortingMap components FollowTintMap[] followTintMaps = FindObjectsOfType(typeof(FollowTintMap)) as FollowTintMap[]; foreach (FollowTintMap followTintMap in followTintMaps) { followTintMap.ResetTintMap(); } if (tintMap.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new TintMap with no ConstantID - change will not be recognised by saved games."); } } else if (sceneSetting == SceneSetting.OnLoadCutscene) { KickStarter.sceneSettings.cutsceneOnLoad = cutscene; if (cutscene.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to Cutscene On Load with no ConstantID - change will not be recognised by saved games."); } } else if (sceneSetting == SceneSetting.OnStartCutscene) { KickStarter.sceneSettings.cutsceneOnStart = cutscene; if (cutscene.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to Cutscene On Start with no ConstantID - change will not be recognised by saved games."); } } return(0f); }
override public float Run() { if (sceneSetting == SceneSetting.DefaultNavMesh) { if (sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider && changeNavMeshMethod == ChangeNavMeshMethod.ChangeNumberOfHoles && hole != null) { NavigationMesh currentNavMesh = sceneSettings.navMesh; if (holeAction == InvAction.Add) { currentNavMesh.AddHole(hole); } else if (holeAction == InvAction.Remove) { currentNavMesh.RemoveHole(hole); } else if (holeAction == InvAction.Replace) { currentNavMesh.AddHole(hole); currentNavMesh.RemoveHole(replaceHole); } } else if (newNavMesh != null) { NavigationMesh oldNavMesh = sceneSettings.navMesh; oldNavMesh.TurnOff(); newNavMesh.TurnOn(); sceneSettings.navMesh = newNavMesh; // Bugfix: Need to cycle this otherwise weight caching doesn't always work newNavMesh.TurnOff(); newNavMesh.TurnOn(); if (newNavMesh.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new NavMesh with no ConstantID - change will not be recognised by saved games.", newNavMesh); } } // Recalculate pathfinding characters foreach (Char _character in KickStarter.stateHandler.Characters) { _character.RecalculateActivePathfind(); } } else if (sceneSetting == SceneSetting.DefaultPlayerStart && playerStart) { sceneSettings.defaultPlayerStart = playerStart; if (playerStart.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new default PlayerStart with no ConstantID - change will not be recognised by saved games.", playerStart); } } else if (sceneSetting == SceneSetting.SortingMap && sortingMap) { sceneSettings.sortingMap = sortingMap; sceneSettings.UpdateAllSortingMaps(); if (sortingMap.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new SortingMap with no ConstantID - change will not be recognised by saved games.", sortingMap); } } else if (sceneSetting == SceneSetting.TintMap && tintMap) { sceneSettings.tintMap = tintMap; // Reset all FollowSortingMap components FollowTintMap[] followTintMaps = FindObjectsOfType(typeof(FollowTintMap)) as FollowTintMap[]; foreach (FollowTintMap followTintMap in followTintMaps) { followTintMap.ResetTintMap(); } if (tintMap.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to new TintMap with no ConstantID - change will not be recognised by saved games.", tintMap); } } else if (sceneSetting == SceneSetting.OnLoadCutscene) { sceneSettings.cutsceneOnLoad = cutscene; if (sceneSettings.actionListSource == ActionListSource.AssetFile) { ACDebug.LogWarning("Warning: As the Scene Manager relies on asset files for its cutscenes, changes made with the 'Scene: Change setting' Action will not be felt."); } else if (cutscene != null && cutscene.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to Cutscene On Load with no ConstantID - change will not be recognised by saved games.", cutscene); } } else if (sceneSetting == SceneSetting.OnStartCutscene) { sceneSettings.cutsceneOnStart = cutscene; if (sceneSettings.actionListSource == ActionListSource.AssetFile) { ACDebug.LogWarning("Warning: As the Scene Manager relies on asset files for its cutscenes, changes made with the 'Scene: Change setting' Action will not be felt."); } else if (cutscene != null && cutscene.GetComponent <ConstantID>() == null) { ACDebug.LogWarning("Warning: Changing to Cutscene On Start with no ConstantID - change will not be recognised by saved games.", cutscene); } } return(0f); }