This commit is contained in:
in0finite 2022-03-24 03:16:12 +01:00
parent c92a73a470
commit 2c323df667
2 changed files with 35 additions and 0 deletions

View file

@ -16,6 +16,7 @@ namespace SanAndreasUnity.Behaviours.World
[SerializeField] private GameObject m_waterCollisionPrefab;
[SerializeField] private bool m_createCollisionObjects = false;
public bool CreateCollisionObjects { get => m_createCollisionObjects; set => m_createCollisionObjects = value; }
[SerializeField] private float m_collisionHeight = 200f;
[SerializeField] private float m_shallowCollisionHeight = 10f;
[SerializeField] private bool m_createVisualsForCollisionObjects = false;

View file

@ -6,6 +6,8 @@ using System.Linq;
using UnityEditor;
using SanAndreasUnity.Utilities;
using UnityEngine.AI;
using SanAndreasUnity.Behaviours.World;
using SanAndreasUnity.Behaviours;
namespace SanAndreasUnity.Editor
{
@ -35,6 +37,18 @@ namespace SanAndreasUnity.Editor
Config.SetString("loadStaticRenderModels", false.ToString());
Config.SetString("dontLoadTextures", true.ToString());
// load game data
Loader.StartLoading();
while (Loader.IsLoading)
yield return null;
if (!Loader.HasLoaded)
throw new Exception("Loader did not finish successfully");
// use AssetExporter to load game collision
var assetExporter = new AssetExporter
{
ExportPrefabs = false,
@ -55,6 +69,15 @@ namespace SanAndreasUnity.Editor
if (!assetExporter.FinishedSuccessfully)
throw new Exception("Asset exporter did not finish successfully");
// we need to create collision for water
Cell.Singleton.Water.CreateCollisionObjects = true;
Cell.Singleton.Water.Initialize(Cell.Singleton.WorldSize * Vector2.one);
// just some testing
DisableObjects();
// now fire up NavMeshGenerator
var navMeshGenerator = new NavMeshGenerator(null);
var navMeshBuildSettings = NavMesh.GetSettingsByID(0);
@ -74,6 +97,8 @@ namespace SanAndreasUnity.Editor
Debug.Log("Finished generator of nav mesh from command line");
yield return null;
//EditorApplication.Exit(0);
}
@ -81,5 +106,14 @@ namespace SanAndreasUnity.Editor
{
//EditorApplication.Exit(1);
}
static void DisableObjects()
{
Cell.Singleton.gameObject.GetFirstLevelChildrenSingleComponent<MapObject>().ForEach(mapObject =>
{
if (mapObject.transform.Distance(Vector3.zero) > 300)
mapObject.gameObject.SetActive(false);
});
}
}
}