动画测试

This commit is contained in:
2025-12-31 15:26:51 +08:00
parent c2958767e0
commit 3e3efcd713
9 changed files with 575 additions and 18 deletions
@@ -311,9 +311,10 @@ namespace AibisDream.SystemEditor
row = frameIndex % manualData.layout.rows;
}
// Unity Y轴从下往上,需要转换
// 使用左上角为(0,0)的坐标系,向右向下为正轴
// 在SliceSprites中会统一转换为Unity的左下角坐标系
int x = column * spriteWidth;
int y = (manualData.layout.rows - 1 - row) * spriteHeight;
int y = row * spriteHeight;
frames.Add(new FrameData
{
@@ -360,6 +361,14 @@ namespace AibisDream.SystemEditor
throw new Exception($"无法加载纹理导入器: {texturePath}");
}
// 获取纹理尺寸
Texture2D texture = AssetDatabase.LoadAssetAtPath<Texture2D>(texturePath);
if (texture == null)
{
throw new Exception($"无法加载纹理: {texturePath}");
}
int textureHeight = texture.height;
// 设置spriteMode为Multiple
textureImporter.spriteImportMode = SpriteImportMode.Multiple;
@@ -376,14 +385,22 @@ namespace AibisDream.SystemEditor
dataProvider.InitSpriteEditorDataProvider();
// 创建SpriteRect数组
// 注意:JSON中的坐标是以左上角为(0,0),向右向下为正轴
// Unity的纹理坐标系统是左下角为(0,0),向上为正轴
// 需要将Y坐标从左上角坐标系转换为Unity的左下角坐标系
var spriteRects = new SpriteRect[frames.Count];
for (int i = 0; i < frames.Count; i++)
{
var frame = frames[i];
// 坐标转换:从左上角(0,0)坐标系转换为Unity左下角(0,0)坐标系
// Unity Y = 纹理高度 - (原始Y + 高度)
float unityY = textureHeight - (frame.y + frame.height);
spriteRects[i] = new SpriteRect
{
name = frame.name,
rect = new Rect(frame.x, frame.y, frame.width, frame.height),
rect = new Rect(frame.x, unityY, frame.width, frame.height),
pivot = new Vector2(0.5f, 0.5f),
alignment = SpriteAlignment.Center
};
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3668d657c7a3bf24ebd242e027ac8be5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,100 @@
{ "frames": {
"说话到俯身 0.aseprite": {
"frame": { "x": 0, "y": 0, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 300
},
"说话到俯身 1.aseprite": {
"frame": { "x": 74, "y": 0, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 200
},
"说话到俯身 2.aseprite": {
"frame": { "x": 148, "y": 0, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 50
},
"说话到俯身 3.aseprite": {
"frame": { "x": 222, "y": 0, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 200
},
"说话到俯身 4.aseprite": {
"frame": { "x": 296, "y": 0, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 400
},
"说话到俯身 5.aseprite": {
"frame": { "x": 370, "y": 0, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 400
},
"说话到俯身 6.aseprite": {
"frame": { "x": 0, "y": 150, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 200
},
"说话到俯身 7.aseprite": {
"frame": { "x": 74, "y": 150, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 50
},
"说话到俯身 8.aseprite": {
"frame": { "x": 148, "y": 150, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 200
},
"说话到俯身 9.aseprite": {
"frame": { "x": 222, "y": 150, "w": 74, "h": 150 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 74, "h": 150 },
"sourceSize": { "w": 74, "h": 150 },
"duration": 300
}
},
"meta": {
"app": "http://www.aseprite.org/",
"version": "1.2.15-x64",
"image": "说话到俯身.png",
"format": "RGBA8888",
"size": { "w": 444, "h": 300 },
"scale": "1",
"frameTags": [
{ "name": "俯身动作", "from": 0, "to": 4, "direction": "forward" },
{ "name": "起身动作", "from": 5, "to": 9, "direction": "forward" }
],
"layers": [
{ "name": "调酒妹", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 944e7573992316248b78ac840803dbd8
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,386 @@
fileFormatVersion: 2
guid: 25ade8fcabe12234e947eb2fd1faf797
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
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: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 21.5
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: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
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: 3
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
- serializedVersion: 3
buildTarget: iPhone
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: 3
buildTarget: Android
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: 3
buildTarget: Server
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:
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 0.aseprite"
rect:
serializedVersion: 2
x: 0
y: 0
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: f2058f29631b2f445bc542ada9fdadb2
internalID: -8686660269677207458
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 1.aseprite"
rect:
serializedVersion: 2
x: 74
y: 0
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: b960f4e94016df547af73d87819977cf
internalID: 4571778429836060549
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 2.aseprite"
rect:
serializedVersion: 2
x: 148
y: 0
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: bfcfc0fb1e1ed294994067c8f8132c9c
internalID: 5925744834341221605
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 3.aseprite"
rect:
serializedVersion: 2
x: 222
y: 0
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: b6e654eb37b6b2d4cae3bb958f0adab3
internalID: 3417067792297643795
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 4.aseprite"
rect:
serializedVersion: 2
x: 296
y: 0
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 3f9d2823f7012ca4e8a96defe32a3200
internalID: 8029721251602746815
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 5.aseprite"
rect:
serializedVersion: 2
x: 370
y: 0
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 2ae1742578194e44c83501f2fa9bc3a2
internalID: 7719310255684422536
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 6.aseprite"
rect:
serializedVersion: 2
x: 0
y: 150
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 44d6d2426b7f93244b8d8b26d64ee4b4
internalID: -6190755443841108145
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 7.aseprite"
rect:
serializedVersion: 2
x: 74
y: 150
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: ef64a93386141ea4d848035cdaa20607
internalID: -8109228470294260414
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 8.aseprite"
rect:
serializedVersion: 2
x: 148
y: 150
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 851642b09a6819444ad98700242947c2
internalID: 6617401414338900246
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: "\u8BF4\u8BDD\u5230\u4FEF\u8EAB 9.aseprite"
rect:
serializedVersion: 2
x: 222
y: 150
width: 74
height: 150
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: fc0efc83b1147cc4e91394cfc42726e4
internalID: 245859675350752340
vertices: []
indices:
edges: []
weights: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable:
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 0.aseprite": -8686660269677207458
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 1.aseprite": 4571778429836060549
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 2.aseprite": 5925744834341221605
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 3.aseprite": 3417067792297643795
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 4.aseprite": 8029721251602746815
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 5.aseprite": 7719310255684422536
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 6.aseprite": -6190755443841108145
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 7.aseprite": -8109228470294260414
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 8.aseprite": 6617401414338900246
"\u8BF4\u8BDD\u5230\u4FEF\u8EAB 9.aseprite": 245859675350752340
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: "\u8C03\u9152\u59B9\u5BF9\u8BDD"
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 6533160500192696812}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1107 &6533160500192696812
AnimatorStateMachine:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates: []
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 0}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f26e5dcbc809104f92f908082de97d5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:
-15
View File
@@ -134,7 +134,6 @@ GameObject:
- component: {fileID: 141893930}
- component: {fileID: 141893932}
- component: {fileID: 141893931}
- component: {fileID: 141893933}
m_Layer: 0
m_Name: Square
m_TagString: Untagged
@@ -230,20 +229,6 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &141893933
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 141893929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: afdf87b8c3a300f42a3ab020c3551837, type: 3}
m_Name:
m_EditorClassIdentifier:
talkSpeed: 1
animator: {fileID: 141893931}
--- !u!1 &1618964974
GameObject:
m_ObjectHideFlags: 0