Compare commits

...

77 Commits

Author SHA1 Message Date
8942aceef2 version 0.4 2016-09-22 02:19:15 +07:00
7057cd71a8 clear code 2016-09-22 02:14:58 +07:00
1d402eb91e clip groups 2016-09-21 23:36:32 +07:00
2ce9897d60 compress asset data 2016-09-21 01:16:12 +07:00
63fea79f49 able move containers and assets 2016-09-20 15:19:39 +07:00
5d29da73c7 tint color for clips 2016-09-16 05:08:06 +07:00
0c4efc0111 flash tools log prefix 2016-09-16 04:50:07 +07:00
6474828774 open settings menu button 2016-09-16 04:36:47 +07:00
78758786e6 'reimport all' menu button 2016-09-16 03:25:44 +07:00
7a0940b6a1 pause, resume and rate scale for manger 2016-09-16 03:03:33 +07:00
3d688d1ac2 controller API improvements 2016-09-16 02:33:48 +07:00
6d69b46c2f Added tag versions/0.3 for changeset d2d05072620c 2016-09-14 22:30:25 +07:00
2e6fc73bfe version 0.3 2016-09-14 22:30:09 +07:00
46a340d615 fix empty texture after reimport 2016-09-14 21:14:07 +07:00
e41eae8c72 GotoAndStop, GotoAndPlay 2016-09-14 18:38:07 +07:00
1991da1f6b fill mesh optimizations 2016-09-14 16:17:35 +07:00
14d1088db9 remove vertex coords tricks. skip many fill mesh in one frame 2016-09-14 14:19:51 +07:00
d1777239cd cut invisible geometry 2016-09-14 01:16:50 +07:00
dc539b1e27 style fixes 2016-09-14 00:42:46 +07:00
8108516350 compress mesh wip 2016-09-13 03:03:36 +07:00
c5270a01a7 compress mesh wip 2016-09-13 00:25:32 +07:00
c424a4d507 compress mesh data wip 2016-09-12 20:29:54 +07:00
876859a0e1 color transform range fix 2016-09-12 16:45:18 +07:00
00d66fa94e hide materials in inspector again 2016-09-11 23:04:51 +07:00
e98071f471 chached meshes wip 2016-09-11 22:55:02 +07:00
f068463454 style fixes 2016-09-11 02:25:43 +07:00
8ddb0d2bcb settings fix 2016-09-10 23:21:31 +07:00
6ba10b4875 little optimize asset size of disk 2016-09-10 22:47:31 +07:00
ddacef7275 show frame count for clip asset 2016-09-10 21:15:44 +07:00
6881f46d89 correct inspector for overriden order layer 2016-09-10 19:57:38 +07:00
811bd73fa1 fix prefab current mesh bug 2016-09-10 18:41:50 +07:00
5bce0db290 style fixes 2016-09-10 18:22:59 +07:00
a5c9d21b66 show clips for container asset in editor 2016-09-10 15:04:35 +07:00
fd0fae1590 preview fixes 2016-09-10 14:05:50 +07:00
225ab99153 style fixes 2016-09-10 05:17:18 +07:00
9609e07e5c preview for assets and clips 2016-09-10 01:49:19 +07:00
060594dc29 little style fix 2016-09-09 21:33:49 +07:00
891c1790c3 safe update controllers 2016-09-09 21:16:47 +07:00
b3783f22c4 jpg rasterize fix 2016-09-09 17:15:48 +07:00
205d4aad8c revert documents after export fix 2016-09-08 22:18:25 +07:00
c749b0ca9d multiple sequences edit 2016-09-08 22:08:45 +07:00
d1a992e421 fix empty mesh bug and to 5.3.6f1 2016-09-08 15:23:41 +07:00
950b7b663d DS_Store to ignore 2016-09-08 03:31:10 +07:00
1a3d541771 Added tag versions/0.2 for changeset aa93e17d4cac 2016-09-08 03:28:30 +07:00
7b4d3fc287 version 0.2 2016-09-08 03:28:14 +07:00
c400cecb04 editor select after create 2016-09-08 02:26:15 +07:00
8087895186 no mipmap by default 2016-09-07 23:48:29 +07:00
973e88143a little style fix 2016-09-07 23:37:14 +07:00
4bd725d92c little style fixes 2016-09-07 23:06:49 +07:00
ed2f5629b6 optional optimization and profile for export 2016-09-07 17:40:08 +07:00
002e040b00 new tests animations 2016-09-06 21:12:40 +07:00
85e3b411ee rename new flash export 2016-09-06 17:23:08 +07:00
0354a41ea3 remove old flash export 2016-09-06 17:22:42 +07:00
9879c436fa new flash export done 2016-09-06 13:01:12 +07:00
104d1f1541 refactor new flash export 2016-09-06 11:53:45 +07:00
3a32d010a8 new fla optimizator wip 2016-09-06 11:08:04 +07:00
f86e8d3813 detect duplicated bitmaps 2016-09-06 11:02:26 +07:00
77a1308ab9 new flash export wip 2016-09-05 17:20:09 +07:00
7b7ca0a064 error for vector graphics 2016-09-04 16:52:53 +07:00
007d46685e using capacity style fix 2016-09-04 16:37:29 +07:00
61acc97d54 alpha test animations 2016-09-04 14:27:44 +07:00
e83e88bf5a add some tags 2016-09-03 12:36:35 +07:00
afe588ef47 empty abc tag 2016-09-02 20:45:00 +07:00
711bc09355 HashSet tot AssocList 2016-09-02 18:05:57 +07:00
f56be1fbe9 rename refactor done 2016-09-02 16:39:11 +07:00
5d9bc9ee40 big name refactor continue 2016-09-02 15:34:50 +07:00
0bdd3fe995 big name refactor continue 2016-09-02 11:13:24 +07:00
e26fcd11e3 big name refactor continue 2016-09-02 04:06:30 +07:00
75bb109e7e big name refactor continue 2016-09-02 03:17:58 +07:00
b5b74e92e7 big name refactor 2016-09-02 01:32:43 +07:00
274f1c2c00 separate clips wip 2016-09-01 23:45:45 +07:00
15ff6b8da6 separate clips wip 2016-09-01 19:59:21 +07:00
b5127221c6 little style fixes 2016-08-31 22:46:51 +07:00
1639cf8d3d ExportAsset and SymbolClass tags parser 2016-08-31 22:02:42 +07:00
1660f52952 hide current frame and animation controls for one frame animation 2016-08-31 21:24:52 +07:00
33265199ec + alpha test animations 2016-08-31 20:57:25 +07:00
e651ed012a Added tag versions/0.1 for changeset 15a7193e27d5 2016-08-31 20:40:38 +07:00
149 changed files with 4469 additions and 1946 deletions

View File

@@ -1,3 +1,5 @@
glob:obj/*
glob:Temp/*
glob:Library/*
glob:.DS_Store

View File

@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_5;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_6;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
@@ -45,18 +45,21 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfAnimationAssetEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfAnimationAssetPostprocessor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfAnimationControllerEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfAnimationEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Editors\SwfAssetEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Editors\SwfClipAssetEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Editors\SwfClipAssetPreview.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Editors\SwfClipControllerEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Editors\SwfClipEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Editors\SwfManagerEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Postprocessors\SwfAssetPostprocessor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Postprocessors\SwfPostprocessor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfEditorUtils.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfManagerEditor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfPostprocessor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfPropertyDrawers.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfContext.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfContextExecuter.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfDecoder.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfStreamReader.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineBinaryDataTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineBitsLossless2Tag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineBitsLosslessTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineSceneAndFrameLabelDataTag.cs" />
@@ -65,18 +68,27 @@
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineShape4Tag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineShapeTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineSpriteTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DoABCTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\EnableDebugger2Tag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\EnableDebuggerTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\EnableTelemetryTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\EndTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\ExportAssetsTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\FileAttributesTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\FrameLabelTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\MetadataTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\PlaceObject2Tag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\PlaceObject3Tag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\PlaceObjectTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\ProtectTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\RemoveObject2Tag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\RemoveObjectTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\ScriptLimitsTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SetBackgroundColorTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\ShowFrameTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SwfTagBase.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SwfTagVisitor.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SymbolClassTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\UnknownTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\UnsupportedTag.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfBlendMode.cs" />
@@ -91,8 +103,10 @@
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfShapesWithStyle.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfShortHeader.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfSurfaceFilters.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\Tests\SwfUtilsTests.cs" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfDecrMask.shader" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfSimple.shader" />
<None Include="Assets\FlashTools\CHANGELOG.txt" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfIncrMask.shader" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfMasked.shader" />
<Reference Include="UnityEditor.Advertisements">
@@ -131,21 +145,9 @@
<Reference Include="UnityEditor.iOS.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.AppleTV.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/AppleTVSupport/UnityEditor.AppleTV.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Tizen.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/TizenPlayer/UnityEditor.Tizen.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.SamsungTV.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/STVPlayer/UnityEditor.SamsungTV.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.WebGL.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/WebGLSupport/UnityEditor.WebGL.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.LinuxStandalone.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/LinuxStandaloneSupport/UnityEditor.LinuxStandalone.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.WindowsStandalone.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/WindowsStandaloneSupport/UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
</Reference>
@@ -153,12 +155,6 @@
<HintPath>/Applications/Unity/PlaybackEngines/MacStandaloneSupport/UnityEditor.OSXStandalone.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Xcode">
<HintPath>/Applications/Unity/PlaybackEngines/AppleTVSupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Common">
<HintPath>/Applications/Unity/PlaybackEngines/AppleTVSupport/UnityEditor.iOS.Extensions.Common.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Xcode">
<HintPath>/Applications/Unity/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Common">

View File

@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_5;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_6;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;DEVELOPMENT_BUILD;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
@@ -45,15 +45,19 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\FlashTools\Scripts\Internal\SwfConverterSettings.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\SwfPropertyAttributes.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\SwfAssocList.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\SwfAttributes.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\SwfList.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\SwfSettings.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfAnimation.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfAnimationAsset.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfAnimationController.cs" />
<Compile Include="Assets\FlashTools\Scripts\Internal\SwfUtils.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfAsset.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfClip.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfClipAsset.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfClipController.cs" />
<Compile Include="Assets\FlashTools\Scripts\SwfManager.cs" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfDecrMask.shader" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfSimple.shader" />
<None Include="Assets\FlashTools\CHANGELOG.txt" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfIncrMask.shader" />
<None Include="Assets\FlashTools\Resources\Shaders\SwfMasked.shader" />
<Reference Include="UnityEngine.UI">

View File

@@ -1,5 +1,29 @@
-----------------
-- Version 0.4 --
-----------------
Clip groups
Fix move assets bug
Tint color for clips
Animation API improvements
-----------------
-- Version 0.3 --
-----------------
Preview for animation assets and clips
Animation API improvements
Memory optimizations
-----------------
-- Version 0.2 --
-----------------
Export optimizations
Export clips with export names
-----------------
-- Version 0.1 --
-----------------
Initial alpha version.
Initial alpha version

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dfa1591b561424bf6a952fcb68bebbc0
timeCreated: 1472651507
licenseType: Free
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 36e41bbcb7e944d0a8d43b8864d11e53
folderAsset: yes
timeCreated: 1472643775
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e61267a1fa3da4e2e9a990b8109dab62
folderAsset: yes
timeCreated: 1472969622
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2cb43abf65fa14bfbbb33e79dd255bf2
timeCreated: 1472969629
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9eebfa609ec774c7fa32004eceb02243
folderAsset: yes
timeCreated: 1472643782
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 26a52e6a7300e444fb29b4191447bd36
timeCreated: 1472651736
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 84286e04b88ef44bfaee32c43f7c6d84
timeCreated: 1472651736
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4e264728156f540fca86118ad1297af4
timeCreated: 1472651736
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1895427e5db9946efa6da139cb46a5b4
timeCreated: 1472651736
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b7b0ac6ce623c41ce962f77cf82ecdf5
folderAsset: yes
timeCreated: 1472878717
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 419ad27fa3aa24d6d96f2a1ba3e2c72f
timeCreated: 1472878717
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 41d174597cd0d44a9b33e8839fae76fe
timeCreated: 1472878717
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e4ff5d1574d134fcc81de16f37c3d686
timeCreated: 1472878717
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: dc03a9474195b4799afdf6699e44cde5
folderAsset: yes
timeCreated: 1472904638
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3742bdeb59b40432d9ddc6efef96969e
timeCreated: 1472904656
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2f1aecaf027324ab3b8991044c19cc2d
timeCreated: 1472904651
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a163590b9c2e748af847e2feb6001884
folderAsset: yes
timeCreated: 1472905625
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a4242c7a9340743908cac495ffff3b46
timeCreated: 1472905638
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 680f136a1f899422c868a0efdf0287da
timeCreated: 1472905634
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 23e7ecbce7cf24bdd8ef7b649076d355
folderAsset: yes
timeCreated: 1473165906
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7dd21379da49e4ae9a58f285e9918bfc
timeCreated: 1473170989
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 083e21a8be6424b4eb2ec49d4e8f8c5a
timeCreated: 1473170984
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4f53fb2d8efa24abf83ad91d1c05f3d7
folderAsset: yes
timeCreated: 1472643825
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aaf494ca6df4d4d57964904fa17bb7e7
timeCreated: 1472651767
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3c71d789f4b0f4f84ba54e06bdeffab6
timeCreated: 1472651753
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ef061dab3797c4b1a86eb9f6acd752bc
timeCreated: 1472651767
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f21b498eb23974606bae51a5e36bae22
timeCreated: 1472651753
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cbbe82c139b4c46f9a97f43959988ba1
timeCreated: 1472651753
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 075eada96ece147de8eeee4710c5ab0f
timeCreated: 1474360714
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: 3
orthographic size: 23
m_Depth: 0
m_CullingMask:
serializedVersion: 2

View File

@@ -1,6 +1,7 @@
Shader "FlashTools/SwfMasked" {
Properties {
[PerRendererData] _MainTex("Main Texture", 2D) = "white" {}
[PerRendererData] _MainTex("Main Texture", 2D ) = "white" {}
[PerRendererData] _Color ("Tint" , Color) = (1,1,1,1)
_StencilID ("Stencil ID", Int) = 0
}
@@ -42,11 +43,13 @@ Shader "FlashTools/SwfMasked" {
fixed4 addcolor : TEXCOORD1;
};
fixed4 _Color;
v2f vert(appdata_t IN) {
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.uv = IN.uv;
OUT.mulcolor = IN.mulcolor;
OUT.mulcolor = IN.mulcolor * _Color;
OUT.addcolor = IN.addcolor;
return OUT;
}

View File

@@ -1,6 +1,7 @@
Shader "FlashTools/SwfSimple" {
Properties {
[PerRendererData] _MainTex("Main Texture", 2D) = "white" {}
[PerRendererData] _MainTex("Main Texture", 2D ) = "white" {}
[PerRendererData] _Color ("Tint" , Color) = (1,1,1,1)
}
SubShader {
@@ -37,11 +38,13 @@ Shader "FlashTools/SwfSimple" {
fixed4 addcolor : TEXCOORD1;
};
fixed4 _Color;
v2f vert(appdata_t IN) {
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.uv = IN.uv;
OUT.mulcolor = IN.mulcolor;
OUT.mulcolor = IN.mulcolor * _Color;
OUT.addcolor = IN.addcolor;
return OUT;
}

View File

@@ -9,13 +9,13 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6da591d87f967451298a275621e1fd5d, type: 3}
m_Name: SwfConverterSettings
m_Name: SwfSettings
m_EditorClassIdentifier:
DefaultSettings:
Settings:
MaxAtlasSize: 1024
AtlasPadding: 1
PixelsPerUnit: 100
GenerateMipMaps: 1
GenerateMipMaps: 0
AtlasPowerOfTwo: 1
AtlasForceSquare: 1
AtlasTextureFilter: 1

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 518cad4150eaf4133881bf2a4bae81ed
folderAsset: yes
timeCreated: 1472790046
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,143 @@
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfAsset)), CanEditMultipleObjects]
public class SwfAssetEditor : Editor {
List<SwfAsset> _assets = new List<SwfAsset>();
//
//
//
static SwfSettings _defaultSettingsCache = null;
static SwfSettings GetDefaultSettings() {
if ( !_defaultSettingsCache ) {
_defaultSettingsCache = SwfSettings.GetHolder();
}
return _defaultSettingsCache;
}
//
//
//
static void RevertOverriddenSettings(SwfAsset asset) {
asset.Overridden = asset.Settings;
}
static void OverriddenSettingsToDefault(SwfAsset asset) {
asset.Overridden = GetDefaultSettings().Settings;
}
static void ApplyOverriddenSettings(SwfAsset asset) {
asset.Settings = asset.Overridden;
ReconvertAsset(asset);
}
static void ReconvertAsset(SwfAsset asset) {
asset.Converting = new SwfAsset.ConvertingState();
AssetDatabase.ImportAsset(
AssetDatabase.GetAssetPath(asset));
}
//
//
//
void AllAssetsForeach(System.Action<SwfAsset> act) {
foreach ( var asset in _assets ) {
act(asset);
}
}
void AllOverriddenSettingsToDefault() {
AllAssetsForeach(p => OverriddenSettingsToDefault(p));
}
void RevertAllOverriddenSettings() {
AllAssetsForeach(p => RevertOverriddenSettings(p));
}
void ApplyAllOverriddenSettings() {
AllAssetsForeach(p => ApplyOverriddenSettings(p));
}
//
//
//
void ShowUnappliedDialog() {
var unapplied = _assets
.Where(p => !p.Settings.CheckEquals(p.Overridden))
.ToArray();
if ( unapplied.Length > 0 ) {
var title =
"Unapplied swf asset settings";
var message = unapplied.Length == 1
? string.Format(
"Unapplied swf asset settings for '{0}'",
AssetDatabase.GetAssetPath(unapplied[0]))
: string.Format(
"Unapplied multiple({0}) swf asset settings",
unapplied.Length);
if ( EditorUtility.DisplayDialog(title, message, "Apply", "Revert") ) {
ApplyAllOverriddenSettings();
} else {
RevertAllOverriddenSettings();
}
}
}
void DrawGUISettingsControls() {
var prop = SwfEditorUtils.GetPropertyByName(serializedObject, "Overridden");
if ( prop.isExpanded ) {
SwfEditorUtils.DoRightHorizontalGUI(() => {
var default_settings = GetDefaultSettings().Settings;
SwfEditorUtils.DoWithEnabledGUI(
_assets.Any(p => !p.Overridden.CheckEquals(default_settings)), () => {
if ( GUILayout.Button("Default") ) {
AllOverriddenSettingsToDefault();
}
});
SwfEditorUtils.DoWithEnabledGUI(
_assets.Any(p => !p.Overridden.CheckEquals(p.Settings)), () => {
if ( GUILayout.Button("Revert") ) {
RevertAllOverriddenSettings();
}
if ( GUILayout.Button("Apply") ) {
ApplyAllOverriddenSettings();
}
});
});
}
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_assets = targets.OfType<SwfAsset>().ToList();
}
void OnDisable() {
ShowUnappliedDialog();
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
DrawGUISettingsControls();
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
}
}

View File

@@ -0,0 +1,158 @@
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfClipAsset)), CanEditMultipleObjects]
public class SwfClipAssetEditor : Editor {
List<SwfClipAsset> _clips = new List<SwfClipAsset>();
static string GetClipPath(SwfClipAsset clip) {
return clip
? AssetDatabase.GetAssetPath(clip)
: string.Empty;
}
static string GetPrefabPath(SwfClipAsset clip) {
var clip_path = GetClipPath(clip);
return string.IsNullOrEmpty(clip_path)
? string.Empty
: Path.ChangeExtension(clip_path, ".prefab");
}
static int GetFrameCount(SwfClipAsset clip) {
return clip != null ? clip.Sequences.Aggregate(0, (acc, seq) => {
return seq.Frames.Count + acc;
}) : 0;
}
//
//
//
static GameObject CreateClipGO(SwfClipAsset clip) {
if ( clip ) {
var clip_go = new GameObject(clip.name);
clip_go.AddComponent<MeshFilter>();
clip_go.AddComponent<MeshRenderer>();
clip_go.AddComponent<SwfClip>().clip = clip;
clip_go.AddComponent<SwfClipController>();
return clip_go;
}
return null;
}
static GameObject CreateClipPrefab(SwfClipAsset clip) {
GameObject result = null;
var clip_go = CreateClipGO(clip);
if ( clip_go ) {
var prefab_path = GetPrefabPath(clip);
if ( !string.IsNullOrEmpty(prefab_path) ) {
var prefab = AssetDatabase.LoadMainAssetAtPath(prefab_path);
if ( !prefab ) {
prefab = PrefabUtility.CreateEmptyPrefab(prefab_path);
}
result = PrefabUtility.ReplacePrefab(
clip_go,
prefab,
ReplacePrefabOptions.ConnectToPrefab);
}
GameObject.DestroyImmediate(clip_go, true);
}
return result;
}
static GameObject CreateClipOnScene(SwfClipAsset clip) {
var clip_go = CreateClipGO(clip);
if ( clip_go ) {
Undo.RegisterCreatedObjectUndo(clip_go, "Instance SwfClip");
}
return clip_go;
}
//
//
//
void CreateAllClipsPrefabs() {
Selection.objects = _clips
.Select (p => CreateClipPrefab(p))
.Where (p => !!p)
.ToArray();
}
void CreateAllClipsOnScene() {
Selection.objects = _clips
.Select (p => CreateClipOnScene(p))
.Where (p => !!p)
.ToArray();
}
//
//
//
void DrawGUIFrameCount() {
var counts = _clips.Select(p => GetFrameCount(p));
var mixed_value = counts.GroupBy(p => p).Count() > 1;
SwfEditorUtils.DoWithEnabledGUI(false, () => {
SwfEditorUtils.DoWithMixedValue(
mixed_value, () => {
EditorGUILayout.IntField("Frame count", counts.First());
});
});
}
void DrawGUISequences() {
SwfEditorUtils.DoWithEnabledGUI(false, () => {
var sequences_prop = SwfEditorUtils.GetPropertyByName(
serializedObject, "Sequences");
if ( sequences_prop.isArray ) {
SwfEditorUtils.DoWithMixedValue(
sequences_prop.hasMultipleDifferentValues, () => {
EditorGUILayout.IntField("Sequence count", sequences_prop.arraySize);
});
}
});
}
void DrawGUIControls() {
SwfEditorUtils.DoHorizontalGUI(() => {
if ( GUILayout.Button("Create prefab") ) {
CreateAllClipsPrefabs();
}
if ( GUILayout.Button("Instance to scene") ) {
CreateAllClipsOnScene();
}
});
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_clips = targets.OfType<SwfClipAsset>().ToList();
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
DrawGUIFrameCount();
DrawGUISequences();
DrawGUIControls();
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
public override bool RequiresConstantRepaint() {
return true;
}
}
}

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 6da591d87f967451298a275621e1fd5d
timeCreated: 1471761453
guid: 1b6bb12f4dfcf4d34a6a027b679eacc8
timeCreated: 1472724849
licenseType: Free
MonoImporter:
serializedVersion: 2

View File

@@ -0,0 +1,179 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
namespace FlashTools.Internal {
[CustomPreview(typeof(SwfClipAsset))]
public class SwfClipAssetPreview : ObjectPreview {
int _sequence = 0;
static MaterialPropertyBlock _matPropBlock = null;
static PreviewRenderUtility _previewUtils = null;
Texture2D targetAtlas {
get {
var clip = target as SwfClipAsset;
return clip.Atlas;
}
}
int targetSequenceCount {
get {
var clip = target as SwfClipAsset;
return clip && clip.Sequences != null
? clip.Sequences.Count
: 0;
}
}
SwfClipAsset.Frame targetFrame {
get {
var clip = target as SwfClipAsset;
return GetFrameForClip(clip, _sequence);
}
}
SwfClipAsset.Sequence targetSequence {
get {
var clip = target as SwfClipAsset;
return GetSequenceForClip(clip, _sequence);
}
}
bool isTargetValidForPreview {
get {
var atlas = targetAtlas;
var frame = targetFrame;
var sequence = targetSequence;
return
atlas &&
frame != null &&
sequence != null &&
frame.CachedMesh && frame.CachedMesh.vertexCount > 0;
}
}
static SwfClipAsset.Frame GetFrameForClip(SwfClipAsset clip, int sequence_index) {
var sequence = GetSequenceForClip(clip, sequence_index);
var frames = sequence != null && sequence.Frames != null && sequence.Frames.Count > 0
? sequence.Frames
: null;
var frame_time = (float)(EditorApplication.timeSinceStartup * clip.FrameRate);
return frames != null
? frames[Mathf.FloorToInt(frame_time) % frames.Count]
: null;
}
static SwfClipAsset.Sequence GetSequenceForClip(SwfClipAsset clip, int sequence_index) {
return clip && clip.Sequences != null && clip.Sequences.Count > 0
? clip.Sequences[Mathf.Abs(sequence_index) % clip.Sequences.Count]
: null;
}
static Bounds CalculateBoundsForSequence(SwfClipAsset.Sequence sequence) {
var bounds = sequence != null && sequence.Frames != null && sequence.Frames.Count > 0
? sequence.Frames
.Where (p => !!p.CachedMesh)
.Select(p => p.CachedMesh.bounds)
: new Bounds[0];
var result = bounds.Any() ? bounds.First() : new Bounds();
foreach ( var bound in bounds ) {
result.Encapsulate(bound);
}
return result;
}
static void ConfigureCameraForSequence(Camera camera, SwfClipAsset.Sequence sequence) {
var bounds = CalculateBoundsForSequence(sequence);
camera.orthographic = true;
camera.orthographicSize = Mathf.Max(
Mathf.Abs(bounds.extents.x),
Mathf.Abs(bounds.extents.y));
camera.transform.position = new Vector3(
bounds.center.x,
bounds.center.y,
-10.0f);
}
// ---------------------------------------------------------------------
//
// Functions
//
// ---------------------------------------------------------------------
public void SetCurrentSequence(string sequence_name) {
var clip = target as SwfClipAsset;
_sequence = clip && clip.Sequences != null
? Mathf.Max(0, clip.Sequences.FindIndex(p => p.Name == sequence_name))
: 0;
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
public override void Initialize(Object[] targets) {
base.Initialize(targets);
if ( _matPropBlock == null ) {
_matPropBlock = new MaterialPropertyBlock();
}
if ( _previewUtils == null ) {
_previewUtils = new PreviewRenderUtility();
}
}
public override bool HasPreviewGUI() {
return true;
}
public override void OnPreviewSettings() {
var any_multi_sequences = m_Targets
.OfType<SwfClipAsset>()
.Any(p => p.Sequences != null && p.Sequences.Count > 1);
if ( any_multi_sequences && GUILayout.Button("<", EditorStyles.miniButton) ) {
--_sequence;
}
var sequence_names = m_Targets
.OfType<SwfClipAsset>()
.Select (p => GetSequenceForClip(p, _sequence))
.Where (p => p != null && !string.IsNullOrEmpty(p.Name))
.Select (p => p.Name)
.ToArray();
var label_text = string.Empty;
for ( int i = 0, e = sequence_names.Length; i < e; ++i ) {
label_text += string.Format(
i < e - 1 ? "{0}, " : "{0}",
sequence_names[i]);
}
GUILayout.Label(label_text, EditorStyles.whiteLabel);
if ( any_multi_sequences && GUILayout.Button(">", EditorStyles.miniButton) ) {
++_sequence;
}
}
public override void OnPreviewGUI(Rect r, GUIStyle background) {
if ( Event.current.type == EventType.Repaint ) {
if ( isTargetValidForPreview ) {
_previewUtils.BeginPreview(r, background);
{
_matPropBlock.SetTexture("_MainTex", targetAtlas);
ConfigureCameraForSequence(_previewUtils.m_Camera, targetSequence);
var frame = targetFrame;
for ( var i = 0; i < frame.Materials.Length; ++i ) {
_previewUtils.DrawMesh(
frame.CachedMesh,
Matrix4x4.identity,
frame.Materials[i],
i,
_matPropBlock);
}
_previewUtils.m_Camera.Render();
}
_previewUtils.EndAndDrawPreview(r);
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 61493c5b6491d4432a831d25914ed92a
timeCreated: 1473360782
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfClipController)), CanEditMultipleObjects]
public class SwfClipControllerEditor : Editor {
List<SwfClipController> _controllers = new List<SwfClipController>();
void AllControllersForeach(System.Action<SwfClipController> act) {
foreach ( var controller in _controllers ) {
act(controller);
}
}
void DrawClipControls() {
SwfEditorUtils.DoRightHorizontalGUI(() => {
if ( GUILayout.Button("Stop") ) {
AllControllersForeach(ctrl => ctrl.Stop(ctrl.isStopped));
}
if ( GUILayout.Button("Play") ) {
AllControllersForeach(ctrl => ctrl.Play(ctrl.isPlaying));
}
});
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_controllers = targets.OfType<SwfClipController>().ToList();
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
if ( Application.isPlaying ) {
DrawClipControls();
}
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
}
}

View File

@@ -0,0 +1,192 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfClip)), CanEditMultipleObjects]
public class SwfClipEditor : Editor {
List<SwfClip> _clips = new List<SwfClip>();
Dictionary<SwfClip, SwfClipAssetPreview> _previews = new Dictionary<SwfClip, SwfClipAssetPreview>();
void AllClipsForeachWithUndo(System.Action<SwfClip> act) {
Undo.RecordObjects(_clips.ToArray(), "Inspector");
foreach ( var clip in _clips ) {
act(clip);
EditorUtility.SetDirty(clip);
}
}
int GetMinClipsFrameCount() {
return _clips.Count > 0
? _clips.Min(clip => clip.frameCount)
: 0;
}
string GetClipsFrameCountStr() {
return _clips.Aggregate(string.Empty, (acc, clip) => {
var frame_count = clip.frameCount > 0 ? clip.frameCount - 1 : 0;
var frame_count_str = frame_count.ToString();
return string.IsNullOrEmpty(acc)
? frame_count_str
: (acc != frame_count_str ? "--" : acc);
});
}
string GetClipsCurrentFrameStr() {
return _clips.Aggregate(string.Empty, (acc, clip) => {
var current_frame = clip.currentFrame;
var current_frame_str = current_frame.ToString();
return string.IsNullOrEmpty(acc)
? current_frame_str
: (acc != current_frame_str ? "--" : acc);
});
}
List<string> GetAllSequences(bool include_empty) {
var result = new List<string>();
var result_clips = _clips
.Where (p => p.clip && p.clip.Sequences.Count > 0)
.Select(p => p.clip.Sequences)
.Where (p => p.All(s => !string.IsNullOrEmpty(s.Name)))
.ToList();
if ( result_clips.Count > 0 ) {
result = result_clips.First()
.Select(p => p.Name)
.ToList();
var sequences_enum = result_clips
.Select(p => p.Select(s => s.Name));
foreach ( var sequences in sequences_enum ) {
result = result
.Where(p => sequences.Contains(p))
.ToList();
}
if ( include_empty ) {
result.Add(string.Empty);
}
}
return result;
}
void DrawSequence() {
var all_sequences = GetAllSequences(true);
if ( all_sequences.Count > 0 ) {
var sequence_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "_sequence");
SwfEditorUtils.DoWithMixedValue(
sequence_prop.hasMultipleDifferentValues, () => {
var sequence_index = EditorGUILayout.Popup(
"Sequence",
sequence_prop.hasMultipleDifferentValues
? all_sequences.FindIndex(p => string.IsNullOrEmpty(p))
: all_sequences.FindIndex(p => p == sequence_prop.stringValue),
all_sequences.ToArray());
if ( sequence_index >= 0 && sequence_index < all_sequences.Count ) {
var new_sequence = all_sequences[sequence_index];
if ( !string.IsNullOrEmpty(new_sequence) ) {
if ( sequence_prop.hasMultipleDifferentValues ) {
sequence_prop.stringValue = string.Empty;
}
sequence_prop.stringValue = new_sequence;
sequence_prop.serializedObject.ApplyModifiedProperties();
}
}
});
}
}
void DrawCurrentFrame() {
var min_frame_count = GetMinClipsFrameCount();
if ( min_frame_count > 1 ) {
EditorGUILayout.IntSlider(
SwfEditorUtils.GetPropertyByName(serializedObject, "_currentFrame"),
0,
min_frame_count - 1,
"Current frame");
DrawClipControls();
}
}
void DrawClipControls() {
EditorGUILayout.Space();
SwfEditorUtils.DoCenterHorizontalGUI(() => {
if ( GUILayout.Button(new GUIContent("<<", "to begin frame")) ) {
AllClipsForeachWithUndo(p => p.ToBeginFrame());
}
if ( GUILayout.Button(new GUIContent("<", "to prev frame")) ) {
AllClipsForeachWithUndo(p => p.ToPrevFrame());
}
GUILayout.Label(string.Format(
"{0}/{1}",
GetClipsCurrentFrameStr(), GetClipsFrameCountStr()));
if ( GUILayout.Button(new GUIContent(">", "to next frame")) ) {
AllClipsForeachWithUndo(p => p.ToNextFrame());
}
if ( GUILayout.Button(new GUIContent(">>", "to end frame")) ) {
AllClipsForeachWithUndo(p => p.ToEndFrame());
}
});
}
void HideMaterials() {
var settings_holder = SwfSettings.GetHolder();
settings_holder.SimpleMaterial .hideFlags = HideFlags.HideInInspector;
settings_holder.IncrMaskMaterial.hideFlags = HideFlags.HideInInspector;
settings_holder.DecrMaskMaterial.hideFlags = HideFlags.HideInInspector;
foreach ( var masked_material in settings_holder.MaskedMaterials ) {
masked_material.hideFlags = HideFlags.HideInInspector;
}
}
void SetupPreviews() {
_previews.Clear();
foreach ( var clip in _clips.Where(p => !!p.clip) ) {
var preview = new SwfClipAssetPreview();
preview.Initialize(new Object[]{clip.clip});
_previews.Add(clip, preview);
}
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_clips = targets.OfType<SwfClip>().ToList();
HideMaterials();
SetupPreviews();
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
DrawSequence();
DrawCurrentFrame();
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
SetupPreviews();
}
}
public override bool RequiresConstantRepaint() {
return _previews.Count > 0;
}
public override bool HasPreviewGUI() {
return _previews.Count > 0;
}
public override void OnPreviewGUI(Rect r, GUIStyle background) {
if ( Event.current.type == EventType.Repaint ) {
SwfClipAssetPreview preview;
var clip = target as SwfClip;
if ( _previews.TryGetValue(clip, out preview) ) {
preview.SetCurrentSequence(clip.sequence);
preview.DrawPreview(r);
}
}
}
}
}

View File

@@ -0,0 +1,98 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfManager))]
public class SwfManagerEditor : Editor {
SwfManager _manager = null;
SwfList<SwfClipController> _controllers = new SwfList<SwfClipController>();
bool _groupsFoldout = true;
void DrawCounts() {
SwfEditorUtils.DoWithEnabledGUI(false, () => {
EditorGUILayout.IntField(
"Clip count",
_manager.clipCount);
EditorGUILayout.IntField(
"Controller count",
_manager.controllerCount);
});
}
void DrawControls() {
SwfEditorUtils.DoRightHorizontalGUI(() => {
if ( _manager.isPaused && GUILayout.Button("Resume") ) {
_manager.Resume();
}
if ( _manager.isPlaying && GUILayout.Button("Pause") ) {
_manager.Pause();
}
});
}
void DrawGroupControls() {
var group_names = GetAllGroupNames();
if ( group_names.Count > 0 ) {
_groupsFoldout = EditorGUILayout.Foldout(_groupsFoldout, "Groups");
if ( _groupsFoldout ) {
foreach ( var group_name in group_names ) {
SwfEditorUtils.DoWithEnabledGUI(false, () => {
EditorGUILayout.TextField("Name", group_name);
});
EditorGUI.BeginChangeCheck();
var new_rate_scale = EditorGUILayout.FloatField(
"Rate Scale", _manager.GetGroupRateScale(group_name));
if ( EditorGUI.EndChangeCheck() ) {
_manager.SetGroupRateScale(group_name, new_rate_scale);
}
SwfEditorUtils.DoRightHorizontalGUI(() => {
if ( _manager.IsGroupPaused(group_name) && GUILayout.Button("Resume") ) {
_manager.ResumeGroup(group_name);
}
if ( _manager.IsGroupPlaying(group_name) && GUILayout.Button("Pause") ) {
_manager.PauseGroup(group_name);
}
});
}
}
}
}
HashSet<string> GetAllGroupNames() {
var result = new HashSet<string>();
for ( int i = 0, e = _controllers.Count; i < e; ++i ) {
var ctrl = _controllers[i];
if ( !string.IsNullOrEmpty(ctrl.groupName) ) {
result.Add(ctrl.groupName);
}
}
return result;
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_manager = target as SwfManager;
_manager.GetAllControllers(_controllers);
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
DrawCounts();
if ( Application.isPlaying ) {
DrawControls();
DrawGroupControls();
}
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6f6448c4e793c4081bce4ef3bea5dc30
folderAsset: yes
timeCreated: 1472790065
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,468 @@
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
namespace FlashTools.Internal {
public class SwfAssetPostprocessor : AssetPostprocessor {
static void OnPostprocessAllAssets(
string[] imported_assets,
string[] deleted_assets,
string[] moved_assets,
string[] moved_from_asset_paths)
{
var asset_paths = imported_assets
.Where(p => Path.GetExtension(p).ToLower().Equals(".asset"));
foreach ( var asset_path in asset_paths ) {
var asset = AssetDatabase.LoadAssetAtPath<SwfAsset>(asset_path);
if ( asset ) {
SwfAssetProcess(asset);
}
}
}
static void SwfAssetProcess(SwfAsset asset) {
try {
if ( asset.Converting.Stage == 0 ) {
var new_data = ConfigureBitmaps(
asset,
SwfEditorUtils.DecompressAsset<SwfAssetData>(asset.Data));
asset.Data = SwfEditorUtils.CompressAsset(new_data);
++asset.Converting.Stage;
EditorUtility.SetDirty(asset);
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(asset));
} else if ( asset.Converting.Stage == 1 ) {
asset.Atlas = LoadAssetAtlas(asset);
if ( asset.Atlas ) {
ConfigureAtlas(asset);
ConfigureClips(
asset,
SwfEditorUtils.DecompressAsset<SwfAssetData>(asset.Data));
}
++asset.Converting.Stage;
EditorUtility.SetDirty(asset);
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(asset));
}
} catch ( Exception e ) {
Debug.LogErrorFormat(
"<b>[FlashTools]</b> Postprocess swf asset error: {0}",
e.Message);
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(asset));
} finally {
if ( asset ) {
UpdateAssetClips(asset);
}
}
}
static Texture2D LoadAssetAtlas(SwfAsset asset) {
return AssetDatabase.LoadAssetAtPath<Texture2D>(
GetAtlasPath(asset));
}
static string GetAtlasPath(SwfAsset asset) {
if ( asset.Atlas ) {
return AssetDatabase.GetAssetPath(asset.Atlas);
} else {
var asset_path = AssetDatabase.GetAssetPath(asset);
return Path.ChangeExtension(asset_path, "._Atlas_.png");
}
}
// ---------------------------------------------------------------------
//
// ConfigureBitmaps
//
// ---------------------------------------------------------------------
static SwfAssetData ConfigureBitmaps(SwfAsset asset, SwfAssetData data) {
var textures = data.Bitmaps
.Where (p => p.Redirect == 0)
.Select (p => new KeyValuePair<ushort, Texture2D>(
p.Id,
LoadTextureFromData(p)))
.ToList();
var rects = PackAndSaveBitmapsAtlas(
GetAtlasPath(asset),
textures.Select(p => p.Value).ToArray(),
asset.Settings);
for ( var i = 0; i < data.Bitmaps.Count; ++i ) {
var bitmap = data.Bitmaps[i];
var texture_key = bitmap.Redirect > 0 ? bitmap.Redirect : bitmap.Id;
bitmap.SourceRect = SwfRectData.FromURect(
rects[textures.FindIndex(p => p.Key == texture_key)]);
}
return data;
}
static Texture2D LoadTextureFromData(SwfBitmapData bitmap) {
var texture = new Texture2D(
bitmap.RealWidth, bitmap.RealHeight,
TextureFormat.ARGB32, false);
texture.LoadRawTextureData(bitmap.ARGB32);
return texture;
}
struct BitmapsAtlasInfo {
public Texture2D Atlas;
public Rect[] Rects;
}
static Rect[] PackAndSaveBitmapsAtlas(
string atlas_path, Texture2D[] textures, SwfSettingsData settings)
{
var atlas_info = PackBitmapsAtlas(textures, settings);
RevertTexturePremultipliedAlpha(atlas_info.Atlas);
File.WriteAllBytes(atlas_path, atlas_info.Atlas.EncodeToPNG());
GameObject.DestroyImmediate(atlas_info.Atlas, true);
AssetDatabase.ImportAsset(atlas_path);
return atlas_info.Rects;
}
static BitmapsAtlasInfo PackBitmapsAtlas(
Texture2D[] textures, SwfSettingsData settings)
{
var atlas_padding = Mathf.Max(0, settings.AtlasPadding);
var max_atlas_size = Mathf.Max(32, settings.AtlasPowerOfTwo
? Mathf.ClosestPowerOfTwo(settings.MaxAtlasSize)
: settings.MaxAtlasSize);
var atlas = new Texture2D(0, 0);
var rects = atlas.PackTextures(textures, atlas_padding, max_atlas_size);
while ( rects == null ) {
max_atlas_size = Mathf.NextPowerOfTwo(max_atlas_size + 1);
rects = atlas.PackTextures(textures, atlas_padding, max_atlas_size);
}
return settings.AtlasForceSquare && atlas.width != atlas.height
? BitmapsAtlasToSquare(atlas, rects)
: new BitmapsAtlasInfo{Atlas = atlas, Rects = rects};
}
static BitmapsAtlasInfo BitmapsAtlasToSquare(Texture2D atlas, Rect[] rects) {
var atlas_size = Mathf.Max(atlas.width, atlas.height);
var atlas_scale = new Vector2(atlas.width, atlas.height) / atlas_size;
var new_atlas = new Texture2D(atlas_size, atlas_size, TextureFormat.ARGB32, false);
for ( var i = 0; i < rects.Length; ++i ) {
var new_position = rects[i].position;
new_position.Scale(atlas_scale);
var new_size = rects[i].size;
new_size.Scale(atlas_scale);
rects[i] = new Rect(new_position, new_size);
}
var fill_pixels = new Color32[atlas_size * atlas_size];
for ( var i = 0; i < atlas_size * atlas_size; ++i ) {
fill_pixels[i] = new Color(1,1,1,0);
}
new_atlas.SetPixels32(fill_pixels);
new_atlas.SetPixels32(0, 0, atlas.width, atlas.height, atlas.GetPixels32());
new_atlas.Apply();
GameObject.DestroyImmediate(atlas, true);
return new BitmapsAtlasInfo{
Atlas = new_atlas,
Rects = rects};
}
static void RevertTexturePremultipliedAlpha(Texture2D texture) {
var pixels = texture.GetPixels();
for ( var i = 0; i < pixels.Length; ++i ) {
var c = pixels[i];
if ( c.a > 0 ) {
c.r /= c.a;
c.g /= c.a;
c.b /= c.a;
}
pixels[i] = c;
}
texture.SetPixels(pixels);
texture.Apply();
}
// ---------------------------------------------------------------------
//
// ConfigureAtlas
//
// ---------------------------------------------------------------------
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.spritePixelsPerUnit = asset.Settings.PixelsPerUnit;
atlas_importer.mipmapEnabled = asset.Settings.GenerateMipMaps;
atlas_importer.filterMode = SwfAtlasFilterToImporterFilter(asset.Settings.AtlasTextureFilter);
atlas_importer.textureFormat = SwfAtlasFormatToImporterFormat(asset.Settings.AtlasTextureFormat);
AssetDatabase.WriteImportSettingsIfDirty(atlas_path);
AssetDatabase.ImportAsset(atlas_path);
}
static TextureImporter GetBitmapsAtlasImporter(SwfAsset asset) {
var atlas_path = AssetDatabase.GetAssetPath(asset.Atlas);
var atlas_importer = AssetImporter.GetAtPath(atlas_path) as TextureImporter;
if ( !atlas_importer ) {
throw new UnityException(string.Format(
"atlas texture importer not found ({0})",
atlas_path));
}
return atlas_importer;
}
static FilterMode SwfAtlasFilterToImporterFilter(
SwfSettingsData.AtlasFilter filter)
{
switch ( filter ) {
case SwfSettingsData.AtlasFilter.Point:
return FilterMode.Point;
case SwfSettingsData.AtlasFilter.Bilinear:
return FilterMode.Bilinear;
case SwfSettingsData.AtlasFilter.Trilinear:
return FilterMode.Trilinear;
default:
throw new UnityException(string.Format(
"incorrect swf atlas filter ({0})",
filter));
}
}
static TextureImporterFormat SwfAtlasFormatToImporterFormat(
SwfSettingsData.AtlasFormat format)
{
switch ( format ) {
case SwfSettingsData.AtlasFormat.AutomaticCompressed:
return TextureImporterFormat.AutomaticCompressed;
case SwfSettingsData.AtlasFormat.Automatic16bit:
return TextureImporterFormat.Automatic16bit;
case SwfSettingsData.AtlasFormat.AutomaticTruecolor:
return TextureImporterFormat.AutomaticTruecolor;
case SwfSettingsData.AtlasFormat.AutomaticCrunched:
return TextureImporterFormat.AutomaticCrunched;
default:
throw new UnityException(string.Format(
"incorrect swf atlas format ({0})",
format));
}
}
// ---------------------------------------------------------------------
//
// ConfigureClips
//
// ---------------------------------------------------------------------
static SwfAssetData ConfigureClips(SwfAsset asset, SwfAssetData data) {
asset.Clips = asset.Clips.Where(p => !!p).ToList();
foreach ( var symbol in data.Symbols ) {
ConfigureClip(asset, data, symbol);
}
return data;
}
static void ConfigureClip(SwfAsset asset, SwfAssetData data, SwfSymbolData symbol) {
var clip_asset = asset.Clips.FirstOrDefault(p => p.Name == symbol.Name);
if ( clip_asset ) {
ConfigureClipAsset(clip_asset, asset, data, symbol);
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(clip_asset));
} else {
var asset_path = AssetDatabase.GetAssetPath(asset);
var clip_asset_path = Path.ChangeExtension(asset_path, symbol.Name + ".asset");
SwfEditorUtils.LoadOrCreateAsset<SwfClipAsset>(clip_asset_path, new_clip_asset => {
ConfigureClipAsset(new_clip_asset, asset, data, symbol);
asset.Clips.Add(new_clip_asset);
});
}
}
static void ConfigureClipAsset(
SwfClipAsset clip_asset, SwfAsset asset, SwfAssetData data, SwfSymbolData symbol)
{
clip_asset.Name = symbol.Name;
clip_asset.Atlas = asset.Atlas;
clip_asset.FrameRate = data.FrameRate;
clip_asset.Sequences = LoadClipSequences(asset, data, symbol);
}
static List<SwfClipAsset.Sequence> LoadClipSequences(
SwfAsset asset, SwfAssetData data, SwfSymbolData symbol)
{
var sequences = new List<SwfClipAsset.Sequence>();
if ( IsValidAssetsForFrame(asset, symbol) ) {
foreach ( var frame in symbol.Frames ) {
var baked_frame = BakeClipFrame(asset, data, frame);
if ( !string.IsNullOrEmpty(frame.Name) &&
(sequences.Count < 1 || sequences.Last().Name != frame.Name) )
{
sequences.Add(new SwfClipAsset.Sequence{Name = frame.Name});
} else if ( sequences.Count < 1 ) {
sequences.Add(new SwfClipAsset.Sequence{Name = "Default"});
}
sequences.Last().Frames.Add(baked_frame);
}
}
return sequences;
}
static bool IsValidAssetsForFrame(
SwfAsset asset, SwfSymbolData symbol)
{
return
asset && asset.Atlas && asset.Data != null &&
symbol != null && symbol.Frames != null;
}
class BakedGroup {
public SwfInstanceData.Types Type;
public int ClipDepth;
public int StartVertex;
public int TriangleCount;
public Material Material;
}
static SwfClipAsset.Frame BakeClipFrame(
SwfAsset asset, SwfAssetData data, SwfFrameData frame)
{
List<uint> baked_uvs = new List<uint>();
List<uint> baked_mulcolors = new List<uint>();
List<uint> baked_addcolors = new List<uint>();
List<Vector2> baked_vertices = new List<Vector2>();
List<BakedGroup> baked_groups = new List<BakedGroup>();
List<Material> baked_materials = new List<Material>();
foreach ( var inst in frame.Instances ) {
var bitmap = inst != null
? FindBitmapFromAssetData(data, inst.Bitmap)
: null;
if ( bitmap != null && IsVisibleInstance(inst) ) {
var width = bitmap.RealWidth / 20.0f;
var height = bitmap.RealHeight / 20.0f;
var v0 = new Vector2( 0, 0);
var v1 = new Vector2(width, 0);
var v2 = new Vector2(width, height);
var v3 = new Vector2( 0, height);
var matrix =
Matrix4x4.Scale(
new Vector3(1.0f, -1.0f, 1.0f) /
asset.Settings.PixelsPerUnit) *
inst.Matrix.ToUMatrix();
baked_vertices.Add(matrix.MultiplyPoint3x4(v0));
baked_vertices.Add(matrix.MultiplyPoint3x4(v1));
baked_vertices.Add(matrix.MultiplyPoint3x4(v2));
baked_vertices.Add(matrix.MultiplyPoint3x4(v3));
var source_rect = bitmap.SourceRect;
baked_uvs.Add(SwfUtils.PackUV(source_rect.xMin, source_rect.yMin));
baked_uvs.Add(SwfUtils.PackUV(source_rect.xMax, source_rect.yMax));
uint mul_pack0, mul_pack1;
SwfUtils.PackFColorToUInts(
inst.ColorTrans.mulColor,
out mul_pack0, out mul_pack1);
baked_mulcolors.Add(mul_pack0);
baked_mulcolors.Add(mul_pack1);
uint add_pack0, add_pack1;
SwfUtils.PackFColorToUInts(
inst.ColorTrans.addColor,
out add_pack0, out add_pack1);
baked_addcolors.Add(add_pack0);
baked_addcolors.Add(add_pack1);
if ( baked_groups.Count == 0 ||
baked_groups[baked_groups.Count - 1].Type != inst.Type ||
baked_groups[baked_groups.Count - 1].ClipDepth != inst.ClipDepth )
{
baked_groups.Add(new BakedGroup{
Type = inst.Type,
ClipDepth = inst.ClipDepth,
StartVertex = baked_vertices.Count - 4,
TriangleCount = 0,
Material = null
});
}
baked_groups.Last().TriangleCount += 6;
}
}
var settings_holder = SwfSettings.GetHolder();
for ( var i = 0; i < baked_groups.Count; ++i ) {
var group = baked_groups[i];
switch ( group.Type ) {
case SwfInstanceData.Types.Mask:
group.Material = settings_holder.GetIncrMaskMaterial();
break;
case SwfInstanceData.Types.Group:
group.Material = settings_holder.GetSimpleMaterial();
break;
case SwfInstanceData.Types.Masked:
group.Material = settings_holder.GetMaskedMaterial(group.ClipDepth);
break;
case SwfInstanceData.Types.MaskReset:
group.Material = settings_holder.GetDecrMaskMaterial();
break;
default:
throw new UnityException(string.Format(
"SwfAssetPostprocessor. Incorrect instance type: {0}",
group.Type));
}
if ( group.Material ) {
baked_materials.Add(group.Material);
} else {
throw new UnityException(string.Format(
"SwfAssetPostprocessor. Material for baked group ({0}) not found",
group.Type));
}
}
var mesh_data = new SwfClipAsset.MeshData{
SubMeshes = baked_groups
.Select(p => new SwfClipAsset.SubMeshData{
StartVertex = p.StartVertex,
IndexCount = p.TriangleCount})
.ToArray(),
Vertices = baked_vertices .ToArray(),
UVs = baked_uvs .ToArray(),
AddColors = baked_addcolors.ToArray(),
MulColors = baked_mulcolors.ToArray()};
return new SwfClipAsset.Frame(
mesh_data,
baked_materials.ToArray());
}
static SwfBitmapData FindBitmapFromAssetData(SwfAssetData data, int bitmap_id) {
for ( var i = 0; i < data.Bitmaps.Count; ++i ) {
var bitmap = data.Bitmaps[i];
if ( bitmap.Id == bitmap_id ) {
return bitmap;
}
}
return null;
}
static bool IsVisibleInstance(SwfInstanceData inst) {
var result_color = inst.ColorTrans.ApplyToColor(Color.white);
return result_color.a >= 0.01f;
}
// ---------------------------------------------------------------------
//
// UpdateAssetClips
//
// ---------------------------------------------------------------------
static void UpdateAssetClips(SwfAsset asset) {
var clips = Resources.FindObjectsOfTypeAll<SwfClip>();
foreach ( var clip in clips ) {
if ( clip && clip.clip && asset.Clips.Contains(clip.clip) ) {
clip.UpdateAllProperties();
}
}
}
}
}

View File

@@ -0,0 +1,217 @@
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using FlashTools.Internal.SwfTools;
using FlashTools.Internal.SwfTools.SwfTags;
using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal {
public class SwfPostprocessor : AssetPostprocessor {
static void OnPostprocessAllAssets(
string[] imported_assets,
string[] deleted_assets,
string[] moved_assets,
string[] moved_from_asset_paths)
{
var swf_paths = imported_assets
.Where(p => Path.GetExtension(p).ToLower().Equals(".swf"));
foreach ( var swf_path in swf_paths ) {
SwfFileProcess(swf_path);
}
}
static void SwfFileProcess(string swf_path) {
var swf_asset_path = Path.ChangeExtension(swf_path, ".asset");
SwfEditorUtils.LoadOrCreateAsset<SwfAsset>(swf_asset_path, swf_asset => {
SafeLoadSwfAsset(swf_path, swf_asset);
});
}
static void SafeLoadSwfAsset(string swf_path, SwfAsset swf_asset) {
try {
var new_data = LoadSwfAssetData(swf_path);
swf_asset.Data = SwfEditorUtils.CompressAsset(new_data);
swf_asset.Converting = new SwfAsset.ConvertingState();
} catch ( Exception e ) {
Debug.LogErrorFormat(
"<b>[FlashTools]</b> Parsing swf error: {0}",
e.Message);
}
}
static SwfAssetData LoadSwfAssetData(string swf_path) {
var library = new SwfLibrary();
var decoder = new SwfDecoder(swf_path);
return new SwfAssetData{
FrameRate = decoder.UncompressedHeader.FrameRate,
Symbols = LoadSymbols(library, decoder),
Bitmaps = LoadBitmaps(library)};
}
// ---------------------------------------------------------------------
//
// LoadSymbols
//
// ---------------------------------------------------------------------
static List<SwfSymbolData> LoadSymbols(
SwfLibrary library, SwfDecoder decoder)
{
var symbols = new List<SwfSymbolData>();
symbols.Add(LoadSymbol("_Stage_", library, decoder.Tags));
var sprite_defs = library.Defines.Values
.OfType<SwfLibrarySpriteDefine>()
.Where(p => !string.IsNullOrEmpty(p.ExportName));
foreach ( var sprite_def in sprite_defs ) {
var name = sprite_def.ExportName;
var tags = sprite_def.ControlTags.Tags;
symbols.Add(LoadSymbol(name, library, tags));
}
return symbols;
}
static SwfSymbolData LoadSymbol(
string symbol_name, SwfLibrary library, List<SwfTagBase> tags)
{
var disp_lst = new SwfDisplayList();
var executer = new SwfContextExecuter(library, 0);
var symbol_frames = new List<SwfFrameData>();
while ( executer.NextFrame(tags, disp_lst) ) {
symbol_frames.Add(LoadSymbolFrameData(library, disp_lst));
}
return new SwfSymbolData{
Name = symbol_name,
Frames = symbol_frames};
}
static SwfFrameData LoadSymbolFrameData(
SwfLibrary library, SwfDisplayList display_list)
{
var frame = new SwfFrameData();
frame.Name = display_list.FrameName;
return AddDisplayListToFrame(
library,
display_list,
0,
0,
null,
Matrix4x4.identity,
SwfColorTransData.identity,
frame);
}
static SwfFrameData AddDisplayListToFrame(
SwfLibrary library,
SwfDisplayList display_list,
ushort parent_masked,
ushort parent_mask,
List<SwfInstanceData> parent_masks,
Matrix4x4 parent_matrix,
SwfColorTransData parent_color_transform,
SwfFrameData frame)
{
var self_masks = new List<SwfInstanceData>();
foreach ( var inst in display_list.Instances.Values.Where(p => p.Visible) ) {
CheckSelfMasks(self_masks, inst.Depth, frame);
var child_matrix = parent_matrix * inst.Matrix.ToUMatrix();
var child_color_transform = parent_color_transform * inst.ColorTransform.ToColorTransData();
switch ( inst.Type ) {
case SwfDisplayInstanceType.Shape:
var shape_def = 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 = library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
if ( bitmap_def != null ) {
var frame_inst_type =
(parent_mask > 0 || inst.ClipDepth > 0)
? SwfInstanceData.Types.Mask
: (parent_masked > 0 || self_masks.Count > 0)
? SwfInstanceData.Types.Masked
: SwfInstanceData.Types.Group;
var frame_inst_clip_depth =
(parent_mask > 0)
? parent_mask
: (inst.ClipDepth > 0)
? inst.ClipDepth
: parent_masked + self_masks.Count;
frame.Instances.Add(new SwfInstanceData{
Type = frame_inst_type,
ClipDepth = (ushort)frame_inst_clip_depth,
Bitmap = bitmap_id,
Matrix = SwfMatrixData.FromUMatrix(child_matrix * bitmap_matrix.ToUMatrix()),
ColorTrans = child_color_transform});
if ( parent_mask > 0 ) {
parent_masks.Add(frame.Instances[frame.Instances.Count - 1]);
} else if ( inst.ClipDepth > 0 ) {
self_masks.Add(frame.Instances[frame.Instances.Count - 1]);
}
}
}
}
break;
case SwfDisplayInstanceType.Sprite:
var sprite_def = library.FindDefine<SwfLibrarySpriteDefine>(inst.Id);
if ( sprite_def != null ) {
var sprite_inst = inst as SwfDisplaySpriteInstance;
AddDisplayListToFrame(
library,
sprite_inst.DisplayList,
(ushort)(parent_masked + self_masks.Count),
(ushort)(parent_mask > 0 ? parent_mask : (inst.ClipDepth > 0 ? inst.ClipDepth : (ushort)0)),
parent_mask > 0 ? parent_masks : (inst.ClipDepth > 0 ? self_masks : null),
child_matrix,
child_color_transform,
frame);
}
break;
default:
throw new UnityException(string.Format(
"unsupported SwfDisplayInstanceType: {0}", inst.Type));
}
}
CheckSelfMasks(self_masks, ushort.MaxValue, frame);
return frame;
}
static void CheckSelfMasks(
List<SwfInstanceData> masks, ushort depth, SwfFrameData frame)
{
foreach ( var mask in masks ) {
if ( mask.ClipDepth < depth ) {
frame.Instances.Add(new SwfInstanceData{
Type = SwfInstanceData.Types.MaskReset,
ClipDepth = 0,
Bitmap = mask.Bitmap,
Matrix = mask.Matrix,
ColorTrans = mask.ColorTrans});
}
}
masks.RemoveAll(p => p.ClipDepth < depth);
}
// ---------------------------------------------------------------------
//
// LoadBitmaps
//
// ---------------------------------------------------------------------
static List<SwfBitmapData> LoadBitmaps(SwfLibrary library) {
return library.Defines
.Where (p => p.Value.Type == SwfLibraryDefineType.Bitmap)
.ToDictionary(p => p.Key, p => p.Value as SwfLibraryBitmapDefine)
.Select (p => new SwfBitmapData{
Id = p.Key,
ARGB32 = p.Value.ARGB32,
Redirect = p.Value.Redirect,
RealWidth = p.Value.Width,
RealHeight = p.Value.Height})
.ToList();
}
}
}

View File

@@ -1,252 +0,0 @@
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfAnimationAsset)), CanEditMultipleObjects]
public class SwfAnimationAssetEditor : Editor {
List<SwfAnimationAsset> _assets = new List<SwfAnimationAsset>();
bool _settingsFoldout = false;
//
//
//
static string GetAssetPath(SwfAnimationAsset asset) {
return asset
? AssetDatabase.GetAssetPath(asset)
: string.Empty;
}
static string GetSwfPath(SwfAnimationAsset asset) {
var asset_path = GetAssetPath(asset);
return string.IsNullOrEmpty(asset_path)
? string.Empty
: Path.ChangeExtension(asset_path, ".swf");
}
static string GetPrefabPath(SwfAnimationAsset asset) {
var asset_path = GetAssetPath(asset);
return string.IsNullOrEmpty(asset_path)
? string.Empty
: Path.ChangeExtension(asset_path, ".prefab");
}
//
//
//
static void RevertOverriddenSettings(SwfAnimationAsset asset) {
asset.Overridden = asset.Settings;
}
static void OverriddenSettingsToDefault(SwfAnimationAsset asset) {
asset.Overridden = SwfConverterSettings.GetDefaultSettings();
}
static void ApplyOverriddenSettings(SwfAnimationAsset asset) {
if ( File.Exists(GetSwfPath(asset)) ) {
asset.Settings = asset.Overridden;
ReconvertAnimationAsset(asset);
} else {
Debug.LogErrorFormat(
"Swf source for animation not found: '{0}'",
GetSwfPath(asset));
RevertOverriddenSettings(asset);
}
}
static void ReconvertAnimationAsset(SwfAnimationAsset asset) {
AssetDatabase.ImportAsset(
GetSwfPath(asset),
ImportAssetOptions.ForceUpdate);
}
static GameObject CreateAnimationGO(SwfAnimationAsset asset) {
if ( asset ) {
var anim_go = new GameObject(asset.name);
anim_go.AddComponent<MeshFilter>();
anim_go.AddComponent<MeshRenderer>();
anim_go.AddComponent<SwfAnimation>().asset = asset;
anim_go.AddComponent<SwfAnimationController>();
return anim_go;
}
return null;
}
static void CreateAnimationPrefab(SwfAnimationAsset asset) {
var anim_go = CreateAnimationGO(asset);
if ( anim_go ) {
var prefab_path = GetPrefabPath(asset);
if ( !string.IsNullOrEmpty(prefab_path) ) {
var prefab = AssetDatabase.LoadMainAssetAtPath(prefab_path);
if ( !prefab ) {
prefab = PrefabUtility.CreateEmptyPrefab(prefab_path);
}
PrefabUtility.ReplacePrefab(
anim_go,
prefab,
ReplacePrefabOptions.ConnectToPrefab);
}
GameObject.DestroyImmediate(anim_go, true);
}
}
static void CreateAnimationOnScene(SwfAnimationAsset asset) {
var anim_go = CreateAnimationGO(asset);
if ( anim_go ) {
Undo.RegisterCreatedObjectUndo(anim_go, "Instance SwfAnimation");
}
}
//
//
//
void AllAssetsForeach(Action<SwfAnimationAsset> act) {
foreach ( var asset in _assets ) {
act(asset);
}
}
void AllOverriddenSettingsToDefault() {
AllAssetsForeach(p => OverriddenSettingsToDefault(p));
}
void RevertAllOverriddenSettings() {
AllAssetsForeach(p => RevertOverriddenSettings(p));
}
void ApplyAllOverriddenSettings() {
AllAssetsForeach(p => ApplyOverriddenSettings(p));
}
void CreateAllAnimationPrefabs() {
AllAssetsForeach(p => CreateAnimationPrefab(p));
}
void CreateAllAnimationsOnScene() {
AllAssetsForeach(p => CreateAnimationOnScene(p));
}
//
//
//
void ShowUnappliedDialog() {
var unapplied = _assets
.Where(p => !p.Settings.CheckEquals(p.Overridden))
.ToArray();
if ( unapplied.Length > 0 ) {
var title =
"Unapplied swf animation settings";
var message = unapplied.Length == 1
? string.Format(
"Unapplied swf animation settings for '{0}'",
GetAssetPath(unapplied[0]))
: string.Format(
"Unapplied multiple({0}) swf animation settings",
unapplied.Length);
if ( EditorUtility.DisplayDialog(title, message, "Apply", "Revert") ) {
ApplyAllOverriddenSettings();
} else {
RevertAllOverriddenSettings();
}
}
}
void DrawGUISettings() {
SwfEditorUtils.DoWithEnabledGUI(false, () => {
var script_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "m_Script");
EditorGUILayout.PropertyField(script_prop, true);
var atlas_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "Atlas");
EditorGUILayout.PropertyField(atlas_prop, true);
var sequences_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "Sequences");
if ( sequences_prop.isArray ) {
SwfEditorUtils.DoWithMixedValue(
sequences_prop.hasMultipleDifferentValues, () => {
EditorGUILayout.IntField("Sequence count", sequences_prop.arraySize);
});
}
});
_settingsFoldout = EditorGUILayout.Foldout(_settingsFoldout, "Settings");
if ( _settingsFoldout ) {
var it = SwfEditorUtils.GetPropertyByName(serializedObject, "Overridden");
while ( it.NextVisible(true) ) {
EditorGUILayout.PropertyField(it, true);
}
DrawGUISettingsControls();
}
}
void DrawGUISettingsControls() {
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
{
var default_settings = SwfConverterSettings.GetDefaultSettings();
SwfEditorUtils.DoWithEnabledGUI(
_assets.Any(p => !p.Overridden.CheckEquals(default_settings)), () => {
if ( GUILayout.Button("Default") ) {
AllOverriddenSettingsToDefault();
}
});
SwfEditorUtils.DoWithEnabledGUI(
_assets.Any(p => !p.Overridden.CheckEquals(p.Settings)), () => {
if ( GUILayout.Button("Revert") ) {
RevertAllOverriddenSettings();
}
if ( GUILayout.Button("Apply") ) {
ApplyAllOverriddenSettings();
}
});
}
GUILayout.EndHorizontal();
}
void DrawGUIAnimation() {
GUILayout.BeginHorizontal();
{
if ( GUILayout.Button("Create prefab") ) {
CreateAllAnimationPrefabs();
}
if ( GUILayout.Button("Instance to scene") ) {
CreateAllAnimationsOnScene();
}
}
GUILayout.EndHorizontal();
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_assets = targets
.OfType<SwfAnimationAsset>()
.ToList();
_settingsFoldout =
_assets.Any(p => !p.Settings.CheckEquals(SwfConverterSettings.GetDefaultSettings()));
}
void OnDisable() {
ShowUnappliedDialog();
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawGUISettings();
DrawGUIAnimation();
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
}
}

View File

@@ -1,340 +0,0 @@
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
namespace FlashTools.Internal {
public class SwfAnimationAssetPostprocessor : AssetPostprocessor {
static void OnPostprocessAllAssets(
string[] imported_assets,
string[] deleted_assets,
string[] moved_assets,
string[] moved_from_asset_paths)
{
var asset_paths = imported_assets
.Where(p => Path.GetExtension(p).ToLower().Equals(".asset"));
foreach ( var asset_path in asset_paths ) {
var asset = AssetDatabase.LoadAssetAtPath<SwfAnimationAsset>(asset_path);
if ( asset ) {
AssetProcess(asset_path, asset);
}
}
}
static void AssetProcess(string asset_path, SwfAnimationAsset asset) {
try {
var atlas_asset = LoadAtlasAsset(asset_path);
if ( atlas_asset != asset.Atlas ) {
asset.Atlas = atlas_asset;
ConfigureAtlas(asset_path, asset);
ConfigureBakedFrames(asset_path, asset);
EditorUtility.SetDirty(asset);
AssetDatabase.SaveAssets();
}
ConfigureAssetAnimations(asset);
} catch ( Exception e ) {
Debug.LogErrorFormat(
"Postprocess swf animation asset error: {0}",
e.Message);
SwfEditorUtils.DeleteAnimationAssetWithDepends(asset);
}
}
static Texture2D LoadAtlasAsset(string asset_path) {
return AssetDatabase.LoadAssetAtPath<Texture2D>(
GetAtlasPath(asset_path));
}
static string GetAtlasPath(string asset_path) {
return Path.ChangeExtension(asset_path, ".png");
}
// ---------------------------------------------------------------------
//
// ConfigureAtlas
//
// ---------------------------------------------------------------------
static void ConfigureAtlas(string asset_path, SwfAnimationAsset asset) {
var atlas_importer = GetBitmapsAtlasImporter(asset_path);
var atlas_importer_size = GetSizeFromTextureImporter(atlas_importer);
atlas_importer.spritesheet = asset.Data.Bitmaps
.Select(bitmap => new SpriteMetaData{
name = bitmap.Id.ToString(),
rect = new Rect(
bitmap.SourceRect.xMin * atlas_importer_size.x,
bitmap.SourceRect.yMin * atlas_importer_size.y,
bitmap.SourceRect.width * atlas_importer_size.x,
bitmap.SourceRect.height * atlas_importer_size.y)})
.ToArray();
atlas_importer.textureType = TextureImporterType.Sprite;
atlas_importer.spriteImportMode = SpriteImportMode.Multiple;
atlas_importer.spritePixelsPerUnit = asset.Settings.PixelsPerUnit;
atlas_importer.mipmapEnabled = asset.Settings.GenerateMipMaps;
atlas_importer.filterMode = SwfAtlasFilterToImporterFilter(asset.Settings.AtlasTextureFilter);
atlas_importer.textureFormat = SwfAtlasFormatToImporterFormat(asset.Settings.AtlasTextureFormat);
AssetDatabase.ImportAsset(
GetAtlasPath(asset_path),
ImportAssetOptions.ForceUpdate);
}
static TextureImporter GetBitmapsAtlasImporter(string asset_path) {
var atlas_path = GetAtlasPath(asset_path);
var atlas_importer = AssetImporter.GetAtPath(atlas_path) as TextureImporter;
if ( !atlas_importer ) {
throw new UnityException(string.Format(
"atlas texture importer not found ({0})",
atlas_path));
}
return atlas_importer;
}
static Vector2 GetSizeFromTextureImporter(TextureImporter importer) {
var method_args = new object[2]{0,0};
typeof(TextureImporter)
.GetMethod("GetWidthAndHeight", BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(importer, method_args);
return new Vector2((int)method_args[0], (int)method_args[1]);
}
static FilterMode SwfAtlasFilterToImporterFilter(
SwfSettings.AtlasFilter filter)
{
switch ( filter ) {
case SwfSettings.AtlasFilter.Point:
return FilterMode.Point;
case SwfSettings.AtlasFilter.Bilinear:
return FilterMode.Bilinear;
case SwfSettings.AtlasFilter.Trilinear:
return FilterMode.Trilinear;
default:
throw new UnityException(string.Format(
"incorrect swf atlas filter ({0})",
filter));
}
}
static TextureImporterFormat SwfAtlasFormatToImporterFormat(
SwfSettings.AtlasFormat format)
{
switch ( format ) {
case SwfSettings.AtlasFormat.AutomaticCompressed:
return TextureImporterFormat.AutomaticCompressed;
case SwfSettings.AtlasFormat.Automatic16bit:
return TextureImporterFormat.Automatic16bit;
case SwfSettings.AtlasFormat.AutomaticTruecolor:
return TextureImporterFormat.AutomaticTruecolor;
case SwfSettings.AtlasFormat.AutomaticCrunched:
return TextureImporterFormat.AutomaticCrunched;
default:
throw new UnityException(string.Format(
"incorrect swf atlas format ({0})",
format));
}
}
// ---------------------------------------------------------------------
//
// ConfigureBakedFrames
//
// ---------------------------------------------------------------------
class BakedGroup {
public SwfAnimationInstanceType Type;
public int ClipDepth;
public List<int> Triangles;
public Material Material;
}
static void ConfigureBakedFrames(string asset_path, SwfAnimationAsset asset) {
RemoveAllSubAssets(asset_path);
var sequences = new List<SwfAnimationAsset.Sequence>();
if ( IsValidAssetForFrame(asset) ) {
for ( var i = 0; i < asset.Data.Frames.Count; ++i ) {
var frame = asset.Data.Frames[i];
var baked_frame = BakeFrameFromAnimationFrame(asset, frame);
if ( !string.IsNullOrEmpty(frame.Name) &&
(sequences.Count < 1 || sequences.Last().Name != frame.Name) )
{
sequences.Add(new SwfAnimationAsset.Sequence{Name = frame.Name});
} else if ( sequences.Count < 1 ) {
sequences.Add(new SwfAnimationAsset.Sequence{Name = "Default"});
}
sequences.Last().Frames.Add(baked_frame);
}
}
asset.Sequences = sequences;
}
static void RemoveAllSubAssets(string asset_path) {
var assets = AssetDatabase.LoadAllAssetsAtPath(asset_path);
for ( var i = 0; i < assets.Length; ++i ) {
var asset = assets[i];
if ( !AssetDatabase.IsMainAsset(asset) ) {
GameObject.DestroyImmediate(asset, true);
}
}
}
static bool IsValidAssetForFrame(SwfAnimationAsset asset) {
return
asset && asset.Atlas &&
asset.Data != null && asset.Data.Frames != null;
}
static SwfAnimationAsset.Frame BakeFrameFromAnimationFrame(
SwfAnimationAsset asset, SwfAnimationFrameData frame)
{
List<Vector2> baked_uvs = new List<Vector2>();
List<Color> baked_mulcolors = new List<Color>();
List<Vector4> baked_addcolors = new List<Vector4>();
List<Vector3> baked_vertices = new List<Vector3>();
List<BakedGroup> baked_groups = new List<BakedGroup>();
List<Material> baked_materials = new List<Material>();
for ( var i = 0; i < frame.Instances.Count; ++i ) {
var inst = frame.Instances[i];
var bitmap = inst != null
? FindBitmapFromAnimationData(asset.Data, inst.Bitmap)
: null;
if ( bitmap != null ) {
var width = bitmap.RealSize.x / 20.0f;
var height = bitmap.RealSize.y / 20.0f;
var v0 = new Vector3( 0, 0, 0);
var v1 = new Vector3(width, 0, 0);
var v2 = new Vector3(width, height, 0);
var v3 = new Vector3( 0, height, 0);
var frame_offset = Matrix4x4.TRS(
new Vector2(
-asset.Data.FrameSize.x * 0.5f / asset.Settings.PixelsPerUnit,
+asset.Data.FrameSize.y * 0.5f / asset.Settings.PixelsPerUnit),
Quaternion.identity,
Vector3.one);
var matrix =
frame_offset *
Matrix4x4.Scale(new Vector3(
+1.0f / asset.Settings.PixelsPerUnit,
-1.0f / asset.Settings.PixelsPerUnit,
+1.0f / asset.Settings.PixelsPerUnit)) *
inst.Matrix;
baked_vertices.Add(matrix.MultiplyPoint3x4(v0));
baked_vertices.Add(matrix.MultiplyPoint3x4(v1));
baked_vertices.Add(matrix.MultiplyPoint3x4(v2));
baked_vertices.Add(matrix.MultiplyPoint3x4(v3));
var source_rect = bitmap.SourceRect;
baked_uvs.Add(new Vector2(source_rect.xMin, source_rect.yMin));
baked_uvs.Add(new Vector2(source_rect.xMax, source_rect.yMin));
baked_uvs.Add(new Vector2(source_rect.xMax, source_rect.yMax));
baked_uvs.Add(new Vector2(source_rect.xMin, source_rect.yMax));
baked_mulcolors.Add(inst.ColorTransform.Mul);
baked_mulcolors.Add(inst.ColorTransform.Mul);
baked_mulcolors.Add(inst.ColorTransform.Mul);
baked_mulcolors.Add(inst.ColorTransform.Mul);
baked_addcolors.Add(inst.ColorTransform.Add);
baked_addcolors.Add(inst.ColorTransform.Add);
baked_addcolors.Add(inst.ColorTransform.Add);
baked_addcolors.Add(inst.ColorTransform.Add);
if ( baked_groups.Count == 0 ||
baked_groups[baked_groups.Count - 1].Type != inst.Type ||
baked_groups[baked_groups.Count - 1].ClipDepth != inst.ClipDepth )
{
baked_groups.Add(new BakedGroup{
Type = inst.Type,
ClipDepth = inst.ClipDepth,
Triangles = new List<int>(),
Material = null
});
}
baked_groups.Last().Triangles.Add(baked_vertices.Count - 4 + 2);
baked_groups.Last().Triangles.Add(baked_vertices.Count - 4 + 1);
baked_groups.Last().Triangles.Add(baked_vertices.Count - 4 + 0);
baked_groups.Last().Triangles.Add(baked_vertices.Count - 4 + 0);
baked_groups.Last().Triangles.Add(baked_vertices.Count - 4 + 3);
baked_groups.Last().Triangles.Add(baked_vertices.Count - 4 + 2);
}
}
var default_converter = SwfConverterSettings.GetDefaultConverter();
for ( var i = 0; i < baked_groups.Count; ++i ) {
var group = baked_groups[i];
switch ( group.Type ) {
case SwfAnimationInstanceType.Mask:
group.Material = default_converter.GetIncrMaskMaterial();
break;
case SwfAnimationInstanceType.Group:
group.Material = default_converter.GetSimpleMaterial();
break;
case SwfAnimationInstanceType.Masked:
group.Material = default_converter.GetMaskedMaterial(group.ClipDepth);
break;
case SwfAnimationInstanceType.MaskReset:
group.Material = default_converter.GetDecrMaskMaterial();
break;
default:
throw new UnityException(string.Format(
"SwfAnimationAssetPostprocessor. Incorrect instance type: {0}",
group.Type));
}
if ( group.Material ) {
group.Material.hideFlags = HideFlags.HideInInspector;
baked_materials.Add(group.Material);
} else {
throw new UnityException(string.Format(
"SwfAnimationAssetPostprocessor. Material for baked group ({0}) not found",
group.Type));
}
}
var mesh = new Mesh();
mesh.subMeshCount = baked_groups.Count;
mesh.SetVertices(baked_vertices);
for ( var i = 0; i < baked_groups.Count; ++i ) {
mesh.SetTriangles(baked_groups[i].Triangles, i);
}
mesh.SetUVs(0, baked_uvs);
mesh.SetUVs(1, baked_addcolors);
mesh.SetColors(baked_mulcolors);
mesh.RecalculateNormals();
AssetDatabase.AddObjectToAsset(mesh, asset);
return new SwfAnimationAsset.Frame{
Mesh = mesh,
Materials = baked_materials.ToArray()};
}
static SwfAnimationBitmapData FindBitmapFromAnimationData(SwfAnimationData data, int bitmap_id) {
for ( var i = 0; i < data.Bitmaps.Count; ++i ) {
var bitmap = data.Bitmaps[i];
if ( bitmap.Id == bitmap_id ) {
return bitmap;
}
}
return null;
}
// ---------------------------------------------------------------------
//
// ConfigureAssetAnimations
//
// ---------------------------------------------------------------------
static void ConfigureAssetAnimations(SwfAnimationAsset asset) {
var animations = GameObject.FindObjectsOfType<SwfAnimation>();
foreach ( var animation in animations ) {
animation.UpdateAllProperties();
}
}
}
}

View File

@@ -1,62 +0,0 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfAnimationController)), CanEditMultipleObjects]
public class SwfAnimationControllerEditor : Editor {
List<SwfAnimationController> _controllers = new List<SwfAnimationController>();
void AllControllersForeach(Action<SwfAnimationController> act) {
foreach ( var controller in _controllers ) {
act(controller);
}
}
void DrawAnimationControls() {
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
{
if ( GUILayout.Button("Stop") ) {
AllControllersForeach(p => p.Stop());
}
if ( GUILayout.Button("Pause") ) {
AllControllersForeach(p => p.Pause());
}
if ( GUILayout.Button("Resume") ) {
AllControllersForeach(p => p.Resume());
}
if ( GUILayout.Button("Play") ) {
AllControllersForeach(p => p.Play());
}
}
GUILayout.EndHorizontal();
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_controllers = targets
.OfType<SwfAnimationController>()
.ToList();
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
if ( Application.isPlaying ) {
DrawAnimationControls();
}
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
}
}

View File

@@ -1,155 +0,0 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfAnimation)), CanEditMultipleObjects]
public class SwfAnimationEditor : Editor {
List<SwfAnimation> _animations = new List<SwfAnimation>();
void AllAnimationsForeachWithUndo(Action<SwfAnimation> act) {
Undo.RecordObjects(
_animations.ToArray(),
"Inspector");
foreach ( var animation in _animations ) {
act(animation);
EditorUtility.SetDirty(animation);
}
}
int GetMinAnimationsFrameCount() {
return _animations.Count > 0
? _animations.Min(anim => anim.frameCount)
: 0;
}
string GetAnimationsFrameCountStr() {
return _animations.Aggregate(string.Empty, (acc, anim) => {
var frame_count = anim.frameCount > 0 ? anim.frameCount - 1 : 0;
var frame_count_str = frame_count.ToString();
return string.IsNullOrEmpty(acc)
? frame_count_str
: (acc != frame_count_str ? "--" : acc);
});
}
string GetAnimationsCurrentFrameStr() {
return _animations.Aggregate(string.Empty, (acc, anim) => {
var current_frame = anim.currentFrame;
var current_frame_str = current_frame.ToString();
return string.IsNullOrEmpty(acc)
? current_frame_str
: (acc != current_frame_str ? "--" : acc);
});
}
bool IsAllAnimationsHasOneAsset() {
foreach ( var animation in _animations ) {
if ( !animation.asset ) {
return false;
}
if ( animation.asset != _animations.First().asset ) {
return false;
}
}
return true;
}
List<string> GetAllSequences(bool include_empty) {
var seq_set = new HashSet<string>(_animations
.Where(p => p.asset)
.SelectMany(p => p.asset.Sequences)
.Select(p => p.Name));
if ( include_empty ) {
seq_set.Add(string.Empty);
}
return seq_set.ToList();
}
void DrawSequence() {
if ( IsAllAnimationsHasOneAsset() ) {
var sequence_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "_sequence");
SwfEditorUtils.DoWithMixedValue(
sequence_prop.hasMultipleDifferentValues, () => {
var all_sequences = GetAllSequences(true);
var sequence_index = EditorGUILayout.Popup(
"Sequence",
sequence_prop.hasMultipleDifferentValues
? all_sequences.FindIndex(p => string.IsNullOrEmpty(p))
: all_sequences.FindIndex(p => p == sequence_prop.stringValue),
all_sequences.ToArray());
var new_sequence = all_sequences[sequence_index];
if ( !string.IsNullOrEmpty(new_sequence) ) {
if ( sequence_prop.hasMultipleDifferentValues ) {
sequence_prop.stringValue = string.Empty;
}
sequence_prop.stringValue = new_sequence;
sequence_prop.serializedObject.ApplyModifiedProperties();
}
});
}
}
void DrawCurrentFrame() {
var min_frame_count = GetMinAnimationsFrameCount();
if ( min_frame_count > 0 ) {
EditorGUILayout.IntSlider(
SwfEditorUtils.GetPropertyByName(serializedObject, "_currentFrame"),
0,
min_frame_count - 1,
"Current frame");
}
}
void DrawAnimationControls() {
EditorGUILayout.Space();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
{
if ( GUILayout.Button(new GUIContent("<<", "to begin frame")) ) {
AllAnimationsForeachWithUndo(p => p.ToBeginFrame());
}
if ( GUILayout.Button(new GUIContent("<", "to prev frame")) ) {
AllAnimationsForeachWithUndo(p => p.ToPrevFrame());
}
GUILayout.Label(string.Format(
"{0}/{1}",
GetAnimationsCurrentFrameStr(), GetAnimationsFrameCountStr()));
if ( GUILayout.Button(new GUIContent(">", "to next frame")) ) {
AllAnimationsForeachWithUndo(p => p.ToNextFrame());
}
if ( GUILayout.Button(new GUIContent(">>", "to end frame")) ) {
AllAnimationsForeachWithUndo(p => p.ToEndFrame());
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_animations = targets
.OfType<SwfAnimation>()
.ToList();
}
public override void OnInspectorGUI() {
serializedObject.Update();
DrawDefaultInspector();
DrawSequence();
DrawCurrentFrame();
DrawAnimationControls();
if ( GUI.changed ) {
serializedObject.ApplyModifiedProperties();
}
}
}
}

View File

@@ -1,22 +1,69 @@
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using Ionic.Zlib;
namespace FlashTools.Internal {
public static class SwfEditorUtils {
public static void DoWithMixedValue(bool mixed, Action act) {
// ---------------------------------------------------------------------
//
// Functions
//
// ---------------------------------------------------------------------
public static void DoWithMixedValue(bool mixed, System.Action act) {
var last_show_mixed_value = EditorGUI.showMixedValue;
EditorGUI.showMixedValue = mixed;
act();
EditorGUI.showMixedValue = last_show_mixed_value;
try {
act();
} finally {
EditorGUI.showMixedValue = last_show_mixed_value;
}
}
public static void DoWithEnabledGUI(bool enabled, Action act) {
var last_gui_enabled = GUI.enabled;
GUI.enabled = enabled;
act();
GUI.enabled = last_gui_enabled;
public static void DoWithEnabledGUI(bool enabled, System.Action act) {
EditorGUI.BeginDisabledGroup(true);
try {
act();
} finally {
EditorGUI.EndDisabledGroup();
}
}
public static void DoHorizontalGUI(System.Action act) {
GUILayout.BeginHorizontal();
try {
act();
} finally {
GUILayout.EndHorizontal();
}
}
public static void DoRightHorizontalGUI(System.Action act) {
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
try {
act();
} finally {
GUILayout.EndHorizontal();
}
}
public static void DoCenterHorizontalGUI(System.Action act) {
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
try {
act();
} finally {
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
}
public static SerializedProperty GetPropertyByName(SerializedObject obj, string name) {
@@ -29,15 +76,85 @@ namespace FlashTools.Internal {
return prop;
}
public static void DeleteAnimationAssetWithDepends(SwfAnimationAsset asset) {
if ( asset ) {
if ( asset.Atlas ) {
AssetDatabase.DeleteAsset(
AssetDatabase.GetAssetPath(asset.Atlas));
public static void RemoveAllSubAssets(string asset_path) {
var assets = AssetDatabase.LoadAllAssetsAtPath(asset_path);
foreach ( var asset in assets ) {
if ( !AssetDatabase.IsMainAsset(asset) ) {
GameObject.DestroyImmediate(asset, true);
}
AssetDatabase.DeleteAsset(
AssetDatabase.GetAssetPath(asset));
}
}
public static T LoadOrCreateAsset<T>(string asset_path, System.Action<T> act) where T : ScriptableObject {
var asset = AssetDatabase.LoadAssetAtPath<T>(asset_path);
if ( asset ) {
act(asset);
} else {
asset = ScriptableObject.CreateInstance<T>();
act(asset);
AssetDatabase.CreateAsset(asset, asset_path);
}
AssetDatabase.ImportAsset(asset_path);
return asset;
}
public static byte[] CompressAsset<T>(T asset) {
var bytes = AssetToBytes(asset);
var result = ZlibStream.CompressBuffer(bytes);
return result;
}
public static T DecompressAsset<T>(byte[] data) {
var bytes = ZlibStream.UncompressBuffer(data);
var result = BytesToAsset<T>(bytes);
return result;
}
static byte[] AssetToBytes<T>(T asset) {
var formatter = new BinaryFormatter();
using ( var stream = new MemoryStream() ) {
formatter.Serialize(stream, asset);
return stream.ToArray();
}
}
static T BytesToAsset<T>(byte[] bytes) {
var formatter = new BinaryFormatter();
using ( var stream = new MemoryStream(bytes) ) {
return (T)formatter.Deserialize(stream);
}
}
// ---------------------------------------------------------------------
//
// Internal
//
// ---------------------------------------------------------------------
[MenuItem("Tools/FlashTools/Open settings...")]
static void Tools_FlashTools_OpenSettings() {
var settings_holder = SwfSettings.GetHolder();
Selection.objects = new Object[]{settings_holder};
}
[MenuItem("Tools/FlashTools/Reimport all swf files")]
static void Tools_FlashTools_ReimportAllSwfFiles() {
var swf_paths = GetAllSwfFilePaths();
var title = "Reimport";
var message = string.Format(
"Do you really want to reimport all ({0}) swf files?",
swf_paths.Length);
if ( EditorUtility.DisplayDialog(title, message, "Ok", "Cancel") ) {
foreach ( var swf_path in swf_paths ) {
AssetDatabase.ImportAsset(swf_path);
}
}
}
static string[] GetAllSwfFilePaths() {
return AssetDatabase.GetAllAssetPaths()
.Where(p => Path.GetExtension(p).ToLower().Equals(".swf"))
.ToArray();
}
}
}

View File

@@ -1,32 +0,0 @@
using UnityEngine;
using UnityEditor;
namespace FlashTools.Internal {
[CustomEditor(typeof(SwfManager))]
public class SwfManagerEditor : Editor {
SwfManager _manager = null;
void DrawAnimationCount() {
SwfEditorUtils.DoWithEnabledGUI(false, () => {
EditorGUILayout.IntField(
"Animation count",
_manager.AllAnimationCount);
});
}
// ---------------------------------------------------------------------
//
// Messages
//
// ---------------------------------------------------------------------
void OnEnable() {
_manager = target as SwfManager;
}
public override void OnInspectorGUI() {
DrawDefaultInspector();
DrawAnimationCount();
}
}
}

View File

@@ -1,299 +0,0 @@
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using FlashTools.Internal.SwfTools;
using FlashTools.Internal.SwfTools.SwfTags;
using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal {
public class SwfPostprocessor : AssetPostprocessor {
static void OnPostprocessAllAssets(
string[] imported_assets,
string[] deleted_assets,
string[] moved_assets,
string[] moved_from_asset_paths)
{
var swf_asset_paths = imported_assets
.Where(p => Path.GetExtension(p).ToLower().Equals(".swf"));
foreach ( var swf_asset_path in swf_asset_paths ) {
SwfAssetProcess(swf_asset_path);
}
}
static void SwfAssetProcess(string swf_asset) {
var new_asset_path = Path.ChangeExtension(swf_asset, ".asset");
var new_asset = AssetDatabase.LoadAssetAtPath<SwfAnimationAsset>(new_asset_path);
if ( !new_asset ) {
new_asset = ScriptableObject.CreateInstance<SwfAnimationAsset>();
AssetDatabase.CreateAsset(new_asset, new_asset_path);
}
if ( LoadDataFromSwfFile(swf_asset, new_asset) ) {
EditorUtility.SetDirty(new_asset);
AssetDatabase.SaveAssets();
} else {
SwfEditorUtils.DeleteAnimationAssetWithDepends(new_asset);
}
}
static bool LoadDataFromSwfFile(string swf_asset, SwfAnimationAsset asset) {
try {
if ( asset.Atlas ) {
AssetDatabase.DeleteAsset(
AssetDatabase.GetAssetPath(asset.Atlas));
asset.Atlas = null;
}
asset.Data = LoadAnimationDataFromSwfDecoder(
swf_asset,
asset,
new SwfDecoder(swf_asset));
return true;
} catch ( Exception e ) {
Debug.LogErrorFormat("Parsing swf error: {0}", e.Message);
return false;
}
}
static SwfAnimationData LoadAnimationDataFromSwfDecoder(
string swf_asset, SwfAnimationAsset asset, SwfDecoder decoder)
{
var animation_data = new SwfAnimationData{
FrameRate = decoder.UncompressedHeader.FrameRate,
FrameSize = decoder.UncompressedHeader.FrameSize.ToUnityVectorSize()
};
var context = new SwfContext();
var executer = new SwfContextExecuter(context, 0);
while ( executer.NextFrame(decoder.Tags, context.DisplayList) ) {
animation_data.Frames.Add(
LoadAnimationFrameFromContext(context));
}
animation_data.Bitmaps = LoadBitmapsFromContext(swf_asset, asset, context);
return animation_data;
}
static SwfAnimationFrameData LoadAnimationFrameFromContext(SwfContext context) {
var frame = new SwfAnimationFrameData();
frame.Name = context.DisplayList.FrameName;
return AddDisplayListToFrame(
context,
context.DisplayList,
0,
0,
null,
Matrix4x4.identity,
SwfAnimationColorTransform.identity,
frame);
}
static SwfAnimationFrameData AddDisplayListToFrame(
SwfContext ctx,
SwfDisplayList dl,
ushort parent_masked,
ushort parent_mask,
List<SwfAnimationInstanceData> parent_masks,
Matrix4x4 parent_matrix,
SwfAnimationColorTransform parent_color_transform,
SwfAnimationFrameData frame)
{
var self_masks = new List<SwfAnimationInstanceData>();
foreach ( var inst in dl.Instances.Values.Where(p => p.Visible) ) {
CheckSelfMasks(self_masks, inst.Depth, frame);
var child_matrix = parent_matrix * inst.Matrix.ToUnityMatrix();
var child_color_transform = parent_color_transform * inst.ColorTransform.ToAnimationColorTransform();
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);
if ( bitmap_def != null ) {
var frame_inst_type =
(parent_mask > 0 || inst.ClipDepth > 0)
? SwfAnimationInstanceType.Mask
: (parent_masked > 0 || self_masks.Count > 0)
? SwfAnimationInstanceType.Masked
: SwfAnimationInstanceType.Group;
var frame_inst_clip_depth =
(parent_mask > 0)
? parent_mask
: (inst.ClipDepth > 0)
? inst.ClipDepth
: parent_masked + self_masks.Count;
frame.Instances.Add(new SwfAnimationInstanceData{
Type = frame_inst_type,
ClipDepth = (ushort)frame_inst_clip_depth,
Bitmap = bitmap_id,
Matrix = child_matrix * bitmap_matrix.ToUnityMatrix(),
ColorTransform = child_color_transform});
if ( parent_mask > 0 ) {
parent_masks.Add(frame.Instances[frame.Instances.Count - 1]);
} else if ( inst.ClipDepth > 0 ) {
self_masks.Add(frame.Instances[frame.Instances.Count - 1]);
}
}
}
}
break;
case SwfDisplayInstanceType.Sprite:
var sprite_def = ctx.Library.FindDefine<SwfLibrarySpriteDefine>(inst.Id);
if ( sprite_def != null ) {
var sprite_inst = inst as SwfDisplaySpriteInstance;
AddDisplayListToFrame(
ctx,
sprite_inst.DisplayList,
(ushort)(parent_masked + self_masks.Count),
(ushort)(parent_mask > 0 ? parent_mask : (inst.ClipDepth > 0 ? inst.ClipDepth : (ushort)0)),
parent_mask > 0 ? parent_masks : (inst.ClipDepth > 0 ? self_masks : null),
child_matrix,
child_color_transform,
frame);
}
break;
default:
throw new UnityException(string.Format(
"Unsupported SwfDisplayInstanceType: {0}", inst.Type));
}
}
CheckSelfMasks(self_masks, ushort.MaxValue, frame);
return frame;
}
static void CheckSelfMasks(
List<SwfAnimationInstanceData> masks, ushort depth, SwfAnimationFrameData frame)
{
foreach ( var mask in masks ) {
if ( mask.ClipDepth < depth ) {
frame.Instances.Add(new SwfAnimationInstanceData{
Type = SwfAnimationInstanceType.MaskReset,
ClipDepth = 0,
Bitmap = mask.Bitmap,
Matrix = mask.Matrix,
ColorTransform = mask.ColorTransform
});
}
}
masks.RemoveAll(p => p.ClipDepth < depth);
}
static List<SwfAnimationBitmapData> LoadBitmapsFromContext(
string swf_asset, SwfAnimationAsset asset, SwfContext context)
{
var bitmap_defines = context.Library.Defines
.Where (p => p.Value.Type == SwfLibraryDefineType.Bitmap)
.Select (p => new KeyValuePair<int, SwfLibraryBitmapDefine>(p.Key, p.Value as SwfLibraryBitmapDefine))
.ToArray();
var textures = bitmap_defines
.Select (p => LoadTextureFromBitmapDefine(p.Value))
.ToArray();
var rects = PackAndSaveBitmapsAtlas(
swf_asset,
textures,
asset.Settings);
var bitmaps = new List<SwfAnimationBitmapData>(bitmap_defines.Length);
for ( var i = 0; i < bitmap_defines.Length; ++i ) {
var bitmap_define = bitmap_defines[i];
var bitmap_data = new SwfAnimationBitmapData{
Id = bitmap_define.Key,
RealSize = new Vector2(bitmap_define.Value.Width, bitmap_define.Value.Height),
SourceRect = rects[i]
};
bitmaps.Add(bitmap_data);
}
return bitmaps;
}
static Texture2D LoadTextureFromBitmapDefine(SwfLibraryBitmapDefine bitmap) {
var texture = new Texture2D(
bitmap.Width, bitmap.Height,
TextureFormat.ARGB32, false);
texture.LoadRawTextureData(bitmap.ARGB32);
RevertTexturePremultipliedAlpha(texture);
return texture;
}
static void RevertTexturePremultipliedAlpha(Texture2D texture) {
for ( int y = 0; y < texture.height; ++y ) {
for ( int x = 0; x < texture.width; ++x ) {
var c = texture.GetPixel(x, y);
if ( c.a > 0 ) {
c.r /= c.a;
c.g /= c.a;
c.b /= c.a;
}
texture.SetPixel(x, y, c);
}
}
texture.Apply();
}
struct BitmapsAtlasInfo {
public Texture2D Atlas;
public Rect[] Rects;
}
static string GetAtlasPath(string swf_asset) {
return Path.ChangeExtension(swf_asset, ".png");
}
static Rect[] PackAndSaveBitmapsAtlas(
string swf_asset,
Texture2D[] textures,
SwfSettings settings)
{
var atlas_info = PackBitmapsAtlas(textures, settings);
File.WriteAllBytes(
GetAtlasPath(swf_asset),
atlas_info.Atlas.EncodeToPNG());
GameObject.DestroyImmediate(atlas_info.Atlas, true);
AssetDatabase.ImportAsset(
GetAtlasPath(swf_asset),
ImportAssetOptions.ForceUpdate);
return atlas_info.Rects;
}
static BitmapsAtlasInfo PackBitmapsAtlas(
Texture2D[] textures,
SwfSettings settings)
{
var atlas_padding = Mathf.Max(0, settings.AtlasPadding);
var max_atlas_size = Mathf.Max(32, settings.AtlasPowerOfTwo
? Mathf.ClosestPowerOfTwo(settings.MaxAtlasSize)
: settings.MaxAtlasSize);
var atlas = new Texture2D(0, 0);
var rects = atlas.PackTextures(textures, atlas_padding, max_atlas_size);
return settings.AtlasForceSquare && atlas.width != atlas.height
? BitmapsAtlasToSquare(atlas, rects)
: new BitmapsAtlasInfo{Atlas = atlas, Rects = rects};
}
static BitmapsAtlasInfo BitmapsAtlasToSquare(Texture2D atlas, Rect[] rects) {
var atlas_size = Mathf.Max(atlas.width, atlas.height);
var atlas_scale = new Vector2(atlas.width, atlas.height) / atlas_size;
var new_atlas = new Texture2D(atlas_size, atlas_size, TextureFormat.ARGB32, false);
for ( var i = 0; i < rects.Length; ++i ) {
var new_position = rects[i].position;
new_position.Scale(atlas_scale);
var new_size = rects[i].size;
new_size.Scale(atlas_scale);
rects[i] = new Rect(new_position, new_size);
}
var fill_pixels = new Color32[atlas_size * atlas_size];
for ( var i = 0; i < atlas_size * atlas_size; ++i ) {
fill_pixels[i] = new Color(1,1,1,0);
}
new_atlas.SetPixels32(fill_pixels);
new_atlas.SetPixels32(0, 0, atlas.width, atlas.height, atlas.GetPixels32());
new_atlas.Apply();
GameObject.DestroyImmediate(atlas, true);
return new BitmapsAtlasInfo{Atlas = new_atlas, Rects = rects};
}
}
}

View File

@@ -4,7 +4,7 @@ using UnityEditor;
using System.Linq;
using System.Collections.Generic;
namespace FlashTools.Internal.SwfEditorTools {
namespace FlashTools.Internal {
//
// SwfIntRange
@@ -103,6 +103,7 @@ namespace FlashTools.Internal.SwfEditorTools {
if ( property.propertyType == SerializedPropertyType.String ) {
var all_sorting_layers = GetAllSortingLayers(false);
if ( !all_sorting_layers.Contains(property.stringValue) ) {
property.stringValue = string.Empty;
property.stringValue = DefaultLayerName;
property.serializedObject.ApplyModifiedProperties();
}
@@ -117,6 +118,8 @@ namespace FlashTools.Internal.SwfEditorTools {
ValidateProperty(property);
SwfEditorUtils.DoWithMixedValue(
property.hasMultipleDifferentValues, () => {
label = EditorGUI.BeginProperty(position, label, property);
EditorGUI.BeginChangeCheck();
var all_sorting_layers = GetAllSortingLayers(true);
var sorting_layer_index = EditorGUI.Popup(
position,
@@ -125,14 +128,19 @@ namespace FlashTools.Internal.SwfEditorTools {
? all_sorting_layers.FindIndex(p => string.IsNullOrEmpty(p))
: all_sorting_layers.FindIndex(p => p == property.stringValue),
all_sorting_layers.Select(p => new GUIContent(p)).ToArray());
var new_value = all_sorting_layers[sorting_layer_index];
if ( !string.IsNullOrEmpty(new_value) ) {
if ( property.hasMultipleDifferentValues ) {
property.stringValue = string.Empty;
if ( EditorGUI.EndChangeCheck() ) {
if ( sorting_layer_index >= 0 && sorting_layer_index < all_sorting_layers.Count ) {
var new_value = all_sorting_layers[sorting_layer_index];
if ( !string.IsNullOrEmpty(new_value) ) {
if ( property.hasMultipleDifferentValues ) {
property.stringValue = string.Empty;
}
property.stringValue = new_value;
property.serializedObject.ApplyModifiedProperties();
}
}
property.stringValue = new_value;
property.serializedObject.ApplyModifiedProperties();
}
EditorGUI.EndProperty();
});
} else {
EditorGUI.LabelField(position, label.text, "Use SwfSortingLayer with string attribute.");
@@ -149,7 +157,7 @@ namespace FlashTools.Internal.SwfEditorTools {
static SerializedProperty FindNextBoolProperty(SerializedProperty property, string next_prop) {
var prop = property.Copy();
while ( prop.NextVisible(false) ) {
while ( prop.Next(false) ) {
if ( prop.name == next_prop && prop.propertyType == SerializedPropertyType.Boolean ) {
return prop;
}
@@ -211,4 +219,75 @@ namespace FlashTools.Internal.SwfEditorTools {
}
}
}
//
// SwfReadOnlyDrawer
//
[CustomPropertyDrawer(typeof(SwfReadOnlyAttribute))]
public class SwfReadOnlyDrawer : PropertyDrawer {
public override void OnGUI(
Rect position, SerializedProperty property, GUIContent label)
{
SwfEditorUtils.DoWithEnabledGUI(false, () => {
EditorGUI.PropertyField(position, property, label, true);
});
}
}
//
// SwfAssetGUIDDrawer
//
[CustomPropertyDrawer(typeof(SwfAssetGUIDAttribute))]
public class SwfAssetGUIDDrawer : PropertyDrawer {
public override void OnGUI(
Rect position, SerializedProperty property, GUIContent label)
{
if ( property.propertyType == SerializedPropertyType.String ) {
var attr = attribute as SwfAssetGUIDAttribute;
SwfEditorUtils.DoWithEnabledGUI(!attr.ReadOnly, () => {
SwfEditorUtils.DoWithMixedValue(
property.hasMultipleDifferentValues, () => {
label = EditorGUI.BeginProperty(position, label, property);
EditorGUI.BeginChangeCheck();
var asset_path = AssetDatabase.GUIDToAssetPath(property.stringValue);
var asset = AssetDatabase.LoadMainAssetAtPath(asset_path);
var new_asset = EditorGUI.ObjectField(
position, property.displayName, asset, typeof(UnityEngine.Object), false);
if ( EditorGUI.EndChangeCheck() ) {
if ( property.hasMultipleDifferentValues ) {
property.stringValue = "--";
}
var new_asset_path = AssetDatabase.GetAssetPath(new_asset);
property.stringValue = AssetDatabase.AssetPathToGUID(new_asset_path);
property.serializedObject.ApplyModifiedProperties();
}
EditorGUI.EndProperty();
});
});
} else {
EditorGUI.LabelField(position, label.text, "Use SwfAssetGUID with string attribute.");
}
}
}
//
// SwfDisplayNameDrawer
//
[CustomPropertyDrawer(typeof(SwfDisplayNameAttribute))]
public class SwfDisplayNameDrawer : PropertyDrawer {
public override void OnGUI(
Rect position, SerializedProperty property, GUIContent label)
{
var new_label = new GUIContent(label);
new_label.text = (attribute as SwfDisplayNameAttribute).DisplayName;
if ( EditorGUI.PropertyField(position, property, new_label) ) {
foreach ( SerializedProperty child in property ) {
EditorGUILayout.PropertyField(child);
}
}
}
}
}

View File

@@ -17,6 +17,7 @@ namespace FlashTools.Internal.SwfTools {
}
public abstract class SwfLibraryDefine {
public string ExportName = string.Empty;
public abstract SwfLibraryDefineType Type { get; }
}
@@ -30,9 +31,10 @@ namespace FlashTools.Internal.SwfTools {
}
public class SwfLibraryBitmapDefine : SwfLibraryDefine {
public int Width = 0;
public int Height = 0;
public byte[] ARGB32 = new byte[0];
public int Width = 0;
public int Height = 0;
public byte[] ARGB32 = new byte[0];
public ushort Redirect = 0;
public override SwfLibraryDefineType Type {
get { return SwfLibraryDefineType.Bitmap; }
@@ -107,13 +109,4 @@ namespace FlashTools.Internal.SwfTools {
public string FrameName = string.Empty;
public DisplayInstances Instances = new DisplayInstances();
}
//
// SwfContext
//
public class SwfContext {
public SwfLibrary Library = new SwfLibrary();
public SwfDisplayList DisplayList = new SwfDisplayList();
}
}

View File

@@ -6,11 +6,11 @@ using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools {
public class SwfContextExecuter : SwfTagVisitor<SwfDisplayList, SwfDisplayList> {
public SwfContext MainContex = null;
public SwfLibrary Library = null;
public int CurrentTag = 0;
public SwfContextExecuter(SwfContext main_context, int current_tag) {
MainContex = main_context;
public SwfContextExecuter(SwfLibrary library, int current_tag) {
Library = library;
CurrentTag = current_tag;
}
@@ -18,7 +18,7 @@ namespace FlashTools.Internal.SwfTools {
dl.FrameName = string.Empty;
while ( CurrentTag < tags.Count ) {
var tag = tags[CurrentTag++];
//TagToDebugLog(tag);
TagToDebugLog(tag);
tag.AcceptVistor(this, dl);
if ( tag.TagType == SwfTagType.ShowFrame ) {
ChildrenNextFrameLooped(dl);
@@ -30,10 +30,8 @@ namespace FlashTools.Internal.SwfTools {
}
public SwfDisplayList Visit(PlaceObjectTag tag, SwfDisplayList dl) {
var is_shape =
MainContex.Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
var is_sprite =
MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
var is_shape = Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
var is_sprite = Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
SwfDisplayInstance new_inst = null;
if ( is_shape ) {
new_inst = new SwfDisplayShapeInstance();
@@ -54,10 +52,10 @@ namespace FlashTools.Internal.SwfTools {
public SwfDisplayList Visit(PlaceObject2Tag tag, SwfDisplayList dl) {
var is_shape = tag.HasCharacter
? MainContex.Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId)
? Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId)
: false;
var is_sprite = tag.HasCharacter
? MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
? Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
: false;
if ( tag.HasCharacter ) {
SwfDisplayInstance old_inst = null;
@@ -101,10 +99,10 @@ namespace FlashTools.Internal.SwfTools {
public SwfDisplayList Visit(PlaceObject3Tag tag, SwfDisplayList dl) {
var is_shape = tag.HasCharacter
? MainContex.Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId)
? Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId)
: false;
var is_sprite = tag.HasCharacter
? MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
? Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
: false;
if ( tag.HasCharacter ) {
SwfDisplayInstance old_inst = null;
@@ -168,7 +166,11 @@ namespace FlashTools.Internal.SwfTools {
}
public SwfDisplayList Visit(FrameLabelTag tag, SwfDisplayList dl) {
dl.FrameName = tag.Name;
dl.FrameName = tag.Name.Trim();
return dl;
}
public SwfDisplayList Visit(ProtectTag tag, SwfDisplayList dl) {
return dl;
}
@@ -176,10 +178,50 @@ namespace FlashTools.Internal.SwfTools {
return dl;
}
public SwfDisplayList Visit(ExportAssetsTag tag, SwfDisplayList dl) {
foreach ( var asset_tag in tag.AssetTags ) {
var define = Library.FindDefine<SwfLibraryDefine>(asset_tag.Tag);
if ( define != null ) {
define.ExportName = asset_tag.Name.Trim();
}
}
return dl;
}
public SwfDisplayList Visit(EnableDebuggerTag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(EnableDebugger2Tag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(ScriptLimitsTag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(SymbolClassTag tag, SwfDisplayList dl) {
foreach ( var symbol_tag in tag.SymbolTags ) {
var define = Library.FindDefine<SwfLibraryDefine>(symbol_tag.Tag);
if ( define != null ) {
define.ExportName = symbol_tag.Name.Trim();
}
}
return dl;
}
public SwfDisplayList Visit(MetadataTag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(DefineSceneAndFrameLabelDataTag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(DoABCTag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(DefineShapeTag tag, SwfDisplayList dl) {
AddShapesToLibrary(tag.ShapeId, tag.Shapes);
return dl;
@@ -229,6 +271,14 @@ namespace FlashTools.Internal.SwfTools {
return dl;
}
public SwfDisplayList Visit(EnableTelemetryTag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(DefineBinaryDataTag tag, SwfDisplayList dl) {
return dl;
}
public SwfDisplayList Visit(UnknownTag tag, SwfDisplayList dl) {
return dl;
}
@@ -247,27 +297,40 @@ namespace FlashTools.Internal.SwfTools {
Bitmaps = bitmap_styles.Select(p => p.BitmapId ).ToArray(),
Matrices = bitmap_styles.Select(p => p.BitmapMatrix).ToArray()
};
MainContex.Library.Defines.Add(define_id, define);
Library.Defines.Add(define_id, define);
}
void AddBitmapToLibrary(ushort define_id, int width, int height, byte[] argb32) {
var duplicated = FindDuplicatedBitmap(argb32);
var define = new SwfLibraryBitmapDefine{
Width = width,
Height = height,
ARGB32 = argb32
};
MainContex.Library.Defines.Add(define_id, define);
Width = width,
Height = height,
ARGB32 = duplicated > 0 ? new byte[0] : argb32,
Redirect = duplicated};
Library.Defines.Add(define_id, define);
}
void AddSpriteToLibrary(ushort define_id, SwfControlTags control_tags) {
var define = new SwfLibrarySpriteDefine{
ControlTags = control_tags
};
MainContex.Library.Defines.Add(define_id, define);
Library.Defines.Add(define_id, define);
}
ushort FindDuplicatedBitmap(byte[] argb32) {
foreach ( var define in Library.Defines ) {
var bitmap = define.Value as SwfLibraryBitmapDefine;
if ( bitmap != null && bitmap.ARGB32.Length == argb32.Length ) {
if ( bitmap.ARGB32.SequenceEqual(argb32) ) {
return define.Key;
}
}
}
return 0;
}
bool IsSpriteTimelineEnd(SwfDisplaySpriteInstance sprite) {
var sprite_def = MainContex.Library.FindDefine<SwfLibrarySpriteDefine>(sprite.Id);
var sprite_def = Library.FindDefine<SwfLibrarySpriteDefine>(sprite.Id);
if ( sprite_def != null && sprite.CurrentTag < sprite_def.ControlTags.Tags.Count ) {
return false;
}
@@ -287,12 +350,12 @@ namespace FlashTools.Internal.SwfTools {
.Where (p => p.Type == SwfDisplayInstanceType.Sprite)
.Select(p => p as SwfDisplaySpriteInstance);
foreach ( var sprite in sprites ) {
var sprite_def = MainContex.Library.FindDefine<SwfLibrarySpriteDefine>(sprite.Id);
var sprite_def = Library.FindDefine<SwfLibrarySpriteDefine>(sprite.Id);
if ( sprite_def != null ) {
if ( IsSpriteTimelineEnd(sprite) ) {
sprite.Reset();
}
var sprite_executer = new SwfContextExecuter(MainContex, sprite.CurrentTag);
var sprite_executer = new SwfContextExecuter(Library, sprite.CurrentTag);
sprite_executer.NextFrame(sprite_def.ControlTags.Tags, sprite.DisplayList);
sprite.CurrentTag = sprite_executer.CurrentTag;
}
@@ -300,12 +363,10 @@ namespace FlashTools.Internal.SwfTools {
}
void TagToDebugLog(SwfTagBase tag) {
if ( tag is UnsupportedTag ) {
Debug.LogError(tag);
} else if ( tag is UnknownTag ) {
Debug.LogWarning(tag);
} else {
Debug.Log(tag);
if ( tag is UnsupportedTag || tag is UnknownTag ) {
Debug.LogWarningFormat(
"<b>[FlashTools]</b> SwfContextExecuter. {0}",
tag);
}
}
}

View File

@@ -28,8 +28,7 @@ namespace FlashTools.Internal.SwfTools {
var new_short_header = new SwfShortHeader{
Format = "FWS",
Version = OriginalHeader.Version,
FileLength = OriginalHeader.FileLength
};
FileLength = OriginalHeader.FileLength};
var uncompressed_stream = new MemoryStream();
new_short_header.Write(uncompressed_stream);
rest_stream.WriteTo(uncompressed_stream);

View File

@@ -0,0 +1,27 @@
namespace FlashTools.Internal.SwfTools.SwfTags {
public class DefineBinaryDataTag : SwfTagBase {
public ushort Tag;
public byte[] Data;
public override SwfTagType TagType {
get { return SwfTagType.DefineBinaryData; }
}
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
return visitor.Visit(this, arg);
}
public override string ToString() {
return "DefineBinaryDataTag.";
}
public static DefineBinaryDataTag Create(SwfStreamReader reader) {
var tag = reader.ReadUInt16();
reader.ReadUInt32(); // reserved
var data = reader.ReadRest();
return new DefineBinaryDataTag{
Tag = tag,
Data = data};
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6ffeb1c85031245dcbcdb64b486fa91c
timeCreated: 1472925860
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -31,19 +31,19 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
}
public static DefineSceneAndFrameLabelDataTag Create(SwfStreamReader reader) {
var scenes = new List<SceneOffsetData>((int)reader.ReadEncodedU32());
for ( var i = 0; i < scenes.Capacity; ++i ) {
var scene_count = reader.ReadEncodedU32();
var scenes = new List<SceneOffsetData>((int)scene_count);
for ( var i = 0; i < scene_count; ++i ) {
scenes.Add(new SceneOffsetData{
Offset = reader.ReadEncodedU32(),
Name = reader.ReadString()
});
Name = reader.ReadString()});
}
var frames = new List<FrameLabelData>((int)reader.ReadEncodedU32());
for ( var i = 0; i < frames.Capacity; ++i ) {
var frame_count = reader.ReadEncodedU32();
var frames = new List<FrameLabelData>((int)frame_count);
for ( var i = 0; i < frame_count; ++i ) {
frames.Add(new FrameLabelData{
Number = reader.ReadEncodedU32(),
Label = reader.ReadString()
});
Label = reader.ReadString()});
}
return new DefineSceneAndFrameLabelDataTag{
Scenes = scenes,

View File

@@ -0,0 +1,32 @@
using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags {
public class DoABCTag : SwfTagBase {
public bool ExecuteImmediately;
public string Name;
public byte[] ABCBytes;
public override SwfTagType TagType {
get { return SwfTagType.DoABC; }
}
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
return visitor.Visit(this, arg);
}
public override string ToString() {
return "DoABCTag.";
}
public static DoABCTag Create(SwfStreamReader reader) {
const int kDoAbcLazyInitializeFlag = 1;
var flags = reader.ReadUInt32();
var name = reader.ReadString();
var abc_bytes = reader.ReadRest();
return new DoABCTag{
ExecuteImmediately = (flags & kDoAbcLazyInitializeFlag) == 0,
Name = name,
ABCBytes = abc_bytes};
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1644c7cd661b049a0afab118c09d69a5
timeCreated: 1472819662
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
namespace FlashTools.Internal.SwfTools.SwfTags {
public class EnableDebugger2Tag : SwfTagBase {
public string MD5PasswordHash;
public override SwfTagType TagType {
get { return SwfTagType.EnableDebugger2; }
}
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
return visitor.Visit(this, arg);
}
public override string ToString() {
return string.Format(
"EnableDebugger2Tag. " +
"MD5PasswordHash: {0}",
MD5PasswordHash.Length > 0);
}
public static EnableDebugger2Tag Create(SwfStreamReader reader) {
reader.ReadUInt16(); // reserved
var md5 = reader.IsEOF
? string.Empty
: reader.ReadString();
return new EnableDebugger2Tag{
MD5PasswordHash = md5};
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b616323c0469d4e81ba73869b289b21e
timeCreated: 1472880545
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
namespace FlashTools.Internal.SwfTools.SwfTags {
public class EnableDebuggerTag : SwfTagBase {
public string MD5PasswordHash;
public override SwfTagType TagType {
get { return SwfTagType.EnableDebugger; }
}
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
return visitor.Visit(this, arg);
}
public override string ToString() {
return string.Format(
"EnableDebuggerTag. " +
"MD5PasswordHash: {0}",
MD5PasswordHash.Length > 0);
}
public static EnableDebuggerTag Create(SwfStreamReader reader) {
var md5 = reader.IsEOF
? string.Empty
: reader.ReadString();
return new EnableDebuggerTag{
MD5PasswordHash = md5};
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e5d4c7d7a464b4c44be8b8653686760e
timeCreated: 1472880531
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
namespace FlashTools.Internal.SwfTools.SwfTags {
public class EnableTelemetryTag : SwfTagBase {
public byte[] SHA256PasswordHash;
public override SwfTagType TagType {
get { return SwfTagType.EnableTelemetry; }
}
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
return visitor.Visit(this, arg);
}
public override string ToString() {
return string.Format(
"EnableTelemetryTag. " +
"SHA256PasswordHash: {0}",
SHA256PasswordHash.Length > 0);
}
public static EnableTelemetryTag Create(SwfStreamReader reader) {
reader.ReadUInt16(); // reserved
var sha256 = reader.IsEOF
? new byte[0]
: reader.ReadBytes(32);
return new EnableTelemetryTag{
SHA256PasswordHash = sha256};
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 40db138046cd1449a9e0a3d5020d9963
timeCreated: 1472925852
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using System.Collections.Generic;
namespace FlashTools.Internal.SwfTools.SwfTags {
public class ExportAssetsTag : SwfTagBase {
public struct AssetTagData {
public ushort Tag;
public string Name;
}
public List<AssetTagData> AssetTags;
public override SwfTagType TagType {
get { return SwfTagType.ExportAssets; }
}
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
return visitor.Visit(this, arg);
}
public override string ToString() {
return string.Format(
"ExportAssetsTag. " +
"AssetTags: {0}",
AssetTags.Count);
}
public static ExportAssetsTag Create(SwfStreamReader reader) {
var asset_tag_count = reader.ReadUInt16();
var asset_tags = new List<AssetTagData>((int)asset_tag_count);
for ( var i = 0; i < asset_tag_count; ++i ) {
asset_tags.Add(new AssetTagData{
Tag = reader.ReadUInt16(),
Name = reader.ReadString()});
}
return new ExportAssetsTag{
AssetTags = asset_tags};
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 91d525c5510d747daa79a206efa73ee8
timeCreated: 1472655466
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More