From eb4e64036aeb5a016378c90d4dc4d8f8b63c2900 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 29 Jul 2021 16:43:03 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ActionTool/Editor/ActionManager.cs | 47 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'Assets/ActionTool/Editor/ActionManager.cs') 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(); 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); 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(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); -- cgit v1.1-26-g67d0