diff options
Diffstat (limited to 'Assets/ActionTool/Editor/ActionManager.cs')
-rw-r--r-- | Assets/ActionTool/Editor/ActionManager.cs | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/Assets/ActionTool/Editor/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs index 08d48781..d147b0d6 100644 --- a/Assets/ActionTool/Editor/ActionManager.cs +++ b/Assets/ActionTool/Editor/ActionManager.cs @@ -5,7 +5,7 @@ using UnityEngine; namespace ActionTool
{
- public static class ActionManager
+ public static class ActionManager
{
public static string s_AnimFolder = "Assets/Art/Animations/";
public static string s_Controller = "Assets/ActionTool/controller_temp.controller";
@@ -53,6 +53,9 @@ namespace ActionTool private static RootMotionData s_RootMotion;
+ private static AnimationData s_AnimationData;
+ public static AnimationData animationData { get { return s_AnimationData; } }
+
private static ActionToolGizmos s_Gizmos;
public static ActionToolGizmos gizmos { get { return s_Gizmos; } }
@@ -64,6 +67,13 @@ namespace ActionTool private const string kRootActionTool = "RootActionTool";
public const int kMaxEventsPerFrame = 10;
+ public static int eventAndBoxCount
+ {
+ get
+ {
+ return kMaxEventsPerFrame + (animationData != null ? animationData.GetBoxesCount() : 0);
+ }
+ }
public static void OnSelectObj(GameObject obj)
{
@@ -83,14 +93,16 @@ namespace ActionTool PreviewWindow = EditorWindow.GetWindow<ActionPreviewEditor>();
PreviewWindow.Repaint();
- string animpath = s_AnimFolder + s_CurrentUnit.name + "/" + animation + ".anim";
+ string unitName = s_CurrentUnit.name;
+
+ string animpath = s_AnimFolder + unitName + "/" + animation + ".anim";
AnimationClip clip = AssetDatabase.LoadAssetAtPath(animpath, typeof(AnimationClip)) as AnimationClip;
if (clip)
{
s_OverrideContorller["EmptyAction"] = clip;
}
- string rootmotionData = s_RootMotionDataFolder + s_CurrentUnit.name + "/" + animation + ".asset";
+ string rootmotionData = s_RootMotionDataFolder + unitName + "/" + animation + ".asset";
s_RootMotion = AssetDatabase.LoadAssetAtPath<RootMotionData>(rootmotionData);
if (s_RootMotion == null)
{
@@ -100,6 +112,9 @@ namespace ActionTool if (s_CurActionData == null)
s_CurActionData = new ActionData();
s_CurActionData.Initialize(s_Animator, clip, s_RootMotion);
+
+ string animationDataPath = s_AnimationDataFolder + unitName + "/" + animation + ".asset";
+ s_AnimationData = AssetDatabase.LoadAssetAtPath<AnimationData>(animationDataPath);
}
public static bool HasSelectObj()
@@ -222,5 +237,31 @@ namespace ActionTool s_CurActionData.curAnimTimeNormal = 1;
}
+ public static void CreateAnimationData()
+ {
+ string unitName = s_CurrentUnit.name;
+ string animation = s_CurrentAnimationName;
+ string animationDataPath = s_AnimationDataFolder + unitName + "/" + animation + ".asset";
+ string animpath = s_AnimFolder + unitName + "/" + animation + ".anim";
+ AnimationData animData = new AnimationData();
+ animData.animationName = s_CurrentAnimationName;
+ animData.animationPath = animpath;
+ AssetDatabase.CreateAsset(animData, animationDataPath);
+ AssetDatabase.Refresh();
+ s_AnimationData = animData;
+ }
+
+ public static void SaveAnimationData()
+ {
+ if (s_AnimationData == null)
+ {
+ Debug.LogError("[ActionTool] 没有animation data数据");
+ return;
+ }
+ EditorUtility.SetDirty(s_AnimationData);
+ AssetDatabase.SaveAssets();
+ AssetDatabase.Refresh();
+ }
+
}
}
\ No newline at end of file |