mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2026-01-06 08:26:52 +07:00
little optimize asset size of disk
This commit is contained in:
@@ -31,10 +31,10 @@ namespace FlashTools.Internal {
|
||||
asset.Atlas = atlas_asset;
|
||||
ConfigureAtlas(asset);
|
||||
ConfigureClips(asset);
|
||||
ConfigureAssetClips(asset);
|
||||
EditorUtility.SetDirty(asset);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
ConfigureAssetClips(asset);
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat(
|
||||
"Postprocess swf asset error: {0}",
|
||||
@@ -230,7 +230,7 @@ namespace FlashTools.Internal {
|
||||
+1.0f / asset.Settings.PixelsPerUnit,
|
||||
-1.0f / asset.Settings.PixelsPerUnit,
|
||||
+1.0f / asset.Settings.PixelsPerUnit)) *
|
||||
inst.Matrix;
|
||||
inst.Matrix.ToUnityMatrix();
|
||||
|
||||
baked_vertices.Add(matrix.MultiplyPoint3x4(v0));
|
||||
baked_vertices.Add(matrix.MultiplyPoint3x4(v1));
|
||||
@@ -315,6 +315,7 @@ namespace FlashTools.Internal {
|
||||
mesh.SetUVs(1, baked_addcolors);
|
||||
mesh.SetColors(baked_mulcolors);
|
||||
mesh.RecalculateNormals();
|
||||
mesh.Optimize();
|
||||
|
||||
return new SwfClipAsset.Frame{
|
||||
Mesh = mesh,
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace FlashTools.Internal {
|
||||
Type = frame_inst_type,
|
||||
ClipDepth = (ushort)frame_inst_clip_depth,
|
||||
Bitmap = bitmap_id,
|
||||
Matrix = child_matrix * bitmap_matrix.ToUnityMatrix(),
|
||||
Matrix = SwfMatrixData.FromUnityMatrix(child_matrix * bitmap_matrix.ToUnityMatrix()),
|
||||
ColorTrans = child_color_transform});
|
||||
if ( parent_mask > 0 ) {
|
||||
parent_masks.Add(frame.Instances[frame.Instances.Count - 1]);
|
||||
|
||||
@@ -3,6 +3,49 @@ using FlashTools.Internal;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools {
|
||||
[System.Serializable]
|
||||
public struct SwfMatrixData {
|
||||
public float ScX;
|
||||
public float ScY;
|
||||
public float SkX;
|
||||
public float SkY;
|
||||
public float TrX;
|
||||
public float TrY;
|
||||
|
||||
public static SwfMatrixData identity {
|
||||
get {
|
||||
return new SwfMatrixData{
|
||||
ScX = 1.0f,
|
||||
ScY = 1.0f,
|
||||
SkX = 0.0f,
|
||||
SkY = 0.0f,
|
||||
TrX = 0.0f,
|
||||
TrY = 0.0f};
|
||||
}
|
||||
}
|
||||
|
||||
public static SwfMatrixData FromUnityMatrix(Matrix4x4 mat) {
|
||||
return new SwfMatrixData{
|
||||
ScX = mat.m00,
|
||||
ScY = mat.m11,
|
||||
SkX = mat.m10,
|
||||
SkY = mat.m01,
|
||||
TrX = mat.m03,
|
||||
TrY = mat.m13};
|
||||
}
|
||||
|
||||
public Matrix4x4 ToUnityMatrix() {
|
||||
var mat = Matrix4x4.identity;
|
||||
mat.m00 = ScX;
|
||||
mat.m11 = ScY;
|
||||
mat.m10 = SkX;
|
||||
mat.m01 = SkY;
|
||||
mat.m03 = TrX;
|
||||
mat.m13 = TrY;
|
||||
return mat;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SwfColorTransData {
|
||||
public Vector4 Mul;
|
||||
@@ -44,7 +87,7 @@ namespace FlashTools {
|
||||
public Types Type = Types.Group;
|
||||
public ushort ClipDepth = 0;
|
||||
public ushort Bitmap = 0;
|
||||
public Matrix4x4 Matrix = Matrix4x4.identity;
|
||||
public SwfMatrixData Matrix = SwfMatrixData.identity;
|
||||
public SwfColorTransData ColorTrans = SwfColorTransData.identity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user