safety snapshot: recover geo importers and current quest/server state
This commit is contained in:
@@ -24,6 +24,7 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
[SerializeField] private float updateInterval = 0.5f;
|
||||
[SerializeField] private int maxConcurrentLoads = 2;
|
||||
[SerializeField] private bool verboseLogging = false;
|
||||
[SerializeField] private bool useEmbeddedBuildingsInTilePrefabs = true;
|
||||
|
||||
[Header("Buildings (2km blocks)")]
|
||||
[SerializeField] private bool loadBuildingsFor2kmBlocks = true;
|
||||
@@ -85,6 +86,10 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
var basePath = Path.Combine(Application.persistentDataPath, tileBundleFolderName, buildTargetFolder);
|
||||
var manifestPath = Path.Combine(basePath, manifestFileName);
|
||||
|
||||
Debug.Log(
|
||||
$"[GeoTileAddressablesLoader] Startup: platform={Application.platform}, " +
|
||||
$"persistentDataPath={Application.persistentDataPath}, basePath={basePath}, manifestPath={manifestPath}");
|
||||
|
||||
Log($"Initializing loader. BasePath={basePath}");
|
||||
Log($"ManifestPath={manifestPath}");
|
||||
|
||||
@@ -112,6 +117,10 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
LoadBuildingManifest(basePath);
|
||||
BuildBuildingBlocks();
|
||||
|
||||
Debug.Log(
|
||||
$"[GeoTileAddressablesLoader] Manifest loaded: path={manifestPath}, buildTarget={manifest.buildTarget}, " +
|
||||
$"catalogFile={manifest.catalogFile}, catalogHashFile={manifest.catalogHashFile}, tileCount={tiles.Count}");
|
||||
|
||||
Log($"Manifest loaded. Tiles={tiles.Count} CatalogFile={manifest.catalogFile}");
|
||||
|
||||
var catalogPath = Path.Combine(basePath, manifest.catalogFile);
|
||||
@@ -121,8 +130,11 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
yield break;
|
||||
}
|
||||
|
||||
var catalogUri = ToFileUri(catalogPath);
|
||||
Debug.Log($"[GeoTileAddressablesLoader] Loading catalog: path={catalogPath}, uri={catalogUri}");
|
||||
|
||||
Log($"Loading catalog: {catalogPath}");
|
||||
var handle = Addressables.LoadContentCatalogAsync(ToFileUri(catalogPath), true);
|
||||
var handle = Addressables.LoadContentCatalogAsync(catalogUri, true);
|
||||
yield return handle;
|
||||
|
||||
if (handle.Status != AsyncOperationStatus.Succeeded)
|
||||
@@ -131,11 +143,61 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
yield break;
|
||||
}
|
||||
|
||||
Debug.Log($"[GeoTileAddressablesLoader] Catalog loaded successfully: {manifest.catalogFile}");
|
||||
Log("Catalog loaded successfully.");
|
||||
|
||||
// Sanity-check key resolution against the loaded catalog so logcat immediately
|
||||
// shows whether the runtime catalog actually contains our tile keys.
|
||||
yield return StartCoroutine(LogCatalogKeyProbe());
|
||||
|
||||
initialized = true;
|
||||
nextUpdateTime = Time.time;
|
||||
}
|
||||
|
||||
private IEnumerator LogCatalogKeyProbe()
|
||||
{
|
||||
int probeCount = 0;
|
||||
foreach (var kvp in tiles)
|
||||
{
|
||||
var key = kvp.Key;
|
||||
var locationsHandle = Addressables.LoadResourceLocationsAsync(key);
|
||||
yield return locationsHandle;
|
||||
|
||||
int locationCount = 0;
|
||||
if (locationsHandle.Status == AsyncOperationStatus.Succeeded && locationsHandle.Result != null)
|
||||
locationCount = locationsHandle.Result.Count;
|
||||
|
||||
Debug.Log($"[GeoTileAddressablesLoader] KeyProbe tile key={key} locations={locationCount}");
|
||||
Addressables.Release(locationsHandle);
|
||||
|
||||
probeCount++;
|
||||
if (probeCount >= 5)
|
||||
break;
|
||||
}
|
||||
|
||||
if (loadBuildingsFor2kmBlocks && buildingTiles.Count > 0)
|
||||
{
|
||||
int buildingProbeCount = 0;
|
||||
foreach (var kvp in buildingTiles)
|
||||
{
|
||||
var key = kvp.Key;
|
||||
var locationsHandle = Addressables.LoadResourceLocationsAsync(key);
|
||||
yield return locationsHandle;
|
||||
|
||||
int locationCount = 0;
|
||||
if (locationsHandle.Status == AsyncOperationStatus.Succeeded && locationsHandle.Result != null)
|
||||
locationCount = locationsHandle.Result.Count;
|
||||
|
||||
Debug.Log($"[GeoTileAddressablesLoader] KeyProbe building key={key} locations={locationCount}");
|
||||
Addressables.Release(locationsHandle);
|
||||
|
||||
buildingProbeCount++;
|
||||
if (buildingProbeCount >= 5)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadBuildingManifest(string basePath)
|
||||
{
|
||||
buildingManifest = null;
|
||||
@@ -145,6 +207,7 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
return;
|
||||
|
||||
var path = Path.Combine(basePath, buildingManifestFileName);
|
||||
Debug.Log($"[GeoTileAddressablesLoader] Building manifest path: {path}");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Log($"Building manifest not found: {path}");
|
||||
@@ -165,6 +228,9 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
buildingTiles[key] = tile;
|
||||
}
|
||||
|
||||
Debug.Log(
|
||||
$"[GeoTileAddressablesLoader] Building manifest loaded: path={path}, buildTarget={buildingManifest.buildTarget}, " +
|
||||
$"catalogFile={buildingManifest.catalogFile}, tileCount={buildingTiles.Count}");
|
||||
Log($"Building manifest loaded. BuildingTiles={buildingTiles.Count}");
|
||||
}
|
||||
|
||||
@@ -330,6 +396,12 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
var instance = op.Result;
|
||||
instance.name = tileKey;
|
||||
instance.transform.position = new Vector3(tile.offsetX, tile.baseY, tile.offsetZ);
|
||||
|
||||
if (!useEmbeddedBuildingsInTilePrefabs)
|
||||
RemoveEmbeddedBuildings(instance, tileKey);
|
||||
|
||||
LogTerrainState(instance, tileKey);
|
||||
|
||||
loaded[tileKey] = instance;
|
||||
Log($"Loaded tile {tileKey}. LoadedCount={loaded.Count}");
|
||||
};
|
||||
@@ -382,6 +454,82 @@ public class GeoTileAddressablesLoader : MonoBehaviour
|
||||
Log($"Unloaded buildings {buildingKey}. LoadedCount={buildingLoaded.Count}");
|
||||
}
|
||||
|
||||
private static void LogTerrainState(GameObject instance, string tileKey)
|
||||
{
|
||||
if (instance == null)
|
||||
return;
|
||||
|
||||
var terrain = instance.GetComponent<Terrain>();
|
||||
if (terrain == null)
|
||||
{
|
||||
Debug.LogWarning($"[GeoTileAddressablesLoader] Tile {tileKey}: no Terrain component on instance.");
|
||||
return;
|
||||
}
|
||||
|
||||
var td = terrain.terrainData;
|
||||
if (td == null)
|
||||
{
|
||||
Debug.LogWarning($"[GeoTileAddressablesLoader] Tile {tileKey}: TerrainData is NULL.");
|
||||
return;
|
||||
}
|
||||
|
||||
var layers = td.terrainLayers;
|
||||
int layerCount = layers != null ? layers.Length : 0;
|
||||
bool hasDiffuse = false;
|
||||
string diffuseName = "<none>";
|
||||
if (layerCount > 0 && layers[0] != null && layers[0].diffuseTexture != null)
|
||||
{
|
||||
hasDiffuse = true;
|
||||
diffuseName = layers[0].diffuseTexture.name;
|
||||
}
|
||||
|
||||
string materialName = terrain.materialTemplate != null ? terrain.materialTemplate.name : "<none>";
|
||||
Debug.Log(
|
||||
$"[GeoTileAddressablesLoader] Tile {tileKey}: terrain ok, " +
|
||||
$"drawHeightmap={terrain.drawHeightmap}, layers={layerCount}, " +
|
||||
$"hasDiffuse={hasDiffuse}, diffuse={diffuseName}, material={materialName}");
|
||||
}
|
||||
|
||||
private void RemoveEmbeddedBuildings(GameObject tileInstance, string tileKey)
|
||||
{
|
||||
if (tileInstance == null)
|
||||
return;
|
||||
|
||||
int removed = 0;
|
||||
var removedIds = new HashSet<int>();
|
||||
|
||||
// Current tile prefab convention: a direct child named "Buildings"
|
||||
var direct = tileInstance.transform.Find("Buildings");
|
||||
if (direct != null)
|
||||
{
|
||||
Destroy(direct.gameObject);
|
||||
removed++;
|
||||
removedIds.Add(direct.gameObject.GetInstanceID());
|
||||
}
|
||||
|
||||
// Safety pass if any nested "Buildings" transforms exist
|
||||
var all = tileInstance.GetComponentsInChildren<Transform>(true);
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
{
|
||||
var t = all[i];
|
||||
if (t == null || t == tileInstance.transform)
|
||||
continue;
|
||||
|
||||
if (!string.Equals(t.name, "Buildings", StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
if (removedIds.Contains(t.gameObject.GetInstanceID()))
|
||||
continue;
|
||||
|
||||
Destroy(t.gameObject);
|
||||
removed++;
|
||||
removedIds.Add(t.gameObject.GetInstanceID());
|
||||
}
|
||||
|
||||
if (removed > 0)
|
||||
Log($"Removed {removed} embedded building root(s) from tile {tileKey}.");
|
||||
}
|
||||
|
||||
private void BuildBuildingBlocks()
|
||||
{
|
||||
tileBlockKey.Clear();
|
||||
|
||||
Reference in New Issue
Block a user