mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2026-03-22 12:55:32 +07:00
load flash matrix
This commit is contained in:
@@ -38,6 +38,34 @@ namespace FlashTools {
|
||||
MovieClip
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct FlashAnimMatrix {
|
||||
public float a;
|
||||
public float b;
|
||||
public float c;
|
||||
public float d;
|
||||
public float tx;
|
||||
public float ty;
|
||||
public FlashAnimMatrix(
|
||||
float a, float b, float c, float d,
|
||||
float tx, float ty)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
}
|
||||
static public FlashAnimMatrix identity {
|
||||
get {
|
||||
return new FlashAnimMatrix(
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FlashAnimBitmapData {
|
||||
public string Id = string.Empty;
|
||||
@@ -58,7 +86,7 @@ namespace FlashTools {
|
||||
public class FlashAnimElemData {
|
||||
public string Id = string.Empty;
|
||||
public int Depth = 0;
|
||||
public Matrix4x4 Matrix = Matrix4x4.identity;
|
||||
public FlashAnimMatrix Matrix = FlashAnimMatrix.identity;
|
||||
public List<FlashAnimInstData> Insts = new List<FlashAnimInstData>();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Globalization;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
public class FlashAnimPostprocessor : AssetPostprocessor {
|
||||
@@ -179,8 +180,22 @@ namespace FlashTools.Internal {
|
||||
return def_value;
|
||||
}
|
||||
|
||||
static Matrix4x4 SafeLoadMatFromElemAttr(XElement elem, string attr_name, Matrix4x4 def_value) {
|
||||
// TODO: implme
|
||||
static FlashAnimMatrix SafeLoadMatFromElemAttr(XElement elem, string attr_name, FlashAnimMatrix def_value) {
|
||||
var mat_str = SafeLoadStrFromElemAttr(elem, attr_name, "");
|
||||
var mat_strs = mat_str.Split(';');
|
||||
if ( mat_strs.Length == 6 ) {
|
||||
float a, b, c, d, tx, ty;
|
||||
if (
|
||||
float.TryParse(mat_strs[0], NumberStyles.Any, CultureInfo.InvariantCulture, out a ) &&
|
||||
float.TryParse(mat_strs[1], NumberStyles.Any, CultureInfo.InvariantCulture, out b ) &&
|
||||
float.TryParse(mat_strs[2], NumberStyles.Any, CultureInfo.InvariantCulture, out c ) &&
|
||||
float.TryParse(mat_strs[3], NumberStyles.Any, CultureInfo.InvariantCulture, out d ) &&
|
||||
float.TryParse(mat_strs[4], NumberStyles.Any, CultureInfo.InvariantCulture, out tx) &&
|
||||
float.TryParse(mat_strs[5], NumberStyles.Any, CultureInfo.InvariantCulture, out ty) )
|
||||
{
|
||||
return new FlashAnimMatrix(a, b, c, d, tx, ty);
|
||||
}
|
||||
}
|
||||
return def_value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user