diff options
Diffstat (limited to 'Assets/ActionTool')
-rw-r--r-- | Assets/ActionTool/Editor/ActionData.cs | 2 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionEditor.cs | 6 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionManager.cs | 47 |
3 files changed, 30 insertions, 25 deletions
diff --git a/Assets/ActionTool/Editor/ActionData.cs b/Assets/ActionTool/Editor/ActionData.cs index 77935f68..39888914 100644 --- a/Assets/ActionTool/Editor/ActionData.cs +++ b/Assets/ActionTool/Editor/ActionData.cs @@ -221,7 +221,7 @@ namespace ActionTool {
if (m_AnimData == null || m_EventList == null)
{
- Debug.LogError("[ActionTool] 没有对应的action数据,是否在" + ActionManager.s_AnimationDataFolder + "创建");
+ Debug.LogError("[ActionTool] 没有对应的action数据,是否在" + ActionManager.unitAnimationDataFolder + "创建");
return;
}
m_EventList.Add(evnt);
diff --git a/Assets/ActionTool/Editor/ActionEditor.cs b/Assets/ActionTool/Editor/ActionEditor.cs index 2835714a..d7ba4f54 100644 --- a/Assets/ActionTool/Editor/ActionEditor.cs +++ b/Assets/ActionTool/Editor/ActionEditor.cs @@ -77,13 +77,11 @@ namespace ActionTool if (!ActionManager.HasSelectObj())
return;
- string unitName = ActionManager.GetUnitName();
-
EditorGUILayout.LabelField("Animation List");
m_SearchText = GUILayout.TextField(m_SearchText, "SearchTextField", GUILayout.Width(position.width - 20)).ToLower();
-
- string animFolder = ActionManager.s_AnimFolder + unitName + "/";
+
+ string animFolder = ActionManager.unitAnimationClipFolder;
string[] animfiles = Directory.GetFiles(animFolder);
diff --git a/Assets/ActionTool/Editor/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs index 094e28fc..4fe3138b 100644 --- a/Assets/ActionTool/Editor/ActionManager.cs +++ b/Assets/ActionTool/Editor/ActionManager.cs @@ -1,4 +1,5 @@ using System;
+using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
@@ -8,12 +9,19 @@ namespace ActionTool {
public static class ActionManager
{
- public static string s_AnimFolder = "Assets/Art/Animations/";
+ public enum UnitType
+ {
+ PC,
+ NPC,
+ }
+
public static string s_Controller = "Assets/ActionTool/controller_temp.controller";
- public static string s_AnimationDataFolder = "Assets/Data/AnimationData/";
- static string s_RootMotionDataFolder = "Assets/Data/RootMotionData/";
static string s_SettingPath = "Assets/ActionTool/ActionTool Settings.asset";
+ //public static string s_AnimFolder = "Assets/Art/Animations/";
+ //public static string s_AnimationDataFolder = "Assets/Data/AnimationData/";
+ //static string s_RootMotionDataFolder = "Assets/Data/RootMotionData/";
+
public static ActionEditor AnimationWindow;
public static ActionPreviewEditor PreviewWindow;
public static ActionEventEditor EventEditWindow;
@@ -104,12 +112,22 @@ namespace ActionTool }
}
+ public static string unitFolder;
+ public static string unitAnimationDataFolder { get { return unitFolder + "AnimationData/"; } }
+ public static string unitRootMotionFolder { get { return unitFolder + "RootMotion/"; } }
+ public static string unitAnimationClipFolder { get { return unitFolder + "AnimationClip/"; } }
+ public static string unitDataFolder { get { return unitFolder + "UnitData/"; } }
+
public static void OnSelectObj(GameObject obj)
{
Release();
s_CurrentUnit = obj;
if(s_CurrentUnit != null)
{
+ string path = AssetDatabase.GetAssetPath(obj);
+ string folder = Path.GetDirectoryName(path).Replace('\\', '/');
+ folder = folder.Substring(0, folder.LastIndexOf('/'));
+ unitFolder = folder + "/";
s_UnitInstance = GameObject.Instantiate(obj);
InitializeUnitInstance(s_UnitInstance);
}
@@ -122,16 +140,14 @@ namespace ActionTool PreviewWindow = EditorWindow.GetWindow<ActionPreviewEditor>();
PreviewWindow.Repaint();
- string unitName = s_CurrentUnit.name;
-
- string animpath = s_AnimFolder + unitName + "/" + animation + ".anim";
+ string animpath = unitAnimationClipFolder + animation + ".anim";
AnimationClip clip = AssetDatabase.LoadAssetAtPath(animpath, typeof(AnimationClip)) as AnimationClip;
if (clip)
{
s_OverrideContorller["EmptyAction"] = clip;
}
- string rootmotionData = s_RootMotionDataFolder + unitName + "/" + animation + ".asset";
+ string rootmotionData = unitRootMotionFolder + animation + ".asset";
s_RootMotion = AssetDatabase.LoadAssetAtPath<RootMotionData>(rootmotionData);
if (s_RootMotion == null)
{
@@ -142,7 +158,7 @@ namespace ActionTool s_CurActionData = new ActionData();
s_CurActionData.Initialize(s_Animator, clip, s_RootMotion);
- string animationDataPath = s_AnimationDataFolder + unitName + "/" + animation + ".asset";
+ string animationDataPath = unitAnimationDataFolder + animation + ".asset";
AnimationData asset = AssetDatabase.LoadAssetAtPath<AnimationData>(animationDataPath);
m_SharedAnimationData = asset;
if(asset != null)
@@ -162,13 +178,6 @@ namespace ActionTool return s_CurrentUnit != null;
}
- public static string GetUnitName()
- {
- if (s_CurrentUnit == null)
- return null;
- return s_CurrentUnit.name;
- }
-
public static void Release()
{
if(s_UnitInstance != null)
@@ -284,10 +293,9 @@ namespace ActionTool 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";
+ string animationDataPath = unitAnimationDataFolder + animation + ".asset";
+ string animpath = unitAnimationClipFolder + animation + ".anim";
AnimationData animData = new AnimationData();
animData.animationName = s_CurrentAnimationName;
animData.animationPath = animpath;
@@ -304,9 +312,8 @@ namespace ActionTool Debug.LogError("[ActionTool] 没有animation data数据");
return;
}
- string unitName = s_CurrentUnit.name;
string animation = s_CurrentAnimationName;
- string animationDataPath = s_AnimationDataFolder + unitName + "/" + animation + ".asset";
+ string animationDataPath = unitAnimationClipFolder + animation + ".asset";
EditorUtility.CopySerialized(animationData, m_SharedAnimationData);
m_SharedAnimationData.OnSaveToDisk();
EditorUtility.SetDirty(m_SharedAnimationData);
|