中
This commit is contained in:
8
Assets/Scripts/Test/AutoMap.meta
Normal file
8
Assets/Scripts/Test/AutoMap.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ae155084cdc7004ea20a4ec3a4191b7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
463
Assets/Scripts/Test/AutoMap/AutoMapGenerator.cs
Normal file
463
Assets/Scripts/Test/AutoMap/AutoMapGenerator.cs
Normal file
@@ -0,0 +1,463 @@
|
||||
// Assets/Scripts/Test/AutoMap/AutoMapGenerator.cs
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Resources;
|
||||
|
||||
public class AutoMapGenerator : MonoBehaviour
|
||||
{
|
||||
[Header("地图区域设置")]
|
||||
public string areaName = "目标区域";
|
||||
public double southLat = 39.9100;
|
||||
public double northLat = 39.9300;
|
||||
public double westLon = 116.3800;
|
||||
public double eastLon = 116.4100;
|
||||
|
||||
[Header("资源引用 - 如为空将自动创建")]
|
||||
public Material buildingMaterial;
|
||||
public Material roadMaterial;
|
||||
public Material parkMaterial;
|
||||
public Material waterMaterial;
|
||||
public Material groundMaterial;
|
||||
|
||||
[Header("生成设置")]
|
||||
public float buildingHeight = 8f;
|
||||
public float roadWidth = 6f;
|
||||
|
||||
[Header("调试选项")]
|
||||
public bool showDebugInfo = true;
|
||||
public bool logMissingBuildings = true;
|
||||
public bool includeAllWays = true; // 新增
|
||||
|
||||
private OSMParser osmParser;
|
||||
private ResourceManager resourceManager;
|
||||
|
||||
void Start()
|
||||
{
|
||||
InitializeComponents();
|
||||
StartCoroutine(DownloadAndGenerateMap());
|
||||
}
|
||||
|
||||
void InitializeComponents()
|
||||
{
|
||||
// 确保有必要的组件
|
||||
osmParser = GetComponent<OSMParser>();
|
||||
if (osmParser == null) osmParser = gameObject.AddComponent<OSMParser>();
|
||||
|
||||
// 设置解析器选项
|
||||
osmParser.includeAllWays = includeAllWays;
|
||||
|
||||
// 初始化资源管理器
|
||||
resourceManager = new ResourceManager();
|
||||
resourceManager.InitializeResources(this);
|
||||
// 调试:显示现有材质
|
||||
if (showDebugInfo)
|
||||
{
|
||||
resourceManager.LogExistingMaterials();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加一个编辑器菜单项来清理和重新创建材质
|
||||
[ContextMenu("重新初始化材质")]
|
||||
public void ReinitializeMaterials()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("重新初始化材质...");
|
||||
|
||||
// 强制重新创建所有材质
|
||||
resourceManager = new ResourceManager();
|
||||
|
||||
// 清空现有材质引用
|
||||
buildingMaterial = null;
|
||||
roadMaterial = null;
|
||||
parkMaterial = null;
|
||||
waterMaterial = null;
|
||||
groundMaterial = null;
|
||||
|
||||
// 重新初始化
|
||||
resourceManager.InitializeResources(this);
|
||||
|
||||
Debug.Log("材质重新初始化完成");
|
||||
#endif
|
||||
}
|
||||
|
||||
// 添加一个方法来检查材质状态
|
||||
[ContextMenu("检查材质状态")]
|
||||
public void CheckMaterialStatus()
|
||||
{
|
||||
Debug.Log("=== 材质状态检查 ===");
|
||||
Debug.Log($"建筑材质: {buildingMaterial?.name ?? "未设置"}");
|
||||
Debug.Log($"道路材质: {roadMaterial?.name ?? "未设置"}");
|
||||
Debug.Log($"公园材质: {parkMaterial?.name ?? "未设置"}");
|
||||
Debug.Log($"水域材质: {waterMaterial?.name ?? "未设置"}");
|
||||
Debug.Log($"地面材质: {groundMaterial?.name ?? "未设置"}");
|
||||
|
||||
resourceManager.LogExistingMaterials();
|
||||
}
|
||||
|
||||
IEnumerator DownloadAndGenerateMap()
|
||||
{
|
||||
Debug.Log($"开始下载 {areaName} 地图数据...");
|
||||
|
||||
string overpassQuery = BuildOverpassQuery();
|
||||
string encodedQuery = UnityWebRequest.EscapeURL(overpassQuery);
|
||||
string url = $"https://overpass-api.de/api/interpreter?data={encodedQuery}";
|
||||
|
||||
if (showDebugInfo)
|
||||
{
|
||||
Debug.Log($"目标区域: {areaName}");
|
||||
Debug.Log($"经纬度范围: {southLat},{westLon} 到 {northLat},{eastLon}");
|
||||
}
|
||||
|
||||
using (UnityWebRequest request = UnityWebRequest.Get(url))
|
||||
{
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
string osmData = request.downloadHandler.text;
|
||||
Debug.Log($"成功下载地图数据! 长度: {osmData.Length} 字符");
|
||||
GenerateMap(osmData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"下载失败: {request.error}");
|
||||
CreateTestMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string BuildOverpassQuery()
|
||||
{
|
||||
return $@"
|
||||
[out:xml][timeout:45];
|
||||
(
|
||||
way[""building""]({southLat},{westLon},{northLat},{eastLon});
|
||||
way[""highway""]({southLat},{westLon},{northLat},{eastLon});
|
||||
way[""leisure""]({southLat},{westLon},{northLat},{eastLon});
|
||||
way[""waterway""]({southLat},{westLon},{northLat},{eastLon});
|
||||
way[""natural""][""natural""~""water""]({southLat},{westLon},{northLat},{eastLon});
|
||||
);
|
||||
(._;>;);
|
||||
out body;";
|
||||
}
|
||||
|
||||
void GenerateMap(string osmData)
|
||||
{
|
||||
ClearExistingMap();
|
||||
|
||||
if (string.IsNullOrEmpty(osmData) || osmData.Length < 100)
|
||||
{
|
||||
Debug.LogError("OSM数据无效,创建测试地图");
|
||||
CreateTestMap();
|
||||
return;
|
||||
}
|
||||
|
||||
OSMData parsedData = osmParser.ParseOSMXML(osmData);
|
||||
CreateMapElements(parsedData);
|
||||
|
||||
Debug.Log("地图生成完成!");
|
||||
}
|
||||
|
||||
void CreateMapElements(OSMData data)
|
||||
{
|
||||
// 创建地面
|
||||
CreateGround(data);
|
||||
|
||||
int totalBuildings = 0;
|
||||
int generatedBuildings = 0;
|
||||
int skippedBuildings = 0;
|
||||
|
||||
// 创建各种地图元素
|
||||
foreach (var way in data.ways)
|
||||
{
|
||||
var points = GetWayPoints(way, data);
|
||||
|
||||
if (way.IsBuilding)
|
||||
{
|
||||
totalBuildings++;
|
||||
|
||||
// 放宽建筑生成条件
|
||||
if (points.Count >= 3)
|
||||
{
|
||||
CreateBuilding(way, points);
|
||||
generatedBuildings++;
|
||||
}
|
||||
else if (points.Count == 2)
|
||||
{
|
||||
// 对于只有2个点的建筑,创建简化版本
|
||||
CreateSimpleBuilding(way, points);
|
||||
generatedBuildings++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"跳过建筑 {way.id}: 只有 {points.Count} 个点");
|
||||
skippedBuildings++;
|
||||
}
|
||||
}
|
||||
else if (way.IsRoad && points.Count >= 2)
|
||||
{
|
||||
CreateRoad(way, points);
|
||||
}
|
||||
else if (way.IsPark && points.Count >= 3)
|
||||
{
|
||||
CreatePark(way, points);
|
||||
}
|
||||
else if (way.IsWater && points.Count >= 3)
|
||||
{
|
||||
CreateWater(way, points);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"建筑生成统计: 总计{totalBuildings}, 生成{generatedBuildings}, 跳过{skippedBuildings}");
|
||||
}
|
||||
|
||||
// 创建简化建筑(用于只有2个点的情况)
|
||||
void CreateSimpleBuilding(OSMWay way, List<Vector3> points)
|
||||
{
|
||||
if (points.Count != 2) return;
|
||||
|
||||
GameObject building = new GameObject($"SimpleBuilding_{way.id}");
|
||||
building.transform.SetParent(transform);
|
||||
|
||||
// 计算矩形的四个点
|
||||
Vector3 direction = (points[1] - points[0]).normalized;
|
||||
Vector3 perpendicular = new Vector3(-direction.z, 0, direction.x); // 垂直方向
|
||||
|
||||
float width = 10f; // 默认宽度
|
||||
List<Vector3> footprint = new List<Vector3>
|
||||
{
|
||||
points[0] - perpendicular * width * 0.5f,
|
||||
points[1] - perpendicular * width * 0.5f,
|
||||
points[1] + perpendicular * width * 0.5f,
|
||||
points[0] + perpendicular * width * 0.5f
|
||||
};
|
||||
|
||||
var meshFilter = building.AddComponent<MeshFilter>();
|
||||
var renderer = building.AddComponent<MeshRenderer>();
|
||||
|
||||
meshFilter.mesh = CreateBuildingMesh(footprint, buildingHeight);
|
||||
renderer.material = buildingMaterial;
|
||||
building.AddComponent<MeshCollider>();
|
||||
|
||||
Debug.Log($"创建简化建筑: {way.id} (从{points.Count}个点生成)");
|
||||
}
|
||||
|
||||
// 改进的节点获取方法
|
||||
List<Vector3> GetWayPoints(OSMWay way, OSMData data)
|
||||
{
|
||||
var points = new List<Vector3>();
|
||||
var nodeDict = CreateNodeDictionary(data);
|
||||
|
||||
int foundNodes = 0;
|
||||
foreach (long nodeId in way.nodeRefs)
|
||||
{
|
||||
if (nodeDict.ContainsKey(nodeId))
|
||||
{
|
||||
points.Add(nodeDict[nodeId].unityPosition);
|
||||
foundNodes++;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundNodes < way.nodeRefs.Count && way.IsBuilding)
|
||||
{
|
||||
Debug.LogWarning($"建筑 {way.id}: 引用 {way.nodeRefs.Count} 个节点,只找到 {foundNodes} 个");
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
Dictionary<long, OSMNode> CreateNodeDictionary(OSMData data)
|
||||
{
|
||||
var dict = new Dictionary<long, OSMNode>();
|
||||
foreach (var node in data.nodes)
|
||||
dict[node.id] = node;
|
||||
return dict;
|
||||
}
|
||||
|
||||
void CreateGround(OSMData data)
|
||||
{
|
||||
if (data.nodes.Count == 0) return;
|
||||
|
||||
GameObject ground = GameObject.CreatePrimitive(PrimitiveType.Plane);
|
||||
ground.name = "MapGround";
|
||||
ground.transform.SetParent(transform);
|
||||
|
||||
Bounds bounds = CalculateBounds(data);
|
||||
ground.transform.position = new Vector3(bounds.center.x, -0.1f, bounds.center.z);
|
||||
ground.transform.localScale = new Vector3(bounds.size.x / 10f, 1, bounds.size.z / 10f);
|
||||
|
||||
ground.GetComponent<Renderer>().material = groundMaterial;
|
||||
}
|
||||
|
||||
void CreateBuilding(OSMWay way, List<Vector3> footprint)
|
||||
{
|
||||
GameObject building = new GameObject($"Building_{way.id}");
|
||||
building.transform.SetParent(transform);
|
||||
|
||||
var meshFilter = building.AddComponent<MeshFilter>();
|
||||
var renderer = building.AddComponent<MeshRenderer>();
|
||||
|
||||
meshFilter.mesh = CreateBuildingMesh(footprint, buildingHeight);
|
||||
renderer.material = buildingMaterial;
|
||||
building.AddComponent<MeshCollider>();
|
||||
}
|
||||
|
||||
void CreateRoad(OSMWay way, List<Vector3> path)
|
||||
{
|
||||
GameObject road = new GameObject($"Road_{way.id}");
|
||||
road.transform.SetParent(transform);
|
||||
|
||||
var lineRenderer = road.AddComponent<LineRenderer>();
|
||||
lineRenderer.positionCount = path.Count;
|
||||
lineRenderer.SetPositions(path.ToArray());
|
||||
lineRenderer.startWidth = roadWidth;
|
||||
lineRenderer.endWidth = roadWidth;
|
||||
lineRenderer.material = roadMaterial;
|
||||
lineRenderer.textureMode = LineTextureMode.Tile;
|
||||
}
|
||||
|
||||
void CreatePark(OSMWay way, List<Vector3> area)
|
||||
{
|
||||
GameObject park = new GameObject($"Park_{way.id}");
|
||||
park.transform.SetParent(transform);
|
||||
|
||||
var ground = GameObject.CreatePrimitive(PrimitiveType.Plane);
|
||||
ground.transform.SetParent(park.transform);
|
||||
ground.name = "ParkGround";
|
||||
|
||||
Bounds bounds = CalculateBounds(area);
|
||||
ground.transform.position = bounds.center;
|
||||
ground.transform.localScale = new Vector3(bounds.size.x / 10f, 1, bounds.size.z / 10f);
|
||||
ground.GetComponent<Renderer>().material = parkMaterial;
|
||||
}
|
||||
|
||||
void CreateWater(OSMWay way, List<Vector3> area)
|
||||
{
|
||||
GameObject water = new GameObject($"Water_{way.id}");
|
||||
water.transform.SetParent(transform);
|
||||
|
||||
var surface = GameObject.CreatePrimitive(PrimitiveType.Plane);
|
||||
surface.transform.SetParent(water.transform);
|
||||
surface.name = "WaterSurface";
|
||||
|
||||
Bounds bounds = CalculateBounds(area);
|
||||
surface.transform.position = bounds.center + Vector3.up * 0.1f;
|
||||
surface.transform.localScale = new Vector3(bounds.size.x / 10f, 1, bounds.size.z / 10f);
|
||||
surface.GetComponent<Renderer>().material = waterMaterial;
|
||||
}
|
||||
|
||||
Mesh CreateBuildingMesh(List<Vector3> footprint, float height)
|
||||
{
|
||||
Mesh mesh = new Mesh();
|
||||
var vertices = new List<Vector3>();
|
||||
var triangles = new List<int>();
|
||||
|
||||
int count = footprint.Count;
|
||||
|
||||
// 底面顶点
|
||||
vertices.AddRange(footprint);
|
||||
// 顶面顶点
|
||||
foreach (var point in footprint)
|
||||
vertices.Add(point + Vector3.up * height);
|
||||
|
||||
// 侧面
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int next = (i + 1) % count;
|
||||
triangles.Add(i); triangles.Add(next); triangles.Add(i + count);
|
||||
triangles.Add(next); triangles.Add(next + count); triangles.Add(i + count);
|
||||
}
|
||||
|
||||
// 底面和顶面
|
||||
var bottomTris = TriangulatePolygon(footprint, false);
|
||||
var topTris = TriangulatePolygon(footprint, true);
|
||||
|
||||
triangles.AddRange(bottomTris);
|
||||
foreach (int tri in topTris) triangles.Add(tri + count);
|
||||
|
||||
mesh.vertices = vertices.ToArray();
|
||||
mesh.triangles = triangles.ToArray();
|
||||
mesh.RecalculateNormals();
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
List<int> TriangulatePolygon(List<Vector3> vertices, bool clockwise)
|
||||
{
|
||||
var triangles = new List<int>();
|
||||
if (vertices.Count < 3) return triangles;
|
||||
|
||||
for (int i = 1; i < vertices.Count - 1; i++)
|
||||
{
|
||||
if (clockwise)
|
||||
{
|
||||
triangles.Add(0); triangles.Add(i); triangles.Add(i + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
triangles.Add(0); triangles.Add(i + 1); triangles.Add(i);
|
||||
}
|
||||
}
|
||||
return triangles;
|
||||
}
|
||||
|
||||
Bounds CalculateBounds(OSMData data)
|
||||
{
|
||||
if (data.nodes.Count == 0) return new Bounds();
|
||||
|
||||
Bounds bounds = new Bounds(data.nodes[0].unityPosition, Vector3.zero);
|
||||
foreach (var node in data.nodes)
|
||||
bounds.Encapsulate(node.unityPosition);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
Bounds CalculateBounds(List<Vector3> points)
|
||||
{
|
||||
if (points.Count == 0) return new Bounds();
|
||||
|
||||
Bounds bounds = new Bounds(points[0], Vector3.zero);
|
||||
foreach (var point in points)
|
||||
bounds.Encapsulate(point);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
void CreateTestMap()
|
||||
{
|
||||
Debug.Log("创建测试地图...");
|
||||
ClearExistingMap();
|
||||
|
||||
// 创建测试地面
|
||||
GameObject ground = GameObject.CreatePrimitive(PrimitiveType.Plane);
|
||||
ground.name = "TestGround";
|
||||
ground.transform.SetParent(transform);
|
||||
ground.transform.localScale = new Vector3(10, 1, 10);
|
||||
ground.GetComponent<Renderer>().material = groundMaterial;
|
||||
|
||||
// 创建几个测试建筑
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
var building = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
building.name = $"TestBuilding_{i}";
|
||||
building.transform.SetParent(transform);
|
||||
building.transform.position = new Vector3(i * 15, 4, 0);
|
||||
building.transform.localScale = new Vector3(10, 8, 10);
|
||||
building.GetComponent<Renderer>().material = buildingMaterial;
|
||||
}
|
||||
|
||||
Debug.Log("测试地图创建完成!");
|
||||
}
|
||||
|
||||
void ClearExistingMap()
|
||||
{
|
||||
foreach (Transform child in transform)
|
||||
DestroyImmediate(child.gameObject);
|
||||
}
|
||||
|
||||
[ContextMenu("重新生成地图")]
|
||||
public void RegenerateMap()
|
||||
{
|
||||
StartCoroutine(DownloadAndGenerateMap());
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Test/AutoMap/AutoMapGenerator.cs.meta
Normal file
11
Assets/Scripts/Test/AutoMap/AutoMapGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f53343ff90165f249ac0c50afd2dc804
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Test/AutoMap/Materials.meta
Normal file
8
Assets/Scripts/Test/AutoMap/Materials.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f58b9f3efb4edd4ca5dd11a94be8d7d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Scripts/Test/AutoMap/Materials/BuildingMat.mat
Normal file
135
Assets/Scripts/Test/AutoMap/Materials/BuildingMat.mat
Normal file
@@ -0,0 +1,135 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-4178316768675616329
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: BuildingMat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
|
||||
- _Color: {r: 0.8, g: 0.8, b: 0.8, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df7e2e5ccd01541439b5b56e5fd1d8bd
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Scripts/Test/AutoMap/Materials/GroundMat.mat
Normal file
135
Assets/Scripts/Test/AutoMap/Materials/GroundMat.mat
Normal file
@@ -0,0 +1,135 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GroundMat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.6, g: 0.6, b: 0.5, a: 1}
|
||||
- _Color: {r: 0.6, g: 0.6, b: 0.5, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &4614724421613292119
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
8
Assets/Scripts/Test/AutoMap/Materials/GroundMat.mat.meta
Normal file
8
Assets/Scripts/Test/AutoMap/Materials/GroundMat.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e2a22ccf5889264c887ae42a8dbf711
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Scripts/Test/AutoMap/Materials/ParkMat.mat
Normal file
135
Assets/Scripts/Test/AutoMap/Materials/ParkMat.mat
Normal file
@@ -0,0 +1,135 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-3019538798616889821
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: ParkMat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.39999998, g: 0.8, b: 0.39999998, a: 1}
|
||||
- _Color: {r: 0.39999995, g: 0.8, b: 0.39999995, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Scripts/Test/AutoMap/Materials/ParkMat.mat.meta
Normal file
8
Assets/Scripts/Test/AutoMap/Materials/ParkMat.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f4e7a1d4bb8a7142974c940f1cfaab9
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Scripts/Test/AutoMap/Materials/RoadMat.mat
Normal file
135
Assets/Scripts/Test/AutoMap/Materials/RoadMat.mat
Normal file
@@ -0,0 +1,135 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-7555240385564894646
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: RoadMat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
8
Assets/Scripts/Test/AutoMap/Materials/RoadMat.mat.meta
Normal file
8
Assets/Scripts/Test/AutoMap/Materials/RoadMat.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 407560205895ca44ebbbd93e77cc59ae
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Scripts/Test/AutoMap/Materials/WaterMat.mat
Normal file
135
Assets/Scripts/Test/AutoMap/Materials/WaterMat.mat
Normal file
@@ -0,0 +1,135 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: WaterMat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.19999996, g: 0.39999998, b: 0.8, a: 0.7}
|
||||
- _Color: {r: 0.19999993, g: 0.39999995, b: 0.8, a: 0.7}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &8828093374252480784
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
8
Assets/Scripts/Test/AutoMap/Materials/WaterMat.mat.meta
Normal file
8
Assets/Scripts/Test/AutoMap/Materials/WaterMat.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2455036fb4f5fb4c8f9c737ce79f6e4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/Scripts/Test/AutoMap/OSMDataModels.cs
Normal file
34
Assets/Scripts/Test/AutoMap/OSMDataModels.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
// Assets/Scripts/Test/AutoMap/OSMDataModels.cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class OSMData
|
||||
{
|
||||
public List<OSMNode> nodes = new List<OSMNode>();
|
||||
public List<OSMWay> ways = new List<OSMWay>();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class OSMNode
|
||||
{
|
||||
public long id;
|
||||
public double lat;
|
||||
public double lon;
|
||||
public Vector3 unityPosition;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class OSMWay
|
||||
{
|
||||
public long id;
|
||||
public List<long> nodeRefs = new List<long>();
|
||||
public Dictionary<string, string> tags = new Dictionary<string, string>();
|
||||
|
||||
public bool IsBuilding => tags.ContainsKey("building");
|
||||
public bool IsRoad => tags.ContainsKey("highway");
|
||||
public bool IsPark => tags.ContainsKey("leisure") || (tags.ContainsKey("landuse") && tags["landuse"] == "park");
|
||||
public bool IsWater => tags.ContainsKey("waterway") || (tags.ContainsKey("natural") && tags["natural"] == "water");
|
||||
public string RoadType => IsRoad ? tags["highway"] : "";
|
||||
}
|
||||
11
Assets/Scripts/Test/AutoMap/OSMDataModels.cs.meta
Normal file
11
Assets/Scripts/Test/AutoMap/OSMDataModels.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d65dd88419cb52249a01b061de5fc3ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
263
Assets/Scripts/Test/AutoMap/OSMParser.cs
Normal file
263
Assets/Scripts/Test/AutoMap/OSMParser.cs
Normal file
@@ -0,0 +1,263 @@
|
||||
// Assets/Scripts/Test/AutoMap/OSMParser.cs
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using UnityEngine;
|
||||
|
||||
public class OSMParser : MonoBehaviour
|
||||
{
|
||||
[Header("解析设置")]
|
||||
public bool includeAllWays = true; // 包含所有路径,即使没有标签
|
||||
public bool includeRelations = false; // 是否包含关系数据
|
||||
|
||||
public OSMData ParseOSMXML(string xmlData)
|
||||
{
|
||||
OSMData osmData = new OSMData();
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
xmlDoc.LoadXml(xmlData);
|
||||
ParseNodes(xmlDoc, osmData);
|
||||
ParseWays(xmlDoc, osmData);
|
||||
|
||||
if (includeRelations)
|
||||
{
|
||||
ParseRelations(xmlDoc, osmData);
|
||||
}
|
||||
|
||||
Debug.Log($"解析完成: {osmData.nodes.Count} 节点, {osmData.ways.Count} 路径");
|
||||
|
||||
// 分析数据
|
||||
AnalyzeParsedData(osmData);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"解析OSM数据失败: {e.Message}");
|
||||
}
|
||||
|
||||
return osmData;
|
||||
}
|
||||
|
||||
void ParseNodes(XmlDocument xmlDoc, OSMData osmData)
|
||||
{
|
||||
XmlNodeList nodeList = xmlDoc.GetElementsByTagName("node");
|
||||
Debug.Log($"找到 {nodeList.Count} 个节点");
|
||||
|
||||
int parsedCount = 0;
|
||||
int failedCount = 0;
|
||||
|
||||
foreach (XmlNode node in nodeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var osmNode = new OSMNode
|
||||
{
|
||||
id = long.Parse(node.Attributes["id"].Value),
|
||||
lat = double.Parse(node.Attributes["lat"].Value),
|
||||
lon = double.Parse(node.Attributes["lon"].Value)
|
||||
};
|
||||
|
||||
// 解析标签(如果有)
|
||||
foreach (XmlNode child in node.ChildNodes)
|
||||
{
|
||||
if (child.Name == "tag")
|
||||
{
|
||||
string key = child.Attributes["k"].Value;
|
||||
string value = child.Attributes["v"].Value;
|
||||
// 可以在这里存储节点标签
|
||||
}
|
||||
}
|
||||
|
||||
osmData.nodes.Add(osmNode);
|
||||
parsedCount++;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogWarning($"解析节点失败: {e.Message}");
|
||||
failedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"节点解析: 成功 {parsedCount}, 失败 {failedCount}");
|
||||
|
||||
if (osmData.nodes.Count > 0)
|
||||
{
|
||||
ConvertToUnityCoordinates(osmData);
|
||||
}
|
||||
}
|
||||
|
||||
void ParseWays(XmlDocument xmlDoc, OSMData osmData)
|
||||
{
|
||||
XmlNodeList wayList = xmlDoc.GetElementsByTagName("way");
|
||||
Debug.Log($"找到 {wayList.Count} 条路径");
|
||||
|
||||
var nodeDict = CreateNodeDictionary(osmData);
|
||||
int waysAdded = 0;
|
||||
int waysSkipped = 0;
|
||||
|
||||
foreach (XmlNode way in wayList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var osmWay = new OSMWay { id = long.Parse(way.Attributes["id"].Value) };
|
||||
int validNodeRefs = 0;
|
||||
|
||||
// 处理节点引用
|
||||
foreach (XmlNode child in way.ChildNodes)
|
||||
{
|
||||
if (child.Name == "nd" && child.Attributes["ref"] != null)
|
||||
{
|
||||
long refId = long.Parse(child.Attributes["ref"].Value);
|
||||
osmWay.nodeRefs.Add(refId);
|
||||
|
||||
if (nodeDict.ContainsKey(refId))
|
||||
{
|
||||
validNodeRefs++;
|
||||
}
|
||||
}
|
||||
else if (child.Name == "tag")
|
||||
{
|
||||
string key = child.Attributes["k"].Value;
|
||||
string value = child.Attributes["v"].Value;
|
||||
osmWay.tags[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// 放宽条件:只要有有效节点引用就添加
|
||||
bool shouldAdd = false;
|
||||
|
||||
if (includeAllWays)
|
||||
{
|
||||
// 包含所有有足够节点的路径
|
||||
shouldAdd = validNodeRefs >= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 只包含有标签的路径
|
||||
shouldAdd = osmWay.tags.Count > 0 && validNodeRefs >= 2;
|
||||
}
|
||||
|
||||
if (shouldAdd)
|
||||
{
|
||||
osmData.ways.Add(osmWay);
|
||||
waysAdded++;
|
||||
|
||||
// 调试信息
|
||||
if (osmWay.IsBuilding && validNodeRefs < osmWay.nodeRefs.Count)
|
||||
{
|
||||
Debug.LogWarning($"建筑 {osmWay.id}: 引用 {osmWay.nodeRefs.Count} 个节点,找到 {validNodeRefs} 个");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
waysSkipped++;
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogWarning($"解析路径失败: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"路径解析: 添加 {waysAdded}, 跳过 {waysSkipped}");
|
||||
}
|
||||
|
||||
void ParseRelations(XmlDocument xmlDoc, OSMData osmData)
|
||||
{
|
||||
// 处理关系数据(如建筑群、复杂结构)
|
||||
XmlNodeList relationList = xmlDoc.GetElementsByTagName("relation");
|
||||
Debug.Log($"找到 {relationList.Count} 个关系");
|
||||
|
||||
// 这里可以添加关系解析逻辑
|
||||
}
|
||||
|
||||
Dictionary<long, OSMNode> CreateNodeDictionary(OSMData data)
|
||||
{
|
||||
var dict = new Dictionary<long, OSMNode>();
|
||||
foreach (var node in data.nodes)
|
||||
{
|
||||
dict[node.id] = node;
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
void ConvertToUnityCoordinates(OSMData osmData)
|
||||
{
|
||||
if (osmData.nodes.Count == 0) return;
|
||||
|
||||
// 计算所有节点的中心点作为原点
|
||||
double minLat = double.MaxValue, maxLat = double.MinValue;
|
||||
double minLon = double.MaxValue, maxLon = double.MinValue;
|
||||
|
||||
foreach (OSMNode node in osmData.nodes)
|
||||
{
|
||||
if (node.lat < minLat) minLat = node.lat;
|
||||
if (node.lat > maxLat) maxLat = node.lat;
|
||||
if (node.lon < minLon) minLon = node.lon;
|
||||
if (node.lon > maxLon) maxLon = node.lon;
|
||||
}
|
||||
|
||||
double originLat = (minLat + maxLat) / 2;
|
||||
double originLon = (minLon + maxLon) / 2;
|
||||
|
||||
Debug.Log($"坐标转换原点: ({originLat}, {originLon})");
|
||||
Debug.Log($"数据范围: 纬度[{minLat}~{maxLat}], 经度[{minLon}~{maxLon}]");
|
||||
|
||||
foreach (OSMNode node in osmData.nodes)
|
||||
{
|
||||
node.unityPosition = LatLonToUnityPosition(node.lat, node.lon, originLat, originLon);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 LatLonToUnityPosition(double lat, double lon, double originLat, double originLon)
|
||||
{
|
||||
float x = (float)((lon - originLon) * 111320 * Mathf.Cos((float)originLat * Mathf.Deg2Rad));
|
||||
float z = (float)((lat - originLat) * 110574);
|
||||
return new Vector3(x, 0, z);
|
||||
}
|
||||
|
||||
void AnalyzeParsedData(OSMData data)
|
||||
{
|
||||
Debug.Log("=== 数据解析分析 ===");
|
||||
|
||||
int buildingWays = 0;
|
||||
int roadWays = 0;
|
||||
int parkWays = 0;
|
||||
int waterWays = 0;
|
||||
int otherWays = 0;
|
||||
|
||||
foreach (var way in data.ways)
|
||||
{
|
||||
if (way.IsBuilding) buildingWays++;
|
||||
else if (way.IsRoad) roadWays++;
|
||||
else if (way.IsPark) parkWays++;
|
||||
else if (way.IsWater) waterWays++;
|
||||
else otherWays++;
|
||||
}
|
||||
|
||||
Debug.Log($"建筑路径: {buildingWays}");
|
||||
Debug.Log($"道路路径: {roadWays}");
|
||||
Debug.Log($"公园路径: {parkWays}");
|
||||
Debug.Log($"水域路径: {waterWays}");
|
||||
Debug.Log($"其他路径: {otherWays}");
|
||||
|
||||
// 分析建筑数据质量
|
||||
int buildingsWithEnoughNodes = 0;
|
||||
foreach (var way in data.ways)
|
||||
{
|
||||
if (way.IsBuilding)
|
||||
{
|
||||
if (way.nodeRefs.Count >= 3)
|
||||
{
|
||||
buildingsWithEnoughNodes++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"建筑 {way.id} 节点数不足: {way.nodeRefs.Count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"可生成建筑: {buildingsWithEnoughNodes}/{buildingWays}");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Test/AutoMap/OSMParser.cs.meta
Normal file
11
Assets/Scripts/Test/AutoMap/OSMParser.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad9eefaf2faee8447abd4a7e2812c4fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
172
Assets/Scripts/Test/AutoMap/ResourceManager.cs
Normal file
172
Assets/Scripts/Test/AutoMap/ResourceManager.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
// Assets/Scripts/Test/AutoMap/ResourceManager.cs
|
||||
using UnityEngine;
|
||||
|
||||
public class ResourceManager
|
||||
{
|
||||
private const string MATERIALS_PATH = "Assets/Scripts/Test/AutoMap/Materials/";
|
||||
|
||||
public void InitializeResources(AutoMapGenerator generator)
|
||||
{
|
||||
// 检查并创建缺失的材质
|
||||
if (generator.buildingMaterial == null)
|
||||
generator.buildingMaterial = GetOrCreateMaterial("BuildingMat", new Color(0.8f, 0.8f, 0.8f));
|
||||
|
||||
if (generator.roadMaterial == null)
|
||||
generator.roadMaterial = GetOrCreateMaterial("RoadMat", Color.gray);
|
||||
|
||||
if (generator.parkMaterial == null)
|
||||
generator.parkMaterial = GetOrCreateMaterial("ParkMat", new Color(0.4f, 0.8f, 0.4f));
|
||||
|
||||
if (generator.waterMaterial == null)
|
||||
{
|
||||
generator.waterMaterial = GetOrCreateMaterial("WaterMat", new Color(0.2f, 0.4f, 0.8f, 0.7f), true);
|
||||
}
|
||||
|
||||
if (generator.groundMaterial == null)
|
||||
generator.groundMaterial = GetOrCreateMaterial("GroundMat", new Color(0.6f, 0.6f, 0.5f));
|
||||
}
|
||||
|
||||
Material GetOrCreateMaterial(string name, Color color, bool isTransparent = false)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// 首先尝试加载已存在的材质
|
||||
string assetPath = MATERIALS_PATH + name + ".mat";
|
||||
Material existingMat = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>(assetPath);
|
||||
|
||||
if (existingMat != null)
|
||||
{
|
||||
Debug.Log($"加载现有材质: {name}");
|
||||
return existingMat;
|
||||
}
|
||||
|
||||
// 创建新材质
|
||||
Material mat;
|
||||
|
||||
// 根据是否透明选择URP Shader
|
||||
if (isTransparent)
|
||||
{
|
||||
// URP 透明Shader
|
||||
Shader urpTransparentShader = Shader.Find("Universal Render Pipeline/Lit");
|
||||
if (urpTransparentShader != null)
|
||||
{
|
||||
mat = new Material(urpTransparentShader);
|
||||
mat.SetFloat("_Surface", 1); // 1 = Transparent
|
||||
mat.SetFloat("_Blend", 0); // 0 = Alpha
|
||||
mat.SetFloat("_AlphaClip", 0); // 关闭Alpha裁剪
|
||||
}
|
||||
else
|
||||
{
|
||||
// 备用方案
|
||||
mat = new Material(Shader.Find("Standard"));
|
||||
mat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||
mat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||
mat.SetInt("_ZWrite", 0);
|
||||
mat.DisableKeyword("_ALPHATEST_ON");
|
||||
mat.EnableKeyword("_ALPHABLEND_ON");
|
||||
mat.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||
mat.renderQueue = 3000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// URP 不透明Shader
|
||||
Shader urpShader = Shader.Find("Universal Render Pipeline/Lit");
|
||||
if (urpShader != null)
|
||||
{
|
||||
mat = new Material(urpShader);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 备用方案
|
||||
mat = new Material(Shader.Find("Standard"));
|
||||
}
|
||||
}
|
||||
|
||||
mat.name = name;
|
||||
mat.color = color;
|
||||
|
||||
// 确保目录存在
|
||||
string directory = System.IO.Path.GetDirectoryName(assetPath);
|
||||
if (!System.IO.Directory.Exists(directory))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
// 创建材质资产
|
||||
UnityEditor.AssetDatabase.CreateAsset(mat, assetPath);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
|
||||
Debug.Log($"创建新材质: {name} 在路径: {assetPath}");
|
||||
return mat;
|
||||
#else
|
||||
// 运行时创建简单材质
|
||||
Material runtimeMat = new Material(Shader.Find("Universal Render Pipeline/Lit"));
|
||||
runtimeMat.name = name;
|
||||
runtimeMat.color = color;
|
||||
|
||||
if (isTransparent)
|
||||
{
|
||||
runtimeMat.SetFloat("_Surface", 1);
|
||||
runtimeMat.renderQueue = 3000;
|
||||
}
|
||||
|
||||
Debug.Log($"创建运行时材质: {name}");
|
||||
return runtimeMat;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 检查材质是否已存在的方法
|
||||
public bool CheckMaterialExists(string materialName)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
string assetPath = MATERIALS_PATH + materialName + ".mat";
|
||||
Material existingMat = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>(assetPath);
|
||||
return existingMat != null;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 获取所有已创建的材质(用于调试)
|
||||
public void LogExistingMaterials()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("=== 现有材质列表 ===");
|
||||
string[] materialPaths = UnityEditor.AssetDatabase.FindAssets("t:Material", new[] { "Assets/Scripts/Test/AutoMap/Materials" });
|
||||
|
||||
foreach (string guid in materialPaths)
|
||||
{
|
||||
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
|
||||
Material mat = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>(path);
|
||||
if (mat != null)
|
||||
{
|
||||
Debug.Log($"材质: {mat.name} - 路径: {path}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
public void CreateDefaultMaterialPresets()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("创建默认材质预设...");
|
||||
|
||||
// 建筑材质 - 灰色
|
||||
GetOrCreateMaterial("BuildingMat", new Color(0.8f, 0.8f, 0.8f));
|
||||
|
||||
// 道路材质 - 深灰色
|
||||
GetOrCreateMaterial("RoadMat", new Color(0.3f, 0.3f, 0.3f));
|
||||
|
||||
// 公园材质 - 绿色
|
||||
GetOrCreateMaterial("ParkMat", new Color(0.4f, 0.8f, 0.4f));
|
||||
|
||||
// 水域材质 - 蓝色透明
|
||||
GetOrCreateMaterial("WaterMat", new Color(0.2f, 0.4f, 0.8f, 0.7f), true);
|
||||
|
||||
// 地面材质 - 土黄色
|
||||
GetOrCreateMaterial("GroundMat", new Color(0.6f, 0.6f, 0.5f));
|
||||
|
||||
Debug.Log("默认材质预设创建完成");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Test/AutoMap/ResourceManager.cs.meta
Normal file
11
Assets/Scripts/Test/AutoMap/ResourceManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 845695eaa8466c24c89b25f2d2c52ba3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user