Compare commits

..

22 Commits

Author SHA1 Message Date
bee56e75a9 Fix undefined unusedItems in CS6 2017-02-13 19:59:49 +07:00
7ba00a7e9a undefined unusedItems in CS6 2017-02-13 19:51:49 +07:00
545eacdaf8 Added tag versions/1.3.2 for changeset f4c5c42402d6 2017-02-13 18:09:58 +07:00
ad0e6251e8 Fix bug custom scale export with small items optimization 2017-02-13 18:09:38 +07:00
6f4f11cc9d update dll project 2017-02-12 23:18:43 +07:00
7e4bd5b159 asset store tools ignore 2017-02-12 23:05:56 +07:00
2d8bd13384 Added tag versions/1.3.1 for changeset f9309c819e42 2017-02-12 22:57:27 +07:00
fa8a636d2e 1.3.1 2017-02-12 22:57:13 +07:00
27bb4ef58d unity 5.5 fixes 2017-02-12 22:33:42 +07:00
ece15d9ada Added tag versions/1.3.0 for changeset b598c4685a02 2017-02-12 22:08:14 +07:00
bc8d6c890a 1.3.0 2017-02-12 22:07:47 +07:00
f12f2f9012 new small vector scaled items optimization 2017-02-12 21:57:23 +07:00
c6f86098e2 dev animations 2017-02-12 18:37:07 +07:00
cc8677e61f more unsupported tags 2017-02-12 18:36:03 +07:00
0386992965 added note message about problems of animation in preview 2017-02-12 18:18:46 +07:00
a19ca2499f reconvert example animations 2017-02-12 17:25:01 +07:00
ce4611e23b Export animations with custom scale (for retina) 2017-02-12 17:18:33 +07:00
99d4236e13 ETC1 support 2017-02-12 10:24:32 +07:00
04ddf0d08e more beautiful progress bar 2017-02-12 09:04:09 +07:00
77287a9b4a new dev animation 2017-02-11 23:25:38 +07:00
5b26becc27 some ping objects 2017-02-11 22:40:50 +07:00
1084c839a1 Added tag versions/1.2.0 for changeset 17333d65ec3f 2017-02-11 21:14:58 +07:00
49 changed files with 437 additions and 112 deletions

View File

@@ -2,6 +2,9 @@ glob:obj/*
glob:Temp/*
glob:Library/*
glob:AssetStoreTools/*
glob:AssetStoreTools.meta
glob:.DS_Store
glob:unityflash.sln
glob:unityflash.userprefs

Binary file not shown.

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 936cd155c254c405cbfaa7caf5447e69
timeCreated: 1486882364
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 55c438c941e894f25bb2b0527ee72f7c
timeCreated: 1486989506
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 672cf0095a3044ff298e605979974aa6
timeCreated: 1486823787
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -145,7 +145,7 @@ Camera:
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 1.5
orthographic size: 3
m_Depth: 0
m_CullingMask:
serializedVersion: 2

View File

@@ -1,3 +1,29 @@
-------------------
-- Version 1.3.3 --
-------------------
Fix undefined unusedItems in CS6
-------------------
-- Version 1.3.2 --
-------------------
Fix bug custom scale export with small items optimization
-------------------
-- Version 1.3.1 --
-------------------
Fix some Unity 5.5 deprecated functions
-------------------
-- Version 1.3.0 --
-------------------
ETC separated alpha support
Export animations with custom scale (for retina)
New small vector scaled items optimization
-------------------
-- Version 1.2.0 --
-------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: e336e165518cf4d8680e2fff9c6b59ba
timeCreated: 1476531185
timeCreated: 1486894953
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
@@ -37,8 +37,7 @@ TextureImporter:
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Name: npc_bureaucrat.fla._Stage_
m_EditorClassIdentifier:
Name: _Stage_
Atlas: {fileID: 2800000, guid: e336e165518cf4d8680e2fff9c6b59ba, type: 3}
Sprite: {fileID: 21300000, guid: e336e165518cf4d8680e2fff9c6b59ba, type: 3}
FrameRate: 24
AssetGUID: a25723a1cd8b141a6b489606584a6f65
Sequences:

File diff suppressed because one or more lines are too long

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Name: npc_bureaucrat.fla.bureaucrat
m_EditorClassIdentifier:
Name: bureaucrat
Atlas: {fileID: 2800000, guid: e336e165518cf4d8680e2fff9c6b59ba, type: 3}
Sprite: {fileID: 21300000, guid: e336e165518cf4d8680e2fff9c6b59ba, type: 3}
FrameRate: 24
AssetGUID: a25723a1cd8b141a6b489606584a6f65
Sequences:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: c1278c7f98af44db8a86e620305eb32b
timeCreated: 1476531185
timeCreated: 1486894967
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
@@ -37,8 +37,7 @@ TextureImporter:
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Name: npc_smuggler.fla._Stage_
m_EditorClassIdentifier:
Name: _Stage_
Atlas: {fileID: 2800000, guid: c1278c7f98af44db8a86e620305eb32b, type: 3}
Sprite: {fileID: 21300000, guid: c1278c7f98af44db8a86e620305eb32b, type: 3}
FrameRate: 30
AssetGUID: 91fc9b6bb83c645678686dbc06141d03
Sequences:

File diff suppressed because one or more lines are too long

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Name: npc_smuggler.fla.smuggler
m_EditorClassIdentifier:
Name: smuggler
Atlas: {fileID: 2800000, guid: c1278c7f98af44db8a86e620305eb32b, type: 3}
Sprite: {fileID: 21300000, guid: c1278c7f98af44db8a86e620305eb32b, type: 3}
FrameRate: 30
AssetGUID: 91fc9b6bb83c645678686dbc06141d03
Sequences:

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: a799322aa44e44b38980bc9d307f0c38
timeCreated: 1476531185
timeCreated: 1486894960
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
@@ -37,8 +37,7 @@ TextureImporter:
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Name: purple_apparition.fla._Stage_
m_EditorClassIdentifier:
Name: _Stage_
Atlas: {fileID: 2800000, guid: a799322aa44e44b38980bc9d307f0c38, type: 3}
Sprite: {fileID: 21300000, guid: a799322aa44e44b38980bc9d307f0c38, type: 3}
FrameRate: 24
AssetGUID: 0f54ba869440c48cd8d6c64e70c09b87
Sequences:

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Name: purple_apparition.fla.purpleFlower
m_EditorClassIdentifier:
Name: purpleFlower
Atlas: {fileID: 2800000, guid: a799322aa44e44b38980bc9d307f0c38, type: 3}
Sprite: {fileID: 21300000, guid: a799322aa44e44b38980bc9d307f0c38, type: 3}
FrameRate: 24
AssetGUID: 0f54ba869440c48cd8d6c64e70c09b87
Sequences:

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 47e46d443fd064d78ae33281e2840297
timeCreated: 1476531184
timeCreated: 1486894975
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
@@ -37,8 +37,7 @@ TextureImporter:
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Name: rainbow_100coinstoday.fla._Stage_
m_EditorClassIdentifier:
Name: _Stage_
Atlas: {fileID: 2800000, guid: 47e46d443fd064d78ae33281e2840297, type: 3}
Sprite: {fileID: 21300000, guid: 47e46d443fd064d78ae33281e2840297, type: 3}
FrameRate: 30
AssetGUID: 7cf612ae1f9fb4253bc5cff2800885e9
Sequences:

View File

@@ -7,37 +7,25 @@
};
}
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== 'function') {
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1);
var fToBind = this;
var fNOP = function () {};
var fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}
(function () {
"use strict";
//
// ft
// ft config
//
var ft = {
profile_mode : false,
verbose_mode : false,
graphics_scale : 1.0,
optimize_small_items : true,
optimize_static_items : true,
optimize_single_graphics : true
};
//
// ft base functions
//
ft.trace = function () {
fl.outputPanel.trace(
@@ -75,7 +63,7 @@ if (!Function.prototype.bind) {
};
ft.type_assert_if_defined = function (item, type) {
if (item !== undefined) {
if (item && item !== undefined) {
ft.type_assert(item, type);
}
};
@@ -203,6 +191,13 @@ if (!Function.prototype.bind) {
}
}
};
ft.approximately = function(a, b, precision) {
ft.type_assert(a, 'number');
ft.type_assert(b, 'number');
ft.type_assert(precision, 'number');
return Math.abs(b - a) < Math.abs(precision);
};
ft.gen_unique_name = function () {
if (!ft.gen_unique_name_index) {
@@ -222,12 +217,59 @@ if (!Function.prototype.bind) {
ft.type_assert(doc, Document);
ft.profile_function(function() { ftdoc.prepare_folders(doc); }, "Prepare folders");
ft.profile_function(function() { ftdoc.full_exit_edit_mode(doc); }, "Full exit edit mode");
ft.profile_function(function() { ftdoc.remove_unused_items(doc); }, "Remove unused items");
ft.profile_function(function() { ftdoc.prepare_all_bitmaps(doc); }, "Prepare all bitmaps");
ft.profile_function(function() { ftdoc.unlock_all_timelines(doc); }, "Unlock all timelines");
ft.profile_function(function() { ftdoc.optimize_all_timelines(doc); }, "Optimize all timelines");
ft.profile_function(function() { ftdoc.rasterize_all_shapes(doc); }, "Rasterize all shapes");
ft.profile_function(function() { ftdoc.export_swf(doc); }, "Export swf");
};
ftdoc.get_temp = function (doc) {
if (!ftdoc.hasOwnProperty("temp")) {
ftdoc["temp"] = {
x_max_scales : {},
y_max_scales : {}
}
}
return ftdoc["temp"];
};
ftdoc.calculate_item_final_scale = function (doc, optional_item) {
ft.type_assert(doc, Document);
ft.type_assert_if_defined(optional_item, LibraryItem);
var final_scale = ft.graphics_scale;
if (optional_item && ft.optimize_small_items) {
var item_name = optional_item.name;
var x_max_scales = ftdoc.get_temp(doc).x_max_scales;
var y_max_scales = ftdoc.get_temp(doc).y_max_scales;
if (x_max_scales.hasOwnProperty(item_name) && y_max_scales.hasOwnProperty(item_name)) {
var max_x_scale = x_max_scales[item_name];
var max_y_scale = y_max_scales[item_name];
var max_c_scale = Math.max(max_x_scale, max_y_scale);
if (max_c_scale < 1.0) {
final_scale *= max_c_scale;
}
}
}
return final_scale;
};
ftdoc.convert_selection_to_bitmap = function (doc, optional_item) {
ft.type_assert(doc, Document);
ft.type_assert_if_defined(optional_item, LibraryItem);
var final_scale = ftdoc.calculate_item_final_scale(doc, optional_item);
if (ft.approximately(final_scale, 1.0, 0.01)) {
doc.convertSelectionToBitmap();
} else {
var wrapper_item_name = ft.gen_unique_name();
var wrapper_item = doc.convertToSymbol("graphic", wrapper_item_name , "center");
fttim.recursive_scale_filters(doc, wrapper_item.timeline, final_scale);
doc.scaleSelection(final_scale, final_scale);
doc.convertSelectionToBitmap();
doc.scaleSelection(1.0 / final_scale, 1.0 / final_scale);
}
};
ftdoc.prepare_folders = function (doc) {
ft.type_assert(doc, Document);
@@ -251,6 +293,19 @@ if (!Function.prototype.bind) {
doc.exitEditMode();
}
};
ftdoc.remove_unused_items = function (doc) {
ft.type_assert(doc, Document);
var unused_items = doc.library.unusedItems;
if (unused_items && unused_items !== undefined) {
ft.array_reverse_foreach(unused_items, function(item) {
if (ft.verbose_mode) {
ft.trace_fmt("Remove unused item: {0}", item.name);
}
doc.library.deleteItem(item.name);
});
}
};
ftdoc.unlock_all_timelines = function (doc) {
ft.type_assert(doc, Document);
@@ -260,6 +315,11 @@ if (!Function.prototype.bind) {
ftdoc.optimize_all_timelines = function (doc) {
ft.type_assert(doc, Document);
if (ft.optimize_small_items) {
ft.profile_function(function () {
ftlib.optimize_small_items(doc, doc.library);
}, "Optimize small items");
}
if (ft.optimize_static_items) {
ft.profile_function(function () {
ftlib.optimize_static_items(doc, doc.library);
@@ -356,6 +416,72 @@ if (!Function.prototype.bind) {
fttim.unlock(item.timeline);
});
};
ftlib.optimize_small_items = function (doc, library) {
ft.type_assert(doc, Document);
ft.type_assert(library, Library);
var x_max_scales = ftdoc.get_temp(doc).x_max_scales;
var y_max_scales = ftdoc.get_temp(doc).y_max_scales;
var walk_by_timeline = function(timeline, func, acc) {
ft.type_assert(timeline, Timeline);
ft.type_assert(func, Function);
ft.array_foreach(timeline.layers, function (layer) {
ft.array_foreach(layer.frames, function (frame) {
ft.array_foreach(frame.elements, function (elem) {
walk_by_timeline(
elem.libraryItem.timeline,
func,
func(elem, acc));
}, fttim.is_symbol_instance);
}, fttim.is_keyframe);
});
};
var walk_by_library = function(lib, func, acc) {
ft.type_assert(lib, Library);
ft.type_assert(func, Function);
ft.array_foreach(lib.items, function (item) {
walk_by_timeline(item.timeline, func, acc)
}, ftlib.is_symbol_item);
};
var x_func = function(elem, acc) {
var elem_sx = elem.scaleX * acc;
var item_name = elem.libraryItem.name;
x_max_scales[item_name] = Math.max(
x_max_scales.hasOwnProperty(item_name) ? x_max_scales[item_name] : elem_sx,
elem_sx);
return elem_sx;
};
var y_func = function(elem, acc) {
var elem_sy = elem.scaleY * acc;
var item_name = elem.libraryItem.name;
y_max_scales[item_name] = Math.max(
y_max_scales.hasOwnProperty(item_name) ? y_max_scales[item_name] : elem_sy,
elem_sy);
return elem_sy;
};
walk_by_library(library, x_func, 1.0);
walk_by_timeline(doc.getTimeline(), x_func, 1.0);
walk_by_library(library, y_func, 1.0);
walk_by_timeline(doc.getTimeline(), y_func, 1.0);
if (ft.verbose_mode) {
for (var item_name in x_max_scales) {
var max_x_scale = x_max_scales.hasOwnProperty(item_name) ? x_max_scales[item_name] : 1.0;
var max_y_scale = y_max_scales.hasOwnProperty(item_name) ? y_max_scales[item_name] : 1.0;
var max_c_scale = Math.max(max_x_scale, max_y_scale);
if (max_c_scale < 1.0) {
ft.trace_fmt("Small item for optimize: {0} - {1}", item_name, max_c_scale);
}
}
}
};
ftlib.optimize_static_items = function (doc, library) {
ft.type_assert(doc, Document);
@@ -429,7 +555,7 @@ if (!Function.prototype.bind) {
new_item_elem.setTransformationPoint({x: 0, y: 0});
new_item_elem.transformX = 0;
new_item_elem.transformY = 0;
doc.convertSelectionToBitmap();
ftdoc.convert_selection_to_bitmap(doc, item);
return true;
} else {
doc.exitEditMode();
@@ -441,7 +567,6 @@ if (!Function.prototype.bind) {
ftlib.optimize_single_graphics = function (doc, library) {
ft.type_assert(doc, Document);
ft.type_assert(library, Library);
ft.array_reverse_foreach(library.items, function (item) {
fttim.optimize_single_graphics(doc, item.timeline, item);
}, ftlib.is_symbol_item);
@@ -552,6 +677,26 @@ if (!Function.prototype.bind) {
var frame_height = Math.max(0, bounds.bottom - bounds.top);
return Math.round(frame_width) * Math.round(frame_height);
}
fttim.recursive_scale_filters = function (doc, timeline, scale) {
ft.type_assert(doc, Document);
ft.type_assert(timeline, Timeline);
ft.array_foreach(timeline.layers, function (layer) {
ft.array_foreach(layer.frames, function (frame, frame_index) {
ft.array_foreach(frame.elements, function (elem) {
var elem_filters = elem.filters;
if (Array.isArray(elem_filters)) {
ft.array_foreach(elem_filters, function (elem_filter, filter_index) {
elem_filter.blurX *= scale;
elem_filter.blurY *= scale;
});
elem.filters = elem_filters;
}
fttim.recursive_scale_filters(doc, elem.libraryItem.timeline, scale);
}, fttim.is_symbol_instance);
}, fttim.is_keyframe);
}, fttim.is_not_guide_layer);
};
fttim.replace_baked_symbols = function (doc, timeline, replaces) {
ft.type_assert(doc, Document);
@@ -648,7 +793,7 @@ if (!Function.prototype.bind) {
doc.selectNone();
doc.selection = ft.array_filter(frame.elements, fttim.is_shape_instance);
if (doc.selection.length > 0) {
doc.convertSelectionToBitmap();
ftdoc.convert_selection_to_bitmap(doc, timeline.libraryItem);
doc.arrange("back");
any_rasterize = true;
}

View File

@@ -135,6 +135,9 @@ inline swf_mask_v2f_t swf_mask_vert(swf_mask_appdata_t IN) {
inline fixed4 swf_frag(swf_v2f_t IN) : SV_Target {
fixed4 c = tex2D(_MainTex, IN.uv);
if ( _ExternalAlpha ) {
c.a *= tex2D(_AlphaTex, IN.uv).r;
}
if ( c.a > 0.01 ) {
c = c * IN.mulcolor + IN.addcolor;
}
@@ -144,6 +147,9 @@ inline fixed4 swf_frag(swf_v2f_t IN) : SV_Target {
inline fixed4 swf_grab_frag(swf_grab_v2f_t IN) : SV_Target {
fixed4 c = tex2D(_MainTex, IN.uv);
if ( _ExternalAlpha ) {
c.a *= tex2D(_AlphaTex, IN.uv).r;
}
if ( c.a > 0.01 ) {
c = c * IN.mulcolor + IN.addcolor;
c = grab_blend(_GrabTexture, IN.screenpos, c);
@@ -154,6 +160,9 @@ inline fixed4 swf_grab_frag(swf_grab_v2f_t IN) : SV_Target {
inline fixed4 swf_mask_frag(swf_mask_v2f_t IN) : SV_Target {
fixed4 c = tex2D(_MainTex, IN.uv);
if ( _ExternalAlpha ) {
c.a *= tex2D(_AlphaTex, IN.uv).r;
}
if ( c.a < 0.01 ) {
discard;
}

View File

@@ -1,6 +1,8 @@
Shader "FlashTools/SwfDecrMask" {
Properties {
[PerRendererData] _MainTex("Main Texture", 2D) = "white" {}
[PerRendererData] _MainTex ("Main Texture" , 2D) = "white" {}
[PerRendererData] _AlphaTex ("Alpha Texture" , 2D) = "white" {}
[PerRendererData] _ExternalAlpha ("External Alpha", Float) = 0
}
SubShader {
@@ -28,7 +30,9 @@ Shader "FlashTools/SwfDecrMask" {
CGPROGRAM
fixed4 _Tint;
sampler2D _MainTex;
sampler2D _AlphaTex;
sampler2D _GrabTexture;
float _ExternalAlpha;
#include "UnityCG.cginc"
#include "SwfBaseCG.cginc"

View File

@@ -1,6 +1,8 @@
Shader "FlashTools/SwfIncrMask" {
Properties {
[PerRendererData] _MainTex("Main Texture", 2D) = "white" {}
[PerRendererData] _MainTex ("Main Texture" , 2D) = "white" {}
[PerRendererData] _AlphaTex ("Alpha Texture" , 2D) = "white" {}
[PerRendererData] _ExternalAlpha ("External Alpha", Float) = 0
}
SubShader {
@@ -28,7 +30,9 @@ Shader "FlashTools/SwfIncrMask" {
CGPROGRAM
fixed4 _Tint;
sampler2D _MainTex;
sampler2D _AlphaTex;
sampler2D _GrabTexture;
float _ExternalAlpha;
#include "UnityCG.cginc"
#include "SwfBaseCG.cginc"

View File

@@ -1,7 +1,9 @@
Shader "FlashTools/SwfMaskedGrab" {
Properties {
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[PerRendererData] _MainTex ("Main Texture" , 2D ) = "white" {}
[PerRendererData] _AlphaTex ("Alpha Texture" , 2D ) = "white" {}
[PerRendererData] _ExternalAlpha ("External Alpha", Float) = 0
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
_StencilID ("Stencil ID", Int) = 0
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
@@ -35,7 +37,9 @@ Shader "FlashTools/SwfMaskedGrab" {
CGPROGRAM
fixed4 _Tint;
sampler2D _MainTex;
sampler2D _AlphaTex;
sampler2D _GrabTexture;
float _ExternalAlpha;
#pragma multi_compile SWF_DARKEN_BLEND SWF_DIFFERENCE_BLEND SWF_INVERT_BLEND SWF_OVERLAY_BLEND SWF_HARDLIGHT_BLEND

View File

@@ -1,7 +1,9 @@
Shader "FlashTools/SwfMasked" {
Properties {
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[PerRendererData] _MainTex ("Main Texture" , 2D ) = "white" {}
[PerRendererData] _AlphaTex ("Alpha Texture" , 2D ) = "white" {}
[PerRendererData] _ExternalAlpha ("External Alpha", Float) = 0
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
_StencilID ("Stencil ID", Int) = 0
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
@@ -33,7 +35,9 @@ Shader "FlashTools/SwfMasked" {
CGPROGRAM
fixed4 _Tint;
sampler2D _MainTex;
sampler2D _AlphaTex;
sampler2D _GrabTexture;
float _ExternalAlpha;
#include "UnityCG.cginc"
#include "SwfBaseCG.cginc"

View File

@@ -1,7 +1,9 @@
Shader "FlashTools/SwfSimpleGrab" {
Properties {
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[PerRendererData] _MainTex ("Main Texture" , 2D ) = "white" {}
[PerRendererData] _AlphaTex ("Alpha Texture" , 2D ) = "white" {}
[PerRendererData] _ExternalAlpha ("External Alpha", Float) = 0
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("SrcBlend", Int) = 1
@@ -30,7 +32,9 @@ Shader "FlashTools/SwfSimpleGrab" {
CGPROGRAM
fixed4 _Tint;
sampler2D _MainTex;
sampler2D _AlphaTex;
sampler2D _GrabTexture;
float _ExternalAlpha;
#pragma multi_compile SWF_DARKEN_BLEND SWF_DIFFERENCE_BLEND SWF_INVERT_BLEND SWF_OVERLAY_BLEND SWF_HARDLIGHT_BLEND

View File

@@ -1,7 +1,9 @@
Shader "FlashTools/SwfSimple" {
Properties {
[PerRendererData] _MainTex ("Main Texture", 2D ) = "white" {}
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[PerRendererData] _MainTex ("Main Texture" , 2D ) = "white" {}
[PerRendererData] _AlphaTex ("Alpha Texture" , 2D ) = "white" {}
[PerRendererData] _ExternalAlpha ("External Alpha", Float) = 0
[PerRendererData] _Tint ("Tint" , Color) = (1,1,1,1)
[Enum(UnityEngine.Rendering.BlendOp )] _BlendOp ("BlendOp" , Int) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("SrcBlend", Int) = 1
@@ -28,7 +30,9 @@ Shader "FlashTools/SwfSimple" {
CGPROGRAM
fixed4 _Tint;
sampler2D _MainTex;
sampler2D _AlphaTex;
sampler2D _GrabTexture;
float _ExternalAlpha;
#include "UnityCG.cginc"
#include "SwfBaseCG.cginc"

View File

@@ -80,17 +80,25 @@ namespace FTEditor.Editors {
//
void CreateAllClipsPrefabs() {
Selection.objects = _clips
var objects = _clips
.Select (p => CreateClipPrefab(p))
.Where (p => !!p)
.ToArray();
Selection.objects = objects;
foreach ( var obj in objects ) {
EditorGUIUtility.PingObject(obj);
}
}
void CreateAllClipsOnScene() {
Selection.objects = _clips
var objects = _clips
.Select (p => CreateClipOnScene(p))
.Where (p => !!p)
.ToArray();
Selection.objects = objects;
foreach ( var obj in objects ) {
EditorGUIUtility.PingObject(obj);
}
}
//
@@ -146,6 +154,14 @@ namespace FTEditor.Editors {
});
}
void DrawGUINotes() {
EditorGUILayout.Separator();
EditorGUILayout.HelpBox(
"Masks and blends of animation may not be displayed correctly in preview window. " +
"Instance animation to the scene, to see how it will look like the animation in the game.",
MessageType.Info);
}
// ---------------------------------------------------------------------
//
// Messages
@@ -163,6 +179,7 @@ namespace FTEditor.Editors {
DrawGUISequences();
DrawGUISourceAsset();
DrawGUIControls();
DrawGUINotes();
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}

View File

@@ -12,10 +12,24 @@ namespace FTEditor.Editors {
static MaterialPropertyBlock _matPropBlock = null;
static PreviewRenderUtility _previewUtils = null;
Texture2D targetAtlas {
Sprite targetSprite {
get {
var clip = target as SwfClipAsset;
return clip.Atlas;
return clip ? clip.Sprite : null;
}
}
Texture2D targetAtlas {
get {
var sprite = targetSprite;
return sprite ? sprite.texture : null;
}
}
Texture2D targetAtlasA {
get {
var sprite = targetSprite;
return sprite ? sprite.associatedAlphaSplitTexture : null;
}
}
@@ -160,7 +174,15 @@ namespace FTEditor.Editors {
if ( isTargetValidForPreview ) {
_previewUtils.BeginPreview(r, background);
{
_matPropBlock.SetTexture("_MainTex", targetAtlas);
if ( targetAtlas ) {
_matPropBlock.SetTexture("_MainTex", targetAtlas);
}
if ( targetAtlasA ) {
_matPropBlock.SetTexture("_AlphaTex", targetAtlasA);
_matPropBlock.SetFloat("_ExternalAlpha", 1.0f);
} else {
_matPropBlock.SetFloat("_ExternalAlpha", 0.0f);
}
ConfigureCameraForSequence(_previewUtils.m_Camera, targetSequence);
var frame = targetFrame;
for ( var i = 0; i < frame.Materials.Length; ++i ) {

View File

@@ -211,13 +211,16 @@ namespace FTEditor.Postprocessors {
static void ConfigureAtlas(SwfAsset asset) {
var atlas_path = AssetDatabase.GetAssetPath(asset.Atlas);
var atlas_importer = GetBitmapsAtlasImporter(asset);
atlas_importer.spritesheet = new SpriteMetaData[0];
atlas_importer.textureType = TextureImporterType.Sprite;
atlas_importer.spriteImportMode = SpriteImportMode.Multiple;
atlas_importer.spriteImportMode = SpriteImportMode.Single;
atlas_importer.spritePixelsPerUnit = asset.Settings.PixelsPerUnit;
atlas_importer.mipmapEnabled = asset.Settings.GenerateMipMaps;
atlas_importer.filterMode = SwfAtlasFilterToImporterFilter(asset.Settings.AtlasTextureFilter);
#if UNITY_5_5_OR_NEWER
atlas_importer.textureCompression = SwfAtlasFormatToImporterCompression(asset.Settings.AtlasTextureFormat);
#else
atlas_importer.textureFormat = SwfAtlasFormatToImporterFormat(asset.Settings.AtlasTextureFormat);
#endif
AssetDatabase.WriteImportSettingsIfDirty(atlas_path);
}
@@ -249,24 +252,37 @@ namespace FTEditor.Postprocessors {
}
}
static TextureImporterFormat SwfAtlasFormatToImporterFormat(
#if UNITY_5_5_OR_NEWER
static TextureImporterCompression SwfAtlasFormatToImporterCompression(
SwfSettingsData.AtlasFormat format)
{
switch ( format ) {
case SwfSettingsData.AtlasFormat.AutomaticCompressed:
return TextureImporterFormat.AutomaticCompressed;
case SwfSettingsData.AtlasFormat.Automatic16bit:
return TextureImporterFormat.Automatic16bit;
return TextureImporterCompression.Compressed;
case SwfSettingsData.AtlasFormat.AutomaticTruecolor:
return TextureImporterFormat.AutomaticTruecolor;
case SwfSettingsData.AtlasFormat.AutomaticCrunched:
return TextureImporterFormat.AutomaticCrunched;
return TextureImporterCompression.Uncompressed;
default:
throw new UnityException(string.Format(
"incorrect swf atlas format ({0})",
format));
}
}
#else
static TextureImporterFormat SwfAtlasFormatToImporterFormat(
SwfSettingsData.AtlasFormat format)
{
switch ( format ) {
case SwfSettingsData.AtlasFormat.AutomaticCompressed:
return TextureImporterFormat.AutomaticCompressed;
case SwfSettingsData.AtlasFormat.AutomaticTruecolor:
return TextureImporterFormat.AutomaticTruecolor;
default:
throw new UnityException(string.Format(
"incorrect swf atlas format ({0})",
format));
}
}
#endif
// ---------------------------------------------------------------------
//
@@ -306,8 +322,9 @@ namespace FTEditor.Postprocessors {
SwfClipAsset clip_asset, SwfAsset asset, SwfAssetData data, SwfSymbolData symbol)
{
var asset_guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset));
var asset_atlas = AssetDatabase.LoadAssetAtPath<Sprite>(AssetDatabase.GetAssetPath(asset.Atlas));
clip_asset.Name = symbol.Name;
clip_asset.Atlas = asset.Atlas;
clip_asset.Sprite = asset_atlas;
clip_asset.AssetGUID = asset_guid;
clip_asset.FrameRate = data.FrameRate;
clip_asset.Sequences = LoadClipSequences(asset, data, symbol);

View File

@@ -240,14 +240,19 @@ namespace FTEditor {
// ---------------------------------------------------------------------
public class ProgressBar {
string _title = "Flash Tools Process";
string _title = string.Empty;
public void UpdateTitle(string title) {
_title = string.Format("Flash Tools Process: {0}", title);
_title = title;
}
public void UpdateProgress(string info, float progress) {
EditorUtility.DisplayProgressBar(_title, info, progress);
var bar_title = string.IsNullOrEmpty(_title)
? "Flash Tools Process"
: string.Format("Flash Tools Process: {0}", _title);
var bar_info = string.Format("{0}...", info);
var bar_progress = Mathf.Clamp01(progress);
EditorUtility.DisplayProgressBar(bar_title, bar_info, bar_progress);
}
public void HideProgress() {
@@ -265,6 +270,7 @@ namespace FTEditor {
static void Tools_FlashTools_OpenSettings() {
var settings_holder = SwfEditorUtils.GetSettingsHolder();
Selection.objects = new Object[]{settings_holder};
EditorGUIUtility.PingObject(settings_holder);
}
[MenuItem("Tools/FlashTools/Reimport all swf files")]

View File

@@ -71,18 +71,18 @@
// Fonts and Text
// -----------------------------
//DefineFont = 10,
//DefineFontInfo = 13,
//DefineFontInfo2 = 62,
//DefineFont2 = 48,
//DefineFont3 = 75,
//DefineFontAlignZones = 73,
//DefineFontName = 88,
//DefineText = 11,
//DefineText2 = 33,
//DefineEditText = 37,
//CSMTextSettings = 74,
//DefineFont4 = 91,
DefineFont = 10,
DefineFontInfo = 13,
DefineFontInfo2 = 62,
DefineFont2 = 48,
DefineFont3 = 75,
DefineFontAlignZones = 73,
DefineFontName = 88,
DefineText = 11,
DefineText2 = 33,
DefineEditText = 37,
CSMTextSettings = 74,
DefineFont4 = 91,
// -----------------------------
// Sounds
@@ -199,6 +199,19 @@
// Shape Morphing
case (int)SwfTagType.DefineMorphShape: return UnsupportedTag.Create(SwfTagType.DefineMorphShape);
case (int)SwfTagType.DefineMorphShape2: return UnsupportedTag.Create(SwfTagType.DefineMorphShape2);
// Fonts and Text
case (int)SwfTagType.DefineFont: return UnsupportedTag.Create(SwfTagType.DefineFont);
case (int)SwfTagType.DefineFontInfo: return UnsupportedTag.Create(SwfTagType.DefineFontInfo);
case (int)SwfTagType.DefineFontInfo2: return UnsupportedTag.Create(SwfTagType.DefineFontInfo2);
case (int)SwfTagType.DefineFont2: return UnsupportedTag.Create(SwfTagType.DefineFont2);
case (int)SwfTagType.DefineFont3: return UnsupportedTag.Create(SwfTagType.DefineFont3);
case (int)SwfTagType.DefineFontAlignZones: return UnsupportedTag.Create(SwfTagType.DefineFontAlignZones);
case (int)SwfTagType.DefineFontName: return UnsupportedTag.Create(SwfTagType.DefineFontName);
case (int)SwfTagType.DefineText: return UnsupportedTag.Create(SwfTagType.DefineText);
case (int)SwfTagType.DefineText2: return UnsupportedTag.Create(SwfTagType.DefineText2);
case (int)SwfTagType.DefineEditText: return UnsupportedTag.Create(SwfTagType.DefineEditText);
case (int)SwfTagType.CSMTextSettings: return UnsupportedTag.Create(SwfTagType.CSMTextSettings);
case (int)SwfTagType.DefineFont4: return UnsupportedTag.Create(SwfTagType.DefineFont4);
// Sprites and Movie Clips
case (int)SwfTagType.DefineSprite: return DefineSpriteTag.Create(reader);
// Video

View File

@@ -344,12 +344,19 @@ namespace FTRuntime {
_curPropBlock = new MaterialPropertyBlock();
}
_meshRenderer.GetPropertyBlock(_curPropBlock);
_curPropBlock.SetColor(
"_Tint",
tint);
_curPropBlock.SetTexture(
"_MainTex",
clip && clip.Atlas ? clip.Atlas : Texture2D.whiteTexture);
_curPropBlock.SetColor("_Tint", tint);
var sprite = clip ? clip.Sprite : null;
var atlas = sprite && sprite.texture ? sprite.texture : Texture2D.whiteTexture;
var atlasA = sprite ? sprite.associatedAlphaSplitTexture : null;
if ( atlas ) {
_curPropBlock.SetTexture("_MainTex", atlas);
}
if ( atlasA ) {
_curPropBlock.SetTexture("_AlphaTex", atlasA);
_curPropBlock.SetFloat("_ExternalAlpha", 1.0f);
} else {
_curPropBlock.SetFloat("_ExternalAlpha", 0.0f);
}
_meshRenderer.SetPropertyBlock(_curPropBlock);
}
}

View File

@@ -61,7 +61,7 @@ namespace FTRuntime {
[SwfReadOnly]
public string Name;
[SwfReadOnly]
public Texture2D Atlas;
public Sprite Sprite;
[SwfReadOnly]
public float FrameRate;
[HideInInspector]
@@ -71,7 +71,7 @@ namespace FTRuntime {
void Reset() {
Name = string.Empty;
Atlas = null;
Sprite = null;
FrameRate = 1.0f;
AssetGUID = string.Empty;
Sequences = new List<Sequence>();

View File

@@ -11,10 +11,8 @@ namespace FTRuntime {
}
public enum AtlasFormat {
AutomaticCompressed,
Automatic16bit,
AutomaticTruecolor,
AutomaticCrunched
AutomaticCompressed = 0,
AutomaticTruecolor = 2
}
[SwfPowerOfTwoIfAttribute(5, 13, "AtlasPowerOfTwo")]

View File

@@ -28,10 +28,6 @@
<DefineConstants>FT_VERSION_FULL</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Sources\" />
<Folder Include="FTEditor\" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>..\DLLs\mscorlib.dll</HintPath>
@@ -66,6 +62,9 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="FTEditor\" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\Assets\FlashTools\Scripts\Editor\FTEditor\Editors.meta">
<Link>FTEditor\Editors.meta</Link>

View File

@@ -39,7 +39,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Sources\" />
<Folder Include="FTRuntime\" />
</ItemGroup>
<ItemGroup>
@@ -49,9 +48,6 @@
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\SwfAsset.cs.meta">
<Link>FTRuntime\SwfAsset.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\SwfAttributes.cs.meta">
<Link>FTRuntime\SwfAttributes.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\SwfClip.cs.meta">
<Link>FTRuntime\SwfClip.cs.meta</Link>
</None>
@@ -67,23 +63,35 @@
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\SwfSettings.cs.meta">
<Link>FTRuntime\SwfSettings.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Yields.meta">
<Link>FTRuntime\Yields.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfAssocList.cs.meta">
<Link>FTRuntime\Internal\SwfAssocList.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfAttributes.cs.meta">
<Link>FTRuntime\Internal\SwfAttributes.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfList.cs.meta">
<Link>FTRuntime\Internal\SwfList.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfUtils.cs.meta">
<Link>FTRuntime\Internal\SwfUtils.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Yields\SwfWaitPlayStopped.cs.meta">
<Link>FTRuntime\Yields\SwfWaitPlayStopped.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Yields\SwfWaitRewindPlaying.cs.meta">
<Link>FTRuntime\Yields\SwfWaitRewindPlaying.cs.meta</Link>
</None>
<None Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Yields\SwfWaitStopPlaying.cs.meta">
<Link>FTRuntime\Yields\SwfWaitStopPlaying.cs.meta</Link>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\SwfAsset.cs">
<Link>FTRuntime\SwfAsset.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\SwfAttributes.cs">
<Link>FTRuntime\SwfAttributes.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\SwfClip.cs">
<Link>FTRuntime\SwfClip.cs</Link>
</Compile>
@@ -102,11 +110,23 @@
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfAssocList.cs">
<Link>FTRuntime\Internal\SwfAssocList.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfAttributes.cs">
<Link>FTRuntime\Internal\SwfAttributes.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfList.cs">
<Link>FTRuntime\Internal\SwfList.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Internal\SwfUtils.cs">
<Link>FTRuntime\Internal\SwfUtils.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Yields\SwfWaitPlayStopped.cs">
<Link>FTRuntime\Yields\SwfWaitPlayStopped.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Yields\SwfWaitRewindPlaying.cs">
<Link>FTRuntime\Yields\SwfWaitRewindPlaying.cs</Link>
</Compile>
<Compile Include="..\..\Assets\FlashTools\Scripts\FTRuntime\Yields\SwfWaitStopPlaying.cs">
<Link>FTRuntime\Yields\SwfWaitStopPlaying.cs</Link>
</Compile>
</ItemGroup>
</Project>

View File

@@ -29,7 +29,6 @@
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Sources\" />
<Folder Include="FTSwfTools\" />
</ItemGroup>
<ItemGroup>

View File

@@ -6,4 +6,4 @@ EditorBuildSettings:
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/FlashTools/Example/Scene.unity
path: Assets/DevTests/Scenes/Scene.unity

View File

@@ -22,7 +22,7 @@ GraphicsSettings:
- {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_ShaderSettings:
useScreenSpaceShadows: 1
useScreenSpaceShadows: 0
m_BuildTargetShaderSettings: []
m_LightmapStripping: 0
m_FogStripping: 0

View File

@@ -93,7 +93,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleIdentifier: com.Company.ProductName
bundleIdentifier: me.matov.ft_demo
bundleVersion: 1.0
preloadedAssets: []
metroEnableIndependentInputSource: 0