/// <summary> /// 获取动画剪辑 /// </summary> /// <param name="clipName"></param> /// <returns></returns> public SwfClipAsset GetSwfClip(string clipName) { SwfClipAsset asset = null; swfAssets.TryGetValue(clipName, out asset); return(asset); }
static string GetPrefabPath(SwfClipAsset clip) { var clip_path = GetClipPath(clip); return(string.IsNullOrEmpty(clip_path) ? string.Empty : Path.ChangeExtension(clip_path, ".prefab")); }
static GameObject CreateClipOnScene(SwfClipAsset clip) { var clip_go = CreateClipGO(clip); if (clip_go) { Undo.RegisterCreatedObjectUndo(clip_go, "Instance SwfClip"); } return(clip_go); }
/// <summary> /// 添加动画剪辑 /// </summary> /// <param name="asset"></param> public void AddSwfClip(SwfClipAsset asset) { var strKeys = asset.name.Split('_'); if (swfAssets.ContainsKey(strKeys[1])) { UnityEngine.Debug.LogError(asset); return; } swfAssets.Add(strKeys[1], asset); }
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 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 GameObject CreateClipGO(SwfClipAsset clip) { if (clip) { var clip_go = new GameObject(clip.name); clip_go.AddComponent <MeshFilter>(); clip_go.AddComponent <MeshRenderer>(); clip_go.AddComponent <SortingGroup>(); 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 int GetFrameCount(SwfClipAsset clip) { return(clip != null?clip.Sequences.Aggregate(0, (acc, seq) => { return seq.Frames.Count + acc; }) : 0); }
static string GetClipPath(SwfClipAsset clip) { return(clip ? AssetDatabase.GetAssetPath(clip) : string.Empty); }
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); }
public static bool CheckForOutdatedAsset(SwfClipAsset clip_asset) { return(clip_asset && CheckForOutdatedAsset(AssetDatabase.LoadAssetAtPath <SwfAsset>( AssetDatabase.GUIDToAssetPath(clip_asset.AssetGUID)))); }