中
This commit is contained in:
@@ -489,7 +489,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 997852737}
|
||||
- component: {fileID: 997852736}
|
||||
- component: {fileID: 997852735}
|
||||
- component: {fileID: 997852738}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
@@ -497,26 +497,6 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &997852735
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 997852734}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
--- !u!114 &997852736
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -547,6 +527,48 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &997852738
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 997852734}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
m_ScrollDeltaPerTick: 6
|
||||
--- !u!1 &1268637829
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -664,7 +686,7 @@ MonoBehaviour:
|
||||
- {fileID: 1281760859}
|
||||
- {fileID: 1557817561}
|
||||
- {fileID: 997852734}
|
||||
PlayMode: 0
|
||||
PlayMode: 2
|
||||
--- !u!4 &1281760861
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
BIN
Assets/Res/Main/EntityArt/AnimationLibrary_Unity_Standard.fbx
Normal file
BIN
Assets/Res/Main/EntityArt/AnimationLibrary_Unity_Standard.fbx
Normal file
Binary file not shown.
@@ -0,0 +1,109 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d45be5b270ce92469f786691135214c
|
||||
ModelImporter:
|
||||
serializedVersion: 22200
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 2
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importPhysicalCameras: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
strictVertexDataChecks: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 0
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 2
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
importBlendShapeDeformPercent: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -132,34 +132,14 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 109037212}
|
||||
- component: {fileID: 109037211}
|
||||
- component: {fileID: 109037210}
|
||||
- component: {fileID: 109037213}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &109037210
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109037209}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
m_IsActive: 0
|
||||
--- !u!114 &109037211
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -190,6 +170,48 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &109037213
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109037209}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
m_ScrollDeltaPerTick: 6
|
||||
--- !u!1 &444951594
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -308,6 +330,94 @@ MonoBehaviour:
|
||||
m_LightCookieSize: {x: 1, y: 1}
|
||||
m_LightCookieOffset: {x: 0, y: 0}
|
||||
m_SoftShadowQuality: 0
|
||||
--- !u!1001 &465007459
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalScale.z
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: AnimationLibrary_Unity_Standard
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: 9d45be5b270ce92469f786691135214c,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 9d45be5b270ce92469f786691135214c, type: 3}
|
||||
--- !u!1 &488143178
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -440,7 +550,7 @@ Transform:
|
||||
m_GameObject: {fileID: 488143178}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 5, z: 0}
|
||||
m_LocalPosition: {x: 0, y: 5, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@@ -453,12 +563,69 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 488143178}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 289ff0037da069d4eabdb31ba944ce72, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
mP_Text: {fileID: 2090581202}
|
||||
mP_Text: {fileID: 0}
|
||||
--- !u!1 &634706095
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 634706097}
|
||||
- component: {fileID: 634706096}
|
||||
m_Layer: 0
|
||||
m_Name: AutoMapGenerator
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &634706096
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 634706095}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f53343ff90165f249ac0c50afd2dc804, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
areaName: "\u76EE\u6807\u533A\u57DF"
|
||||
southLat: 39.91
|
||||
northLat: 39.93
|
||||
westLon: 116.38
|
||||
eastLon: 116.41
|
||||
buildingMaterial: {fileID: 0}
|
||||
roadMaterial: {fileID: 0}
|
||||
parkMaterial: {fileID: 0}
|
||||
waterMaterial: {fileID: 0}
|
||||
groundMaterial: {fileID: 0}
|
||||
buildingHeight: 8
|
||||
roadWidth: 6
|
||||
showDebugInfo: 1
|
||||
--- !u!4 &634706097
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 634706095}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1167915817
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -477,7 +644,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!114 &1167915818
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -712,7 +879,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 2147483647
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!154 &2139286201
|
||||
TerrainCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -797,3 +964,5 @@ SceneRoots:
|
||||
- {fileID: 488143182}
|
||||
- {fileID: 1167915821}
|
||||
- {fileID: 109037212}
|
||||
- {fileID: 465007459}
|
||||
- {fileID: 634706097}
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using YooAsset.Editor;
|
||||
using YooAsset;
|
||||
@@ -8,21 +8,21 @@ using UnityEditor.Build.Pipeline;
|
||||
|
||||
public class BuildTool
|
||||
{
|
||||
[MenuItem("Tools/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Preload")]
|
||||
[MenuItem("Tools/打包Preload")]
|
||||
public static void BuildPreload()
|
||||
{
|
||||
CopyHotDll.CopyPreloadDll2Byte();
|
||||
ExecuteBuild("Preload",EBuildPipeline.ScriptableBuildPipeline, EditorUserBuildSettings.activeBuildTarget,EFileNameStyle.BundleName_HashName,EBuildinFileCopyOption.ClearAndCopyAll);
|
||||
Debug.Log($"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Preload<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
Debug.Log($"打包Preload结束");
|
||||
}
|
||||
[MenuItem("Tools/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Main %G")]
|
||||
[MenuItem("Tools/打包Main %G")]
|
||||
public static void BuildMain()
|
||||
{
|
||||
CopyHotDll.CopyMainDll2Byte();
|
||||
ExecuteBuild("Main", EBuildPipeline.ScriptableBuildPipeline, EditorUserBuildSettings.activeBuildTarget, EFileNameStyle.BundleName_HashName, EBuildinFileCopyOption.None);
|
||||
Debug.Log($"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Main<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
Debug.Log($"打包Main结束");
|
||||
}
|
||||
[MenuItem("Tools/ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
||||
[MenuItem("Tools/全部打包")]
|
||||
public static void BuildAll()
|
||||
{
|
||||
BuildPreload();
|
||||
@@ -68,8 +68,8 @@ public class BuildTool
|
||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||
}
|
||||
/// <summary>
|
||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// ע<EFBFBD>⣺<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD>
|
||||
/// 内置着色器资源包名称
|
||||
/// 注意:和自动收集的着色器资源包名保持一致!
|
||||
/// </summary>
|
||||
public static string GetBuiltinShaderBundleName(string PackageName)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
public class CopyHotDll
|
||||
{
|
||||
[MenuItem("Tools/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PreloadDll")]
|
||||
[MenuItem("Tools/更新生成PreloadDll")]
|
||||
public static void CopyPreloadDll2Byte()
|
||||
{
|
||||
HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
@@ -23,7 +23,7 @@ public class CopyHotDll
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log($"copy {sourceDir} to {destDir}");
|
||||
}
|
||||
[MenuItem("Tools/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MainDll")]
|
||||
[MenuItem("Tools/更新生成MainDll")]
|
||||
public static void CopyMainDll2Byte()
|
||||
{
|
||||
HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
@@ -37,7 +37,7 @@ public class CopyHotDll
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log($"copy {sourceDir} to {destDir}");
|
||||
}
|
||||
[MenuItem("Tools/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ")]
|
||||
[MenuItem("Tools/更新生成补充数据源")]
|
||||
public static void CopyDepDll2Byte()
|
||||
{
|
||||
HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using YooAsset;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class Test : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class SingletonMono<T> : MonoBehaviour where T : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
8
Assets/Scripts/Test.meta
Normal file
8
Assets/Scripts/Test.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4496b4e65b004c84199bb822321789bb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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: []
|
||||
@@ -1,8 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3687d2503d9d9ab4c8ac9427892b3764
|
||||
guid: df7e2e5ccd01541439b5b56e5fd1d8bd
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9000000
|
||||
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:
|
||||
Binary file not shown.
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"FileVersion": "1.0.0",
|
||||
"PackageName": "Preload",
|
||||
"PackageVersion": "2025-10-09-554",
|
||||
"PackageVersion": "2025-10-10-876",
|
||||
"Wrappers": [
|
||||
{
|
||||
"BundleGUID": "fa4a44515183a01f3ab367e78b06c4bf",
|
||||
"FileName": "preload_assets_res_preload_hotupdatedll_fa4a44515183a01f3ab367e78b06c4bf.bundle"
|
||||
"BundleGUID": "e302da1c009b85048d83055f7dae31f4",
|
||||
"FileName": "preload_assets_res_preload_hotupdatedll_e302da1c009b85048d83055f7dae31f4.bundle"
|
||||
},
|
||||
{
|
||||
"BundleGUID": "3af8985a0950e33249e822a39aa0ccc6",
|
||||
|
||||
@@ -1 +1 @@
|
||||
2025-10-09-554
|
||||
2025-10-10-876
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
999dce39
|
||||
BIN
Assets/StreamingAssets/yoo/Preload/Preload_2025-10-10-876.bytes
Normal file
BIN
Assets/StreamingAssets/yoo/Preload/Preload_2025-10-10-876.bytes
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eed98ff87cd99e4d9f4006580f636dc
|
||||
guid: 7af06e0813eea084fb01c2598872deac
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -0,0 +1 @@
|
||||
c86a962a
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbef88cf5f7804147a516e01df75d1d9
|
||||
guid: 774f64eb7e11e474bb156dbc342bd20c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2134e25b264154542817e0d0fa647c44
|
||||
guid: a1201b11d151d5547b7d1a459c0f3fe8
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
Reference in New Issue
Block a user