From e6ce4c16c943bfe26d3e50d54053b9e64b5c5462 Mon Sep 17 00:00:00 2001 From: in0finite Date: Thu, 24 Mar 2022 21:21:35 +0100 Subject: [PATCH] if specified, disable objects out of given radius --- Assets/Scripts/Editor/NavMeshGeneratorCommandLine.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Editor/NavMeshGeneratorCommandLine.cs b/Assets/Scripts/Editor/NavMeshGeneratorCommandLine.cs index 536013b9..2fb3b800 100644 --- a/Assets/Scripts/Editor/NavMeshGeneratorCommandLine.cs +++ b/Assets/Scripts/Editor/NavMeshGeneratorCommandLine.cs @@ -83,8 +83,11 @@ namespace SanAndreasUnity.Editor Cell.Singleton.Water.CreateCollisionObjects = true; Cell.Singleton.Water.Initialize(Cell.Singleton.WorldSize * Vector2.one); - // TODO: just some testing, remove ... - DisableObjects(); + yield return null; + + // if specified, disable objects out of given radius + if (CmdLineUtils.TryGetUshortArgument("navMeshGenerationObjectsIncludeRadius", out ushort objectsRadius)) + DisableObjectsOutOfRadius(objectsRadius); // now fire up NavMeshGenerator @@ -120,11 +123,11 @@ namespace SanAndreasUnity.Editor EditorApplication.Exit(1); } - static void DisableObjects() + static void DisableObjectsOutOfRadius(ushort radius) { Cell.Singleton.gameObject.GetFirstLevelChildrenSingleComponent().ForEach(mapObject => { - if (mapObject.transform.Distance(Vector3.zero) > 400) + if (mapObject.transform.Distance(Vector3.zero) > radius) mapObject.gameObject.SetActive(false); }); }