(client) feat:实现实体生成函数 #41
@ -77,7 +77,7 @@ SpriteRenderer:
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: 620e16cb0aec3684db9ef80bdcc85695, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
|
@ -173,8 +173,8 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1697214530303839877}
|
||||
- {fileID: 5549544358816209289}
|
||||
- {fileID: 1697214530303839877}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &3332598847335032684
|
||||
|
@ -100,7 +100,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 0c360a9f1baf4eaf9afa85617c395b0d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_defaultSprite: {fileID: 21300000, guid: 620e16cb0aec3684db9ef80bdcc85695, type: 3}
|
||||
_tintColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
_alpha: 1
|
||||
_preserveAspect: 1
|
||||
defaultSprite: {fileID: 21300000, guid: 620e16cb0aec3684db9ef80bdcc85695, type: 3}
|
||||
|
8
Client/Assets/Resources/Default/DefaultAnimation.meta
Normal file
8
Client/Assets/Resources/Default/DefaultAnimation.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0d6e117bfb89f14689759c2ed37bcb4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Client/Assets/Resources/Default/DefaultAnimation/00.png
Normal file
BIN
Client/Assets/Resources/Default/DefaultAnimation/00.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
117
Client/Assets/Resources/Default/DefaultAnimation/00.png.meta
Normal file
117
Client/Assets/Resources/Default/DefaultAnimation/00.png.meta
Normal file
@ -0,0 +1,117 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c21903d3e2b0754faf71558957968d5
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 40
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Client/Assets/Resources/Default/DefaultAnimation/01.png
Normal file
BIN
Client/Assets/Resources/Default/DefaultAnimation/01.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
117
Client/Assets/Resources/Default/DefaultAnimation/01.png.meta
Normal file
117
Client/Assets/Resources/Default/DefaultAnimation/01.png.meta
Normal file
@ -0,0 +1,117 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d306bc49c39e71f40870ef415657b5ba
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 40
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
145
Client/Assets/Resources/Default/DefaultEntity.prefab
Normal file
145
Client/Assets/Resources/Default/DefaultEntity.prefab
Normal file
@ -0,0 +1,145 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &4172273043265116072
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 978302365984264250}
|
||||
m_Modifications:
|
||||
- target: {fileID: 2113064398104960506, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: _sprites.Array.size
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2113064398104960506, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: '_sprites.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 21300000, guid: 3c21903d3e2b0754faf71558957968d5, type: 3}
|
||||
- target: {fileID: 2113064398104960506, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: '_sprites.Array.data[1]'
|
||||
value:
|
||||
objectReference: {fileID: 21300000, guid: d306bc49c39e71f40870ef415657b5ba, type: 3}
|
||||
- target: {fileID: 5021031438404678310, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Animation
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
--- !u!4 &5706548514770437405 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
m_PrefabInstance: {fileID: 4172273043265116072}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &4652308439801383347
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -0.93
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -0.25
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 697189026367054479, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 887327274103887133, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: DefaultEntity Variant
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 887327274103887133, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects:
|
||||
- targetCorrespondingSourceObject: {fileID: 5549544358816209289, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 5706548514770437405}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
--- !u!4 &978302365984264250 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 5549544358816209289, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
m_PrefabInstance: {fileID: 4652308439801383347}
|
||||
m_PrefabAsset: {fileID: 0}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89661daa5f100c64783f0ad9cd37a7ff
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -686,6 +686,7 @@ MonoBehaviour:
|
||||
isGlobal: 1
|
||||
entityLevel: {fileID: 309861628}
|
||||
entityPrefab: {fileID: 3332598847335032684, guid: 6cd8b01a0f57372438dc30c864ae1530, type: 3}
|
||||
defaultEntityPrefab: {fileID: 0}
|
||||
--- !u!114 &2036983434
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -743,120 +744,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &4078005684296227559
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -5.781
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -0.39
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4201281305206751642, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5309816858037840717, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Image
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: a6657f26d735fab4690c8185980fda29, type: 3}
|
||||
--- !u!1001 &7665142047032752812
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 5021031438404678310, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Animation
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -7.758
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -0.34
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8563418329714102965, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: ea9af70ce0f4c8b4a9de58ac63074156, type: 3}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -867,5 +754,3 @@ SceneRoots:
|
||||
- {fileID: 309861630}
|
||||
- {fileID: 2036983432}
|
||||
- {fileID: 1371068282}
|
||||
- {fileID: 7665142047032752812}
|
||||
- {fileID: 4078005684296227559}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
@ -339,5 +340,53 @@ namespace Configs
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取指定目录下所有匹配后缀名的文件路径(可递归)
|
||||
/// </summary>
|
||||
/// <param name="directoryPath">目标文件夹路径</param>
|
||||
/// <param name="extensions">后缀名列表(如 ["txt", "jpg"])</param>
|
||||
/// <param name="searchOption">是否包含子文件夹</param>
|
||||
/// <returns>匹配的文件路径列表</returns>
|
||||
public static List<string> GetFilesByExtensions(
|
||||
string directoryPath,
|
||||
string[] extensions,
|
||||
SearchOption searchOption = SearchOption.AllDirectories)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(directoryPath))
|
||||
throw new ArgumentException("目录路径不能为空", nameof(directoryPath));
|
||||
|
||||
if (!Directory.Exists(directoryPath))
|
||||
throw new DirectoryNotFoundException($"目录不存在: {directoryPath}");
|
||||
|
||||
if (extensions == null || extensions.Length == 0)
|
||||
throw new ArgumentException("后缀名列表不能为空", nameof(extensions));
|
||||
|
||||
// 标准化后缀名(去掉点,转小写)
|
||||
var normalizedExtensions = new HashSet<string>(
|
||||
extensions.Select(ext => ext.TrimStart('.').ToLower())
|
||||
);
|
||||
|
||||
var result = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
var files = Directory.GetFiles(directoryPath, "*", searchOption);
|
||||
foreach (var file in files)
|
||||
{
|
||||
var ext = Path.GetExtension(file).TrimStart('.').ToLower();
|
||||
if (normalizedExtensions.Contains(ext))
|
||||
{
|
||||
result.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
// 可选:记录日志或忽略无权限目录
|
||||
Console.WriteLine($"访问被拒绝: {ex.Message}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace Entity
|
||||
|
||||
public AIBase aiTree;
|
||||
public JobBase currentJob;
|
||||
public AttributesDef attributes;
|
||||
public AttributesDef attributes=new();
|
||||
public Vector3 direction;
|
||||
public GameObject body;
|
||||
public string affiliation;
|
||||
@ -42,15 +42,18 @@ namespace Entity
|
||||
private bool _isPlayerControlled = false;
|
||||
private bool _warning = false;
|
||||
|
||||
private Dictionary<Orientation,List<ITick>> bodyNode=new();
|
||||
private Orientation currentOrientation=Orientation.Down;
|
||||
private Dictionary<Orientation,List<ITick>> bodyAnimationNode=new();
|
||||
private Dictionary<Orientation, GameObject> bodyNodes = new();
|
||||
|
||||
private Orientation currentOrientation = Orientation.Down;
|
||||
|
||||
public virtual void Init(PawnDef pawnDef)
|
||||
{
|
||||
attributes = pawnDef.attributes.Clone();
|
||||
aiTree = ConvertToAIBase(pawnDef.behaviorTree);
|
||||
affiliation=pawnDef.affiliation;
|
||||
affiliation = pawnDef.affiliation;
|
||||
InitBody(pawnDef.drawingOrder);
|
||||
|
||||
}
|
||||
|
||||
public virtual void InitBody(DrawingOrderDef drawingOrder)
|
||||
@ -60,8 +63,8 @@ namespace Entity
|
||||
|
||||
foreach (var orientation in orientations)
|
||||
{
|
||||
currentOrientation=orientation;
|
||||
bodyNode[orientation]=new();
|
||||
currentOrientation = orientation;
|
||||
bodyAnimationNode[orientation] = new();
|
||||
// 获取当前方向的绘图节点
|
||||
var drawNode = drawingOrder.GetDrawingOrder(orientation);
|
||||
|
||||
@ -70,8 +73,15 @@ namespace Entity
|
||||
directionRoot.transform.SetParent(body.transform, false);
|
||||
|
||||
InitBodyPart(drawNode, directionRoot);
|
||||
bodyNodes[orientation] = directionRoot;
|
||||
}
|
||||
currentOrientation=Orientation.Down;
|
||||
currentOrientation = Orientation.Down;
|
||||
|
||||
foreach (var bodyNode in bodyNodes)
|
||||
{
|
||||
bodyNode.Value.SetActive(false);
|
||||
}
|
||||
SetOrientation(Orientation.Down);
|
||||
}
|
||||
|
||||
// 递归初始化单个绘图节点及其子节点
|
||||
@ -83,19 +93,19 @@ namespace Entity
|
||||
switch (drawNode.drawNodeType)
|
||||
{
|
||||
case DrawNodeType.Image:
|
||||
nodeObject = Instantiate(imagePrefab.gameObject);
|
||||
nodeObject = Instantiate(imagePrefab.gameObject,parent.transform);
|
||||
break;
|
||||
|
||||
case DrawNodeType.Animation:
|
||||
nodeObject = Instantiate(animatorPrefab.gameObject);
|
||||
nodeObject = Instantiate(animatorPrefab.gameObject,parent.transform);
|
||||
ITick tick = nodeObject.GetComponent<SpriteAnimator>();
|
||||
if (tick != null)
|
||||
bodyNode[currentOrientation].Add(tick);
|
||||
bodyAnimationNode[currentOrientation].Add(tick);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
nodeObject.transform.localPosition = drawNode.position;
|
||||
// 递归初始化子节点
|
||||
foreach (var child in drawNode.children)
|
||||
{
|
||||
@ -113,9 +123,9 @@ namespace Entity
|
||||
AutoBehave();
|
||||
}
|
||||
|
||||
foreach (var bodyPart in bodyNode.Values)
|
||||
if (bodyAnimationNode.TryGetValue(currentOrientation, out var ticks))
|
||||
{
|
||||
foreach (var tick in bodyPart)
|
||||
foreach (var tick in ticks)
|
||||
{
|
||||
tick.Tick();
|
||||
}
|
||||
@ -126,12 +136,19 @@ namespace Entity
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void SetOrientation(Orientation orientation)
|
||||
{
|
||||
bodyNodes[currentOrientation]?.SetActive(false);
|
||||
currentOrientation = orientation;
|
||||
bodyNodes[orientation]?.SetActive(true);
|
||||
}
|
||||
/// <summary>
|
||||
/// 往对应朝向移动moveSpeed*deltaTime的距离
|
||||
/// </summary>
|
||||
public virtual void TryMove()
|
||||
{
|
||||
transform.position+=direction * (attributes.moveSpeed * Time.deltaTime * (IsChase ? 1 : 0.5f));
|
||||
transform.position += direction * (attributes.moveSpeed * Time.deltaTime * (IsChase ? 1 : 0.5f));
|
||||
}
|
||||
|
||||
public virtual void OnHit(Entity from)
|
||||
@ -156,6 +173,8 @@ namespace Entity
|
||||
|
||||
private void AutoBehave()
|
||||
{
|
||||
if(aiTree == null)
|
||||
return;
|
||||
if (currentJob == null || !currentJob.Running)
|
||||
{
|
||||
currentJob = aiTree.GetJob(this);
|
||||
|
@ -14,9 +14,11 @@ namespace Managers
|
||||
public class DefineManager : Singleton<DefineManager>
|
||||
{
|
||||
private static readonly string[] dataSetFilePath = { "Data", "Mods" };
|
||||
|
||||
//类别,定义名,定义
|
||||
public Dictionary<string, Dictionary<string, Define>> defines = new();
|
||||
//包id,包
|
||||
public Dictionary<string, DefinePack> packs = new();
|
||||
//类别,定义
|
||||
public Dictionary<string, List<Define>> anonymousDefines = new();
|
||||
/// <summary>
|
||||
/// 初始化定义管理器,加载所有定义包并构建定义字典。
|
||||
@ -46,12 +48,14 @@ namespace Managers
|
||||
Dictionary<Type, FieldInfo[]> fieldCache = new();
|
||||
// 需要链接的定义、需要链接的字段、链接信息
|
||||
List<Tuple<Define, FieldInfo, Define>> defineCache = new();
|
||||
|
||||
string currentPackID = string.Empty;
|
||||
|
||||
void ProcessDefine(Define def)
|
||||
{
|
||||
if (def == null || def.isReferene)
|
||||
return;
|
||||
|
||||
def.packID = currentPackID;
|
||||
// 如果字段信息已经缓存,则直接使用缓存
|
||||
if (!fieldCache.TryGetValue(def.GetType(), out var defineFields))
|
||||
{
|
||||
@ -89,11 +93,12 @@ namespace Managers
|
||||
|
||||
foreach (var pack in packs)
|
||||
{
|
||||
currentPackID = pack.Value.packID;
|
||||
foreach (var (typeName, defList) in pack.Value.defines)
|
||||
{
|
||||
if (!defines.ContainsKey(typeName))
|
||||
defines[typeName] = new Dictionary<string, Define>();
|
||||
|
||||
|
||||
foreach (var def in defList)
|
||||
{
|
||||
defines[typeName][def.defName] = def;
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Base;
|
||||
@ -12,6 +13,8 @@ namespace Managers
|
||||
|
||||
public GameObject entityLevel;
|
||||
public EntityPrefab entityPrefab;
|
||||
|
||||
public EntityPrefab defaultEntityPrefab;
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
@ -57,6 +60,7 @@ namespace Managers
|
||||
if (entityPrefab == null)
|
||||
{
|
||||
Debug.LogError("Error: entityPrefab is null. Please assign a valid prefab.");
|
||||
GenerateDefaultEntity(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,6 +68,7 @@ namespace Managers
|
||||
if (pawnDef == null)
|
||||
{
|
||||
Debug.LogError("Error: PawnDef is null. Cannot generate entity without a valid PawnDef.");
|
||||
GenerateDefaultEntity(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,6 +84,7 @@ namespace Managers
|
||||
if (entityComponent == null)
|
||||
{
|
||||
Debug.LogError($"Error: EntityPrefab component not found on the instantiated object: {entity.name}");
|
||||
GenerateDefaultEntity(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -96,12 +102,32 @@ namespace Managers
|
||||
{
|
||||
// 捕获并记录任何异常
|
||||
Debug.LogError($"An error occurred while generating the entity: {ex.Message}");
|
||||
GenerateDefaultEntity(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateDefaultEntity(Vector3 pos)
|
||||
{
|
||||
var entity = Instantiate(entityPrefab.gameObject, pos, Quaternion.identity, entityLevel.transform);
|
||||
var entityComponent = entity.GetComponent<EntityPrefab>();
|
||||
const string factionKey = "default";
|
||||
if (!factionEntities.ContainsKey(factionKey))
|
||||
{
|
||||
factionEntities[factionKey] = new List<EntityPrefab>();
|
||||
}
|
||||
factionEntities[factionKey].Add(entityComponent);
|
||||
}
|
||||
protected override void OnStart()
|
||||
{
|
||||
factionEntities.Clear();
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var pre = Resources.Load<GameObject>("Default/DefaultEntity");
|
||||
defaultEntityPrefab = pre.GetComponent<EntityPrefab>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Data;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Managers
|
||||
@ -8,17 +10,25 @@ namespace Managers
|
||||
public class PackagesImageManager : Utils.Singleton<PackagesImageManager>
|
||||
{
|
||||
public Sprite defaultSprite;
|
||||
|
||||
//包名,图片名
|
||||
public Dictionary<string, Dictionary<string, Texture2D>> packagesImages = new();
|
||||
//包名,图片名
|
||||
public Dictionary<string, Dictionary<string, Sprite>> sprites = new();
|
||||
|
||||
//包名,文件路径,身体部件名
|
||||
public Dictionary<string, Dictionary<string, Dictionary<string, List<Sprite>>>> bodyTexture = new();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (packagesImages.Count > 0)
|
||||
return;
|
||||
defaultSprite = Resources.Load<Sprite>("Default/DefaultImage");
|
||||
if(defaultSprite)
|
||||
Debug.Log("加载成功");
|
||||
InitImageDef();
|
||||
InitDrawOrder();
|
||||
packagesImages = null;
|
||||
}
|
||||
|
||||
public void InitImageDef()
|
||||
{
|
||||
var imageDef = Managers.DefineManager.Instance.QueryDefinesByType<ImageDef>();
|
||||
foreach (var ima in imageDef)
|
||||
{
|
||||
@ -38,6 +48,44 @@ namespace Managers
|
||||
|
||||
SplitTextureIntoSprites(packId, ima.name, texture, ima.hCount, ima.wCount, ima.pixelsPerUnit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void InitDrawOrder()
|
||||
{
|
||||
var drawOrderDef = Managers.DefineManager.Instance.QueryDefinesByType<DrawingOrderDef>();
|
||||
if (drawOrderDef == null || drawOrderDef.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Dictionary<string, string> packRootSite = new();
|
||||
foreach (var drawOrder in drawOrderDef)
|
||||
{
|
||||
if (string.IsNullOrEmpty(drawOrder.texturePath) || string.IsNullOrEmpty(drawOrder.packID))
|
||||
continue;
|
||||
if (!packRootSite.ContainsKey(drawOrder.packID))
|
||||
packRootSite[drawOrder.packID] = Managers.DefineManager.Instance.GetPackagePath(drawOrder.packID);
|
||||
var rootPath= packRootSite[drawOrder.packID];
|
||||
var folderPath=Path.Combine(rootPath, drawOrder.texturePath);
|
||||
var imagePath = Configs.ConfigProcessor.GetFilesByExtensions(folderPath,
|
||||
new[]
|
||||
{
|
||||
"jpg", "jpeg", "png", "tga", "tif", "tiff", "psd", "bmp"
|
||||
});
|
||||
foreach (var path in imagePath)
|
||||
{
|
||||
var image=Configs.ConfigProcessor.LoadTextureByIO(path);
|
||||
if (image == null)
|
||||
continue;
|
||||
var spr=Sprite.Create(
|
||||
image,
|
||||
new Rect(0, 0, image.width, image.height),
|
||||
new Vector2(0.5f, 0.5f) // 中心点
|
||||
);
|
||||
var name=Path.GetFileNameWithoutExtension(path);
|
||||
InsertBodySprite(drawOrder.packID, drawOrder.texturePath, name, spr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SplitTextureIntoSprites(
|
||||
@ -131,5 +179,35 @@ namespace Managers
|
||||
var fullName = $"{name}_{index}";
|
||||
return GetSprite(packID, fullName);
|
||||
}
|
||||
/// <summary>
|
||||
/// 插入 Sprite 到指定的嵌套字典中。
|
||||
/// </summary>
|
||||
/// <param name="packageName">包名。</param>
|
||||
/// <param name="filePath">文件路径。</param>
|
||||
/// <param name="bodyPartName">身体部件名。</param>
|
||||
/// <param name="sprite">要插入的 Sprite 对象。</param>
|
||||
public void InsertBodySprite(string packageName, string filePath, string bodyPartName, Sprite sprite)
|
||||
{
|
||||
// 确保第一层字典(包名)存在
|
||||
if (!bodyTexture.ContainsKey(packageName))
|
||||
{
|
||||
bodyTexture[packageName] = new Dictionary<string, Dictionary<string, List<Sprite>>>();
|
||||
}
|
||||
|
||||
// 确保第二层字典(文件路径)存在
|
||||
if (!bodyTexture[packageName].ContainsKey(filePath))
|
||||
{
|
||||
bodyTexture[packageName][filePath] = new Dictionary<string, List<Sprite>>();
|
||||
}
|
||||
|
||||
// 确保第三层字典(身体部件名)存在
|
||||
if (!bodyTexture[packageName][filePath].ContainsKey(bodyPartName))
|
||||
{
|
||||
bodyTexture[packageName][filePath][bodyPartName] = new List<Sprite>();
|
||||
}
|
||||
|
||||
// 将 Sprite 添加到列表中
|
||||
bodyTexture[packageName][filePath][bodyPartName].Add(sprite);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,142 +3,42 @@ using UnityEngine;
|
||||
|
||||
namespace Prefab
|
||||
{
|
||||
[RequireComponent(typeof(SpriteRenderer))]
|
||||
|
||||
[RequireComponent(typeof(SpriteRenderer))]
|
||||
public class ImagePrefab : MonoBehaviour
|
||||
{
|
||||
[Header("Display Settings")] [SerializeField]
|
||||
private Sprite _defaultSprite;
|
||||
public Sprite defaultSprite;
|
||||
|
||||
[SerializeField] private Color _tintColor = Color.white;
|
||||
[SerializeField, Range(0, 1)] private float _alpha = 1f;
|
||||
[SerializeField] private bool _preserveAspect = true;
|
||||
|
||||
private SpriteRenderer _renderer;
|
||||
private Vector2 _originalSize;
|
||||
private bool _isInitialized;
|
||||
|
||||
public Sprite DisplayedSprite => _renderer.sprite;
|
||||
public Color CurrentColor => _renderer.color;
|
||||
private SpriteRenderer spriteRenderer;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitializeRenderer();
|
||||
}
|
||||
|
||||
private void InitializeRenderer()
|
||||
{
|
||||
if (_isInitialized) return;
|
||||
|
||||
_renderer = GetComponent<SpriteRenderer>();
|
||||
|
||||
// 初始尺寸记录
|
||||
if (_defaultSprite != null)
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
if (spriteRenderer == null)
|
||||
{
|
||||
_originalSize = new Vector2(
|
||||
_defaultSprite.rect.width / _defaultSprite.pixelsPerUnit,
|
||||
_defaultSprite.rect.height / _defaultSprite.pixelsPerUnit
|
||||
);
|
||||
Debug.LogError("SpriteRenderer组件未找到,请确保预制体包含该组件!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置初始状态
|
||||
ApplyVisualSettings();
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
private void ApplyVisualSettings()
|
||||
{
|
||||
if (!_isInitialized) InitializeRenderer();
|
||||
|
||||
// 设置精灵和颜色
|
||||
_renderer.sprite = _defaultSprite;
|
||||
_renderer.color = new Color(_tintColor.r, _tintColor.g, _tintColor.b, _alpha);
|
||||
|
||||
// 保持原始纵横比
|
||||
if (_preserveAspect && _defaultSprite != null)
|
||||
if (defaultSprite != null)
|
||||
{
|
||||
MaintainAspectRatio();
|
||||
spriteRenderer.sprite = defaultSprite;
|
||||
}
|
||||
}
|
||||
|
||||
private void MaintainAspectRatio()
|
||||
{
|
||||
Vector2 currentSize = transform.lossyScale;
|
||||
float aspectRatio = _originalSize.x / _originalSize.y;
|
||||
|
||||
if (currentSize.x == 0 || currentSize.y == 0) return;
|
||||
|
||||
float currentAspect = currentSize.x / currentSize.y;
|
||||
|
||||
if (Mathf.Abs(currentAspect - aspectRatio) > 0.01f)
|
||||
{
|
||||
Vector2 newScale = currentSize;
|
||||
if (currentAspect > aspectRatio)
|
||||
{
|
||||
newScale.x = currentSize.y * aspectRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
newScale.y = currentSize.x / aspectRatio;
|
||||
}
|
||||
|
||||
transform.localScale = newScale;
|
||||
}
|
||||
}
|
||||
|
||||
// 公共控制方法
|
||||
public void SetSprite(Sprite newSprite)
|
||||
{
|
||||
_defaultSprite = newSprite;
|
||||
if (_defaultSprite != null)
|
||||
if (spriteRenderer != null && newSprite != null)
|
||||
{
|
||||
_originalSize = new Vector2(
|
||||
_defaultSprite.rect.width / _defaultSprite.pixelsPerUnit,
|
||||
_defaultSprite.rect.height / _defaultSprite.pixelsPerUnit
|
||||
);
|
||||
spriteRenderer.sprite = newSprite;
|
||||
}
|
||||
|
||||
ApplyVisualSettings();
|
||||
}
|
||||
|
||||
public void SetColor(Color newColor)
|
||||
{
|
||||
_tintColor = newColor;
|
||||
ApplyVisualSettings();
|
||||
}
|
||||
|
||||
public void SetAlpha(float newAlpha)
|
||||
{
|
||||
_alpha = Mathf.Clamp01(newAlpha);
|
||||
ApplyVisualSettings();
|
||||
}
|
||||
|
||||
public void ToggleVisibility(bool isVisible)
|
||||
{
|
||||
if (!_isInitialized) InitializeRenderer();
|
||||
_renderer.enabled = isVisible;
|
||||
}
|
||||
|
||||
public void SetSortingLayer(string layerName, int order)
|
||||
{
|
||||
if (!_isInitialized) InitializeRenderer();
|
||||
_renderer.sortingLayerName = layerName;
|
||||
_renderer.sortingOrder = order;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
// 编辑器模式下实时预览变化
|
||||
if (UnityEditor.EditorApplication.isPlaying)
|
||||
if (spriteRenderer != null)
|
||||
{
|
||||
ApplyVisualSettings();
|
||||
}
|
||||
else if (GetComponent<SpriteRenderer>() != null)
|
||||
{
|
||||
GetComponent<SpriteRenderer>().sprite = _defaultSprite;
|
||||
GetComponent<SpriteRenderer>().color = new Color(_tintColor.r, _tintColor.g, _tintColor.b, _alpha);
|
||||
spriteRenderer.color = newColor;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@ -13,12 +13,14 @@ namespace Test
|
||||
void Awake()
|
||||
{
|
||||
Managers.DefineManager.Instance.Init();
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var chicken = Managers.DefineManager.Instance.FindDefine<CharacterDef>("testPawn");
|
||||
entityManager.GenerateEntity(chicken,Vector3.zero);
|
||||
entityManager.GenerateDefaultEntity(Vector3.down);
|
||||
Debug.Log(chicken);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
<!-- 2 + (1 * 4) = 6 -->
|
||||
<Dirt_Dirt_Dirt_Grass value="GrassDirt_13"/>
|
||||
<!-- 1 + (3 * 4) = 13 -->
|
||||
<Dirt_Dirt_Grass_Dirt value="GrassDirt_110"/>
|
||||
<Dirt_Dirt_Grass_Dirt value="GrassDirt_0"/>
|
||||
<!-- 0 + (0 * 4) = 0 -->
|
||||
<Dirt_Grass_Dirt_Dirt value="GrassDirt_8"/>
|
||||
<!-- 0 + (2 * 4) = 8 -->
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Reference in New Issue
Block a user