static bool IsValidAssetsForFrame( SwfAsset asset, SwfSymbolData symbol) { return (asset && asset.Atlas && asset.Data != null && symbol != null && symbol.Frames != null); }
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.Anchor) && (sequences.Count < 1 || sequences.Last().Name != frame.Anchor)) { sequences.Add(new SwfClipAsset.Sequence { Name = frame.Anchor }); } else if (sequences.Count < 1) { sequences.Add(new SwfClipAsset.Sequence { Name = "Default" }); } sequences.Last().Frames.Add(baked_frame); } } return(sequences); }
static void ConfigureClipAsset( SwfClipAsset clip_asset, SwfAsset asset, SwfAssetData data, SwfSymbolData symbol) { var asset_guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset)); var asset_atlas = AssetDatabase.LoadAssetAtPath <Sprite>(AssetDatabase.GetAssetPath(asset.Atlas)); clip_asset.Name = symbol.Name; clip_asset.Sprite = asset_atlas; clip_asset.FrameRate = data.FrameRate; clip_asset.AssetGUID = asset_guid; clip_asset.Sequences = LoadClipSequences(asset, data, symbol); EditorUtility.SetDirty(clip_asset); }
static void ConfigureClip(SwfAsset asset, SwfAssetData data, SwfSymbolData symbol) { var asset_guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset)); var clip_assets = SwfEditorUtils.LoadAllAssetsDBByFilter <SwfClipAsset>("t:SwfClipAsset") .Where(p => p.AssetGUID == asset_guid && p.Name == symbol.Name); if (clip_assets.Any()) { foreach (var clip_asset in clip_assets) { ConfigureClipAsset(clip_asset, asset, data, symbol); } } 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, created) => { ConfigureClipAsset(new_clip_asset, asset, data, symbol); return(true); }); } }