mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2026-03-22 04:44:08 +07:00
little clear code
This commit is contained in:
@@ -80,23 +80,28 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
|
||||
static SwfAnimationFrameData AddDisplayListToFrame(
|
||||
SwfContext ctx, SwfDisplayList dl,
|
||||
ushort parent_depth, ushort parent_clip_depth, Matrix4x4 parent_matrix, SwfAnimationColorTransform parent_color_transform,
|
||||
SwfAnimationFrameData frame)
|
||||
SwfContext ctx,
|
||||
SwfDisplayList dl,
|
||||
ushort parent_depth,
|
||||
ushort parent_clip_depth,
|
||||
Matrix4x4 parent_matrix,
|
||||
SwfAnimationColorTransform parent_color_transform,
|
||||
SwfAnimationFrameData frame)
|
||||
{
|
||||
foreach ( var inst in dl.Instances.Values.Where(p => p.Visible) ) {
|
||||
var instances = dl.Instances.Values
|
||||
.Where(p => p.Visible);
|
||||
foreach ( var inst in instances ) {
|
||||
switch ( inst.Type ) {
|
||||
case SwfDisplayInstanceType.Shape:
|
||||
var shape_def = ctx.Library.FindDefine<SwfLibraryShapeDefine>(inst.Id);
|
||||
if ( shape_def != null ) {
|
||||
for ( var i = 0; i < shape_def.Bitmaps.Length; ++i ) {
|
||||
var bitmap_id = shape_def.Bitmaps[i];
|
||||
var bitmap_matrix = i < shape_def.Matrices.Length
|
||||
? shape_def.Matrices[i] : SwfMatrix.identity;
|
||||
var bitmap_def = ctx.Library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
|
||||
var bitmap_matrix = i < shape_def.Matrices.Length ? shape_def.Matrices[i] : SwfMatrix.identity;
|
||||
var bitmap_def = ctx.Library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
|
||||
if ( bitmap_def != null ) {
|
||||
frame.Instances.Add(new SwfAnimationInstanceData{
|
||||
Depth = (ushort)(parent_depth + inst.Depth - 1),
|
||||
Depth = (ushort)(parent_depth + inst.Depth),
|
||||
ClipDepth = (ushort)(parent_clip_depth != 0 ? parent_clip_depth : inst.ClipDepth),
|
||||
Bitmap = bitmap_id,
|
||||
Matrix = parent_matrix * inst.Matrix.ToUnityMatrix() * bitmap_matrix.ToUnityMatrix(),
|
||||
@@ -112,7 +117,7 @@ namespace FlashTools.Internal {
|
||||
AddDisplayListToFrame(
|
||||
ctx,
|
||||
sprite_inst.DisplayList,
|
||||
(ushort)(parent_depth + sprite_inst.Depth),
|
||||
(ushort)(parent_depth + sprite_inst.Depth - 1),
|
||||
(ushort)(parent_clip_depth != 0 ? parent_clip_depth : sprite_inst.ClipDepth),
|
||||
parent_matrix * sprite_inst.Matrix.ToUnityMatrix(),
|
||||
parent_color_transform * sprite_inst.ColorTransform.ToAnimationColorTransform(),
|
||||
@@ -121,7 +126,7 @@ namespace FlashTools.Internal {
|
||||
break;
|
||||
default:
|
||||
throw new UnityException(string.Format(
|
||||
"Unsupported SwfDisplayInstType: {0}", inst.Type));
|
||||
"Unsupported SwfDisplayInstanceType: {0}", inst.Type));
|
||||
}
|
||||
}
|
||||
return frame;
|
||||
@@ -174,4 +179,4 @@ namespace FlashTools.Internal {
|
||||
return Path.ChangeExtension(swf_asset, ".png");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ namespace FlashTools.Internal.SwfTools {
|
||||
void AddShapesToLibrary(ushort define_id, SwfShapesWithStyle shapes) {
|
||||
var bitmap_styles = shapes.FillStyles.Where(p => p.Type.IsBitmapType);
|
||||
var define = new SwfLibraryShapeDefine{
|
||||
Bitmaps = bitmap_styles.Select(p => p.BitmapId).ToArray(),
|
||||
Bitmaps = bitmap_styles.Select(p => p.BitmapId ).ToArray(),
|
||||
Matrices = bitmap_styles.Select(p => p.BitmapMatrix).ToArray()
|
||||
};
|
||||
MainContex.Library.Defines.Add(define_id, define);
|
||||
|
||||
@@ -73,4 +73,4 @@ namespace FlashTools {
|
||||
public int AtlasPadding = 1;
|
||||
public int PixelsPerUnit = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user