mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 22:19:31 +07:00
separate clips wip
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
<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\SwfAnimationClipAssetEditor.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\SwfEditorUtils.cs" />
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
<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\SwfAnimationClipAsset.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\SwfAnimationController.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\SwfManager.cs" />
|
||||
<None Include="Assets\FlashTools\Resources\Shaders\SwfDecrMask.shader" />
|
||||
|
||||
@@ -26,14 +26,7 @@ namespace FlashTools.Internal {
|
||||
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");
|
||||
: SwfEditorUtils.GetSwfPathFromSettingsPath(asset_path);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -66,43 +59,6 @@ namespace FlashTools.Internal {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -125,14 +81,6 @@ namespace FlashTools.Internal {
|
||||
AllAssetsForeach(p => ApplyOverriddenSettings(p));
|
||||
}
|
||||
|
||||
void CreateAllAnimationPrefabs() {
|
||||
AllAssetsForeach(p => CreateAnimationPrefab(p));
|
||||
}
|
||||
|
||||
void CreateAllAnimationsOnScene() {
|
||||
AllAssetsForeach(p => CreateAnimationOnScene(p));
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -167,11 +115,11 @@ namespace FlashTools.Internal {
|
||||
var atlas_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "Atlas");
|
||||
EditorGUILayout.PropertyField(atlas_prop, true);
|
||||
|
||||
var sequences_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "Sequences");
|
||||
if ( sequences_prop.isArray ) {
|
||||
var clips_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "Clips");
|
||||
if ( clips_prop.isArray ) {
|
||||
SwfEditorUtils.DoWithMixedValue(
|
||||
sequences_prop.hasMultipleDifferentValues, () => {
|
||||
EditorGUILayout.IntField("Sequence count", sequences_prop.arraySize);
|
||||
clips_prop.hasMultipleDifferentValues, () => {
|
||||
EditorGUILayout.IntField("Clips count", clips_prop.arraySize);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -209,19 +157,6 @@ namespace FlashTools.Internal {
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
void DrawGUIAnimation() {
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if ( GUILayout.Button("Create prefab") ) {
|
||||
CreateAllAnimationPrefabs();
|
||||
}
|
||||
if ( GUILayout.Button("Instance to scene") ) {
|
||||
CreateAllAnimationsOnScene();
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
@@ -243,7 +178,6 @@ namespace FlashTools.Internal {
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
DrawGUISettings();
|
||||
DrawGUIAnimation();
|
||||
if ( GUI.changed ) {
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace FlashTools.Internal {
|
||||
if ( atlas_asset != asset.Atlas ) {
|
||||
asset.Atlas = atlas_asset;
|
||||
ConfigureAtlas(asset_path, asset);
|
||||
ConfigureBakedFrames(asset_path, asset);
|
||||
ConfigureClips(asset_path, asset);
|
||||
EditorUtility.SetDirty(asset);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
@@ -45,11 +45,7 @@ namespace FlashTools.Internal {
|
||||
|
||||
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");
|
||||
SwfEditorUtils.GetAtlasPathFromSettingsPath(asset_path));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -77,12 +73,12 @@ namespace FlashTools.Internal {
|
||||
atlas_importer.filterMode = SwfAtlasFilterToImporterFilter(asset.Settings.AtlasTextureFilter);
|
||||
atlas_importer.textureFormat = SwfAtlasFormatToImporterFormat(asset.Settings.AtlasTextureFormat);
|
||||
AssetDatabase.ImportAsset(
|
||||
GetAtlasPath(asset_path),
|
||||
SwfEditorUtils.GetAtlasPathFromSettingsPath(asset_path),
|
||||
ImportAssetOptions.ForceUpdate);
|
||||
}
|
||||
|
||||
static TextureImporter GetBitmapsAtlasImporter(string asset_path) {
|
||||
var atlas_path = GetAtlasPath(asset_path);
|
||||
var atlas_path = SwfEditorUtils.GetAtlasPathFromSettingsPath(asset_path);
|
||||
var atlas_importer = AssetImporter.GetAtPath(atlas_path) as TextureImporter;
|
||||
if ( !atlas_importer ) {
|
||||
throw new UnityException(string.Format(
|
||||
@@ -138,10 +134,71 @@ namespace FlashTools.Internal {
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// ConfigureBakedFrames
|
||||
// ConfigureClips
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
static void ConfigureClips(
|
||||
string asset_path,
|
||||
SwfAnimationAsset asset)
|
||||
{
|
||||
SwfEditorUtils.RemoveAllSubAssets(asset_path);
|
||||
foreach ( var symbol in asset.Data.Symbols ) {
|
||||
ConfigureClip(asset_path, asset, symbol);
|
||||
}
|
||||
}
|
||||
|
||||
static void ConfigureClip(
|
||||
string asset_path,
|
||||
SwfAnimationAsset asset, SwfAnimationSymbolData symbol)
|
||||
{
|
||||
var clip_asset_path = Path.ChangeExtension(asset_path, symbol.Id.ToString() + ".asset");
|
||||
var clip_asset = AssetDatabase.LoadAssetAtPath<SwfAnimationClipAsset>(clip_asset_path);
|
||||
if ( !clip_asset ) {
|
||||
clip_asset = ScriptableObject.CreateInstance<SwfAnimationClipAsset>();
|
||||
AssetDatabase.CreateAsset(clip_asset, clip_asset_path);
|
||||
}
|
||||
clip_asset.Atlas = asset.Atlas;
|
||||
clip_asset.FrameRate = asset.Data.FrameRate;
|
||||
clip_asset.Sequences = LoadClipSequences(asset, symbol);
|
||||
asset.Clips.Add(clip_asset);
|
||||
foreach ( var sequence in clip_asset.Sequences ) {
|
||||
for ( var i = 0; i < sequence.Frames.Count; ++i ) {
|
||||
var mesh = sequence.Frames[i].Mesh;
|
||||
mesh.name = sequence.Name + "_" + i.ToString();
|
||||
AssetDatabase.AddObjectToAsset(mesh, clip_asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static List<SwfAnimationClipAsset.Sequence> LoadClipSequences(
|
||||
SwfAnimationAsset asset, SwfAnimationSymbolData symbol)
|
||||
{
|
||||
var sequences = new List<SwfAnimationClipAsset.Sequence>();
|
||||
if ( IsValidAssetsForFrame(asset, symbol) ) {
|
||||
foreach ( var frame in symbol.Frames ) {
|
||||
var baked_frame = BakeClipFrame(asset, frame);
|
||||
if ( !string.IsNullOrEmpty(frame.Name) &&
|
||||
(sequences.Count < 1 || sequences.Last().Name != frame.Name) )
|
||||
{
|
||||
sequences.Add(new SwfAnimationClipAsset.Sequence{Name = frame.Name});
|
||||
} else if ( sequences.Count < 1 ) {
|
||||
sequences.Add(new SwfAnimationClipAsset.Sequence{Name = "Default"});
|
||||
}
|
||||
sequences.Last().Frames.Add(baked_frame);
|
||||
}
|
||||
}
|
||||
return sequences;
|
||||
}
|
||||
|
||||
static bool IsValidAssetsForFrame(
|
||||
SwfAnimationAsset asset, SwfAnimationSymbolData symbol)
|
||||
{
|
||||
return
|
||||
asset && asset.Atlas && asset.Data != null &&
|
||||
symbol != null && symbol.Frames != null;
|
||||
}
|
||||
|
||||
class BakedGroup {
|
||||
public SwfAnimationInstanceType Type;
|
||||
public int ClipDepth;
|
||||
@@ -149,43 +206,7 @@ namespace FlashTools.Internal {
|
||||
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(
|
||||
static SwfAnimationClipAsset.Frame BakeClipFrame(
|
||||
SwfAnimationAsset asset, SwfAnimationFrameData frame)
|
||||
{
|
||||
List<Vector2> baked_uvs = new List<Vector2>();
|
||||
@@ -195,8 +216,7 @@ namespace FlashTools.Internal {
|
||||
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];
|
||||
foreach ( var inst in frame.Instances ) {
|
||||
var bitmap = inst != null
|
||||
? FindBitmapFromAnimationData(asset.Data, inst.Bitmap)
|
||||
: null;
|
||||
@@ -246,8 +266,8 @@ namespace FlashTools.Internal {
|
||||
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[baked_groups.Count - 1].Type != inst.Type ||
|
||||
baked_groups[baked_groups.Count - 1].ClipDepth != inst.ClipDepth )
|
||||
{
|
||||
baked_groups.Add(new BakedGroup{
|
||||
Type = inst.Type,
|
||||
@@ -308,8 +328,7 @@ namespace FlashTools.Internal {
|
||||
mesh.SetColors(baked_mulcolors);
|
||||
mesh.RecalculateNormals();
|
||||
|
||||
AssetDatabase.AddObjectToAsset(mesh, asset);
|
||||
return new SwfAnimationAsset.Frame{
|
||||
return new SwfAnimationClipAsset.Frame{
|
||||
Mesh = mesh,
|
||||
Materials = baked_materials.ToArray()};
|
||||
}
|
||||
@@ -333,7 +352,9 @@ namespace FlashTools.Internal {
|
||||
static void ConfigureAssetAnimations(SwfAnimationAsset asset) {
|
||||
var animations = GameObject.FindObjectsOfType<SwfAnimation>();
|
||||
foreach ( var animation in animations ) {
|
||||
animation.UpdateAllProperties();
|
||||
if ( animation && animation.clip && asset.Clips.Contains(animation.clip) ) {
|
||||
animation.UpdateAllProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
[CustomEditor(typeof(SwfAnimationClipAsset)), CanEditMultipleObjects]
|
||||
public class SwfAnimationClipAssetEditor : Editor {
|
||||
List<SwfAnimationClipAsset> _clips = new List<SwfAnimationClipAsset>();
|
||||
|
||||
static string GetClipPath(SwfAnimationClipAsset clip) {
|
||||
return clip
|
||||
? AssetDatabase.GetAssetPath(clip)
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
static string GetPrefabPath(SwfAnimationClipAsset clip) {
|
||||
var clip_path = GetClipPath(clip);
|
||||
return string.IsNullOrEmpty(clip_path)
|
||||
? string.Empty
|
||||
: Path.ChangeExtension(clip_path, ".prefab");
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
static GameObject CreateAnimationGO(SwfAnimationClipAsset clip) {
|
||||
if ( clip ) {
|
||||
var anim_go = new GameObject(clip.name);
|
||||
anim_go.AddComponent<MeshFilter>();
|
||||
anim_go.AddComponent<MeshRenderer>();
|
||||
anim_go.AddComponent<SwfAnimation>().clip = clip;
|
||||
anim_go.AddComponent<SwfAnimationController>();
|
||||
return anim_go;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static void CreateClipPrefab(SwfAnimationClipAsset clip) {
|
||||
var anim_go = CreateAnimationGO(clip);
|
||||
if ( anim_go ) {
|
||||
var prefab_path = GetPrefabPath(clip);
|
||||
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 CreateClipOnScene(SwfAnimationClipAsset clip) {
|
||||
var anim_go = CreateAnimationGO(clip);
|
||||
if ( anim_go ) {
|
||||
Undo.RegisterCreatedObjectUndo(anim_go, "Instance SwfAnimation");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
void AllClipsForeach(Action<SwfAnimationClipAsset> act) {
|
||||
foreach ( var clip in _clips ) {
|
||||
act(clip);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateAllClipsPrefabs() {
|
||||
AllClipsForeach(p => CreateClipPrefab(p));
|
||||
}
|
||||
|
||||
void CreateAllClipsOnScene() {
|
||||
AllClipsForeach(p => CreateClipOnScene(p));
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
void DrawGUIProperties() {
|
||||
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 frame_rate_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "FrameRate");
|
||||
EditorGUILayout.PropertyField(frame_rate_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);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void DrawGUIControls() {
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if ( GUILayout.Button("Create prefab") ) {
|
||||
CreateAllClipsPrefabs();
|
||||
}
|
||||
if ( GUILayout.Button("Instance to scene") ) {
|
||||
CreateAllClipsOnScene();
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void OnEnable() {
|
||||
_clips = targets
|
||||
.OfType<SwfAnimationClipAsset>()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawGUIProperties();
|
||||
DrawGUIControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b6bb12f4dfcf4d34a6a027b679eacc8
|
||||
timeCreated: 1472724849
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -46,12 +46,12 @@ namespace FlashTools.Internal {
|
||||
});
|
||||
}
|
||||
|
||||
bool IsAllAnimationsHasOneAsset() {
|
||||
bool IsAllAnimationsHasOneClip() {
|
||||
foreach ( var animation in _animations ) {
|
||||
if ( !animation.asset ) {
|
||||
if ( !animation.clip ) {
|
||||
return false;
|
||||
}
|
||||
if ( animation.asset != _animations.First().asset ) {
|
||||
if ( animation.clip != _animations.First().clip ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ namespace FlashTools.Internal {
|
||||
|
||||
List<string> GetAllSequences(bool include_empty) {
|
||||
var seq_set = new HashSet<string>(_animations
|
||||
.Where(p => p.asset)
|
||||
.SelectMany(p => p.asset.Sequences)
|
||||
.Where(p => p.clip)
|
||||
.SelectMany(p => p.clip.Sequences)
|
||||
.Select(p => p.Name));
|
||||
if ( include_empty ) {
|
||||
seq_set.Add(string.Empty);
|
||||
@@ -70,8 +70,8 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
|
||||
void DrawSequence() {
|
||||
if ( IsAllAnimationsHasOneAsset() ) {
|
||||
var sequence_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "_sequence");
|
||||
if ( IsAllAnimationsHasOneClip() ) {
|
||||
var sequence_prop = SwfEditorUtils.GetPropertyByName(serializedObject, "_sequence");
|
||||
SwfEditorUtils.DoWithMixedValue(
|
||||
sequence_prop.hasMultipleDifferentValues, () => {
|
||||
var all_sequences = GetAllSequences(true);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using UnityEditor;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
public static class SwfEditorUtils {
|
||||
@@ -39,5 +40,34 @@ namespace FlashTools.Internal {
|
||||
AssetDatabase.GetAssetPath(asset));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSwfPathFromSettingsPath(string settings_path) {
|
||||
return Path.ChangeExtension(
|
||||
Path.Combine(
|
||||
Path.GetDirectoryName(settings_path),
|
||||
Path.GetFileNameWithoutExtension(settings_path)),
|
||||
".swf");
|
||||
}
|
||||
|
||||
public static string GetAtlasPathFromSwfPath(string swf_path) {
|
||||
return Path.ChangeExtension(swf_path, ".settings.png");
|
||||
}
|
||||
|
||||
public static string GetAtlasPathFromSettingsPath(string settings_path) {
|
||||
return Path.ChangeExtension(settings_path, ".png");
|
||||
}
|
||||
|
||||
public static string GetSettingsPathFromSwfPath(string swf_path) {
|
||||
return Path.ChangeExtension(swf_path, ".settings.asset");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
|
||||
static void SwfAssetProcess(string swf_asset) {
|
||||
var new_asset_path = Path.ChangeExtension(swf_asset, ".asset");
|
||||
var new_asset_path = SwfEditorUtils.GetSettingsPathFromSwfPath(swf_asset);
|
||||
var new_asset = AssetDatabase.LoadAssetAtPath<SwfAnimationAsset>(new_asset_path);
|
||||
if ( !new_asset ) {
|
||||
new_asset = ScriptableObject.CreateInstance<SwfAnimationAsset>();
|
||||
@@ -60,25 +60,44 @@ namespace FlashTools.Internal {
|
||||
static SwfAnimationData LoadAnimationDataFromSwfDecoder(
|
||||
string swf_asset, SwfAnimationAsset asset, SwfDecoder decoder)
|
||||
{
|
||||
var animation_data = new SwfAnimationData{
|
||||
var library = new SwfLibrary();
|
||||
return 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;
|
||||
FrameSize = decoder.UncompressedHeader.FrameSize.ToUnityVectorSize(),
|
||||
Symbols = LoadAnimationSymbols(library, decoder),
|
||||
Bitmaps = LoadAnimationBitmaps(swf_asset, asset.Settings, library)};
|
||||
}
|
||||
|
||||
static SwfAnimationFrameData LoadAnimationFrameFromContext(SwfContext context) {
|
||||
static List<SwfAnimationSymbolData> LoadAnimationSymbols(
|
||||
SwfLibrary library, SwfDecoder decoder)
|
||||
{
|
||||
var symbols = new List<SwfAnimationSymbolData>();
|
||||
symbols.Add(LoadAnimationSymbol(0, library, decoder.Tags));
|
||||
return symbols;
|
||||
}
|
||||
|
||||
static SwfAnimationSymbolData LoadAnimationSymbol(
|
||||
int symbol_id, SwfLibrary library, List<SwfTagBase> tags)
|
||||
{
|
||||
var disp_lst = new SwfDisplayList();
|
||||
var executer = new SwfContextExecuter(library, 0);
|
||||
var symbol_frames = new List<SwfAnimationFrameData>();
|
||||
while ( executer.NextFrame(tags, disp_lst) ) {
|
||||
symbol_frames.Add(LoadAnimationSymbolFrame(library, disp_lst));
|
||||
}
|
||||
return new SwfAnimationSymbolData{
|
||||
Id = symbol_id,
|
||||
Frames = symbol_frames};
|
||||
}
|
||||
|
||||
static SwfAnimationFrameData LoadAnimationSymbolFrame(
|
||||
SwfLibrary library, SwfDisplayList display_list)
|
||||
{
|
||||
var frame = new SwfAnimationFrameData();
|
||||
frame.Name = context.DisplayList.FrameName;
|
||||
frame.Name = display_list.FrameName;
|
||||
return AddDisplayListToFrame(
|
||||
context,
|
||||
context.DisplayList,
|
||||
library,
|
||||
display_list,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
@@ -88,8 +107,8 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
|
||||
static SwfAnimationFrameData AddDisplayListToFrame(
|
||||
SwfContext ctx,
|
||||
SwfDisplayList dl,
|
||||
SwfLibrary library,
|
||||
SwfDisplayList display_list,
|
||||
ushort parent_masked,
|
||||
ushort parent_mask,
|
||||
List<SwfAnimationInstanceData> parent_masks,
|
||||
@@ -98,18 +117,18 @@ namespace FlashTools.Internal {
|
||||
SwfAnimationFrameData frame)
|
||||
{
|
||||
var self_masks = new List<SwfAnimationInstanceData>();
|
||||
foreach ( var inst in dl.Instances.Values.Where(p => p.Visible) ) {
|
||||
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.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);
|
||||
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 = ctx.Library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
|
||||
var bitmap_def = library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
|
||||
if ( bitmap_def != null ) {
|
||||
var frame_inst_type =
|
||||
(parent_mask > 0 || inst.ClipDepth > 0)
|
||||
@@ -139,11 +158,11 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
break;
|
||||
case SwfDisplayInstanceType.Sprite:
|
||||
var sprite_def = ctx.Library.FindDefine<SwfLibrarySpriteDefine>(inst.Id);
|
||||
var sprite_def = library.FindDefine<SwfLibrarySpriteDefine>(inst.Id);
|
||||
if ( sprite_def != null ) {
|
||||
var sprite_inst = inst as SwfDisplaySpriteInstance;
|
||||
AddDisplayListToFrame(
|
||||
ctx,
|
||||
library,
|
||||
sprite_inst.DisplayList,
|
||||
(ushort)(parent_masked + self_masks.Count),
|
||||
(ushort)(parent_mask > 0 ? parent_mask : (inst.ClipDepth > 0 ? inst.ClipDepth : (ushort)0)),
|
||||
@@ -178,23 +197,20 @@ namespace FlashTools.Internal {
|
||||
masks.RemoveAll(p => p.ClipDepth < depth);
|
||||
}
|
||||
|
||||
static List<SwfAnimationBitmapData> LoadBitmapsFromContext(
|
||||
string swf_asset, SwfAnimationAsset asset, SwfContext context)
|
||||
static List<SwfAnimationBitmapData> LoadAnimationBitmaps(
|
||||
string swf_asset, SwfSettings settings, SwfLibrary library)
|
||||
{
|
||||
var bitmap_defines = context.Library.Defines
|
||||
var bitmap_defines = 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);
|
||||
|
||||
settings);
|
||||
var bitmaps = new List<SwfAnimationBitmapData>(bitmap_defines.Length);
|
||||
for ( var i = 0; i < bitmap_defines.Length; ++i ) {
|
||||
var bitmap_define = bitmap_defines[i];
|
||||
@@ -236,10 +252,6 @@ namespace FlashTools.Internal {
|
||||
public Rect[] Rects;
|
||||
}
|
||||
|
||||
static string GetAtlasPath(string swf_asset) {
|
||||
return Path.ChangeExtension(swf_asset, ".png");
|
||||
}
|
||||
|
||||
static Rect[] PackAndSaveBitmapsAtlas(
|
||||
string swf_asset,
|
||||
Texture2D[] textures,
|
||||
@@ -247,12 +259,11 @@ namespace FlashTools.Internal {
|
||||
{
|
||||
var atlas_info = PackBitmapsAtlas(textures, settings);
|
||||
File.WriteAllBytes(
|
||||
GetAtlasPath(swf_asset),
|
||||
SwfEditorUtils.GetAtlasPathFromSwfPath(swf_asset),
|
||||
atlas_info.Atlas.EncodeToPNG());
|
||||
GameObject.DestroyImmediate(atlas_info.Atlas, true);
|
||||
AssetDatabase.ImportAsset(
|
||||
GetAtlasPath(swf_asset),
|
||||
ImportAssetOptions.ForceUpdate);
|
||||
SwfEditorUtils.GetAtlasPathFromSwfPath(swf_asset));
|
||||
return atlas_info.Rects;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,13 +107,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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,7 @@ namespace FlashTools.Internal.SwfTools {
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(FrameLabelTag tag, SwfDisplayList dl) {
|
||||
dl.FrameName = tag.Name;
|
||||
dl.FrameName = tag.Name.Trim();
|
||||
return dl;
|
||||
}
|
||||
|
||||
@@ -255,7 +253,7 @@ 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) {
|
||||
@@ -264,18 +262,18 @@ namespace FlashTools.Internal.SwfTools {
|
||||
Height = height,
|
||||
ARGB32 = argb32
|
||||
};
|
||||
MainContex.Library.Defines.Add(define_id, define);
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -295,12 +293,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;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace FlashTools {
|
||||
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
|
||||
public class SwfAnimation : MonoBehaviour {
|
||||
|
||||
MeshFilter _meshFilter = null;
|
||||
MeshRenderer _meshRenderer = null;
|
||||
MeshFilter _meshFilter = null;
|
||||
MeshRenderer _meshRenderer = null;
|
||||
|
||||
SwfAnimationAsset.Sequence _curSequence = null;
|
||||
MaterialPropertyBlock _curPropBlock = null;
|
||||
SwfAnimationClipAsset.Sequence _curSequence = null;
|
||||
MaterialPropertyBlock _curPropBlock = null;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
@@ -41,12 +41,12 @@ namespace FlashTools {
|
||||
|
||||
[Header("Animation")]
|
||||
[SerializeField]
|
||||
SwfAnimationAsset _asset = null;
|
||||
public SwfAnimationAsset asset {
|
||||
get { return _asset; }
|
||||
SwfAnimationClipAsset _clip = null;
|
||||
public SwfAnimationClipAsset clip {
|
||||
get { return _clip; }
|
||||
set {
|
||||
_asset = value;
|
||||
ChangeAsset();
|
||||
_clip = value;
|
||||
ChangeClip();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,7 @@ namespace FlashTools {
|
||||
|
||||
public float frameRate {
|
||||
get {
|
||||
return asset && asset.Data != null
|
||||
? asset.Data.FrameRate
|
||||
: 1.0f;
|
||||
return clip ? clip.FrameRate : 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,16 +121,16 @@ namespace FlashTools {
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
public void UpdateAllProperties() {
|
||||
asset = _asset;
|
||||
clip = _clip;
|
||||
sequence = _sequence;
|
||||
currentFrame = _currentFrame;
|
||||
sortingLayer = _sortingLayer;
|
||||
sortingOrder = _sortingOrder;
|
||||
}
|
||||
|
||||
void ChangeAsset() {
|
||||
void ChangeClip() {
|
||||
if ( _meshRenderer ) {
|
||||
_meshRenderer.enabled = !!asset;
|
||||
_meshRenderer.enabled = !!clip;
|
||||
}
|
||||
UpdatePropertyBlock();
|
||||
ChangeSequence();
|
||||
@@ -140,19 +138,19 @@ namespace FlashTools {
|
||||
|
||||
void ChangeSequence() {
|
||||
_curSequence = null;
|
||||
if ( asset && asset.Sequences != null ) {
|
||||
for ( int i = 0, e = asset.Sequences.Count; i < e; ++i ) {
|
||||
var asset_sequence = asset.Sequences[i];
|
||||
if ( asset_sequence != null && asset_sequence.Name == sequence ) {
|
||||
_curSequence = asset_sequence;
|
||||
if ( clip && clip.Sequences != null ) {
|
||||
for ( int i = 0, e = clip.Sequences.Count; i < e; ++i ) {
|
||||
var clip_sequence = clip.Sequences[i];
|
||||
if ( clip_sequence != null && clip_sequence.Name == sequence ) {
|
||||
_curSequence = clip_sequence;
|
||||
}
|
||||
}
|
||||
if ( _curSequence == null ) {
|
||||
for ( int i = 0, e = asset.Sequences.Count; i < e; ++i ) {
|
||||
var asset_sequence = asset.Sequences[i];
|
||||
if ( asset_sequence != null ) {
|
||||
_sequence = asset_sequence.Name;
|
||||
_curSequence = asset_sequence;
|
||||
for ( int i = 0, e = clip.Sequences.Count; i < e; ++i ) {
|
||||
var clip_sequence = clip.Sequences[i];
|
||||
if ( clip_sequence != null ) {
|
||||
_sequence = clip_sequence.Name;
|
||||
_curSequence = clip_sequence;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -181,7 +179,7 @@ namespace FlashTools {
|
||||
_curPropBlock = new MaterialPropertyBlock();
|
||||
}
|
||||
_meshRenderer.GetPropertyBlock(_curPropBlock);
|
||||
var atlas = asset && asset.Atlas ? asset.Atlas : null;
|
||||
var atlas = clip ? clip.Atlas : null;
|
||||
if ( atlas ) {
|
||||
_curPropBlock.SetTexture("_MainTex", atlas);
|
||||
}
|
||||
@@ -197,11 +195,11 @@ namespace FlashTools {
|
||||
}
|
||||
}
|
||||
|
||||
SwfAnimationAsset.Frame GetCurrentBakedFrame() {
|
||||
SwfAnimationClipAsset.Frame GetCurrentBakedFrame() {
|
||||
var frames = _curSequence != null ? _curSequence.Frames : null;
|
||||
return frames != null && currentFrame >= 0 && currentFrame < frames.Count
|
||||
? frames[currentFrame]
|
||||
: new SwfAnimationAsset.Frame();
|
||||
: new SwfAnimationClipAsset.Frame();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@@ -55,6 +55,12 @@ namespace FlashTools {
|
||||
public List<SwfAnimationInstanceData> Instances = new List<SwfAnimationInstanceData>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfAnimationSymbolData {
|
||||
public int Id = 0;
|
||||
public List<SwfAnimationFrameData> Frames = new List<SwfAnimationFrameData>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfAnimationBitmapData {
|
||||
public int Id = 0;
|
||||
@@ -66,32 +72,22 @@ namespace FlashTools {
|
||||
public class SwfAnimationData {
|
||||
public float FrameRate = 0.0f;
|
||||
public Vector2 FrameSize = Vector2.zero;
|
||||
public List<SwfAnimationFrameData> Frames = new List<SwfAnimationFrameData>();
|
||||
public List<SwfAnimationSymbolData> Symbols = new List<SwfAnimationSymbolData>();
|
||||
public List<SwfAnimationBitmapData> Bitmaps = new List<SwfAnimationBitmapData>();
|
||||
}
|
||||
|
||||
public class SwfAnimationAsset : ScriptableObject {
|
||||
[System.Serializable]
|
||||
public class Frame {
|
||||
public Mesh Mesh = new Mesh();
|
||||
public Material[] Materials = new Material[0];
|
||||
}
|
||||
[System.Serializable]
|
||||
public class Sequence {
|
||||
public string Name = string.Empty;
|
||||
public List<Frame> Frames = new List<Frame>();
|
||||
}
|
||||
public SwfAnimationData Data;
|
||||
public Texture2D Atlas;
|
||||
public List<Sequence> Sequences;
|
||||
public SwfSettings Settings;
|
||||
public SwfSettings Overridden;
|
||||
public SwfAnimationData Data;
|
||||
public Texture2D Atlas;
|
||||
public List<SwfAnimationClipAsset> Clips;
|
||||
public SwfSettings Settings;
|
||||
public SwfSettings Overridden;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void Reset() {
|
||||
Data = new SwfAnimationData();
|
||||
Atlas = null;
|
||||
Sequences = new List<Sequence>();
|
||||
Clips = new List<SwfAnimationClipAsset>();
|
||||
Settings = SwfConverterSettings.GetDefaultSettings();
|
||||
Overridden = SwfConverterSettings.GetDefaultSettings();
|
||||
}
|
||||
|
||||
29
Assets/FlashTools/Scripts/SwfAnimationClipAsset.cs
Normal file
29
Assets/FlashTools/Scripts/SwfAnimationClipAsset.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using FlashTools.Internal;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools {
|
||||
public class SwfAnimationClipAsset : ScriptableObject {
|
||||
[System.Serializable]
|
||||
public class Frame {
|
||||
public Mesh Mesh = new Mesh();
|
||||
public Material[] Materials = new Material[0];
|
||||
}
|
||||
[System.Serializable]
|
||||
public class Sequence {
|
||||
public string Name = string.Empty;
|
||||
public List<Frame> Frames = new List<Frame>();
|
||||
}
|
||||
public Texture2D Atlas;
|
||||
public float FrameRate;
|
||||
public List<Sequence> Sequences;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void Reset() {
|
||||
Atlas = null;
|
||||
FrameRate = 1.0f;
|
||||
Sequences = new List<Sequence>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
12
Assets/FlashTools/Scripts/SwfAnimationClipAsset.cs.meta
Normal file
12
Assets/FlashTools/Scripts/SwfAnimationClipAsset.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c8c473f52d644fc783452f78f8f015f
|
||||
timeCreated: 1472673248
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user