summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assets/ActionTool/Editor/ActionEditor.cs113
-rw-r--r--Assets/ActionTool/Editor/ActionEditorStyles.cs38
-rw-r--r--Assets/ActionTool/Editor/ActionManager.cs14
-rw-r--r--Assets/ActionTool/Editor/ActionPreviewEditor.cs14
-rw-r--r--Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot.prefab20
-rw-r--r--Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot_AfterImage.prefab2
-rw-r--r--Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs37
-rw-r--r--Assets/Scripts/Unit/Controller/UnitController.cs6
-rw-r--r--Assets/Scripts/Unit/TimelineEventProxy.cs18
-rw-r--r--Assets/Scripts/Unit/UnitParts.cs12
10 files changed, 231 insertions, 43 deletions
diff --git a/Assets/ActionTool/Editor/ActionEditor.cs b/Assets/ActionTool/Editor/ActionEditor.cs
index b84b9e0e..2abe9a2b 100644
--- a/Assets/ActionTool/Editor/ActionEditor.cs
+++ b/Assets/ActionTool/Editor/ActionEditor.cs
@@ -21,16 +21,35 @@ namespace ActionTool
ActionEditorUI ui;
int currentPickerWindow;
+ IEnumerator coLoadAnimationAssets;
+ Dictionary<string, Object> animationAssets = new Dictionary<string, Object>();
+
public void OnEnable()
{
titleContent = new GUIContent("Action Editor");
+
+ EditorApplication.update += OnUpdate;
+ ActionManager.onSelectObj += OnSelectObj;
}
- public void OnDisable()
+ void OnUpdate()
+ {
+ if(coLoadAnimationAssets != null)
+ {
+ if (!coLoadAnimationAssets.MoveNext())
+ {
+ coLoadAnimationAssets = null;
+ }
+ }
+ }
+
+ public void OnDisable()
{
+ EditorApplication.update -= OnUpdate;
+ ActionManager.onSelectObj -= OnSelectObj;
}
- public void OnGUI()
+ public void OnGUI()
{
if (styles == null) styles = ActionEditorStyles.Get();
if (ui == null) ui = ActionEditorUI.Get();
@@ -44,15 +63,8 @@ namespace ActionTool
GUILayout.Space(5);
}
- public enum Foo
- {
- A =0,
- B= 0,
- }
-
private void GUI_SelectUnit()
{
-
GUILayout.BeginHorizontal();
GameObject selectObj = EditorGUILayout.ObjectField(ActionManager.CurrentUnit, typeof(GameObject), false, GUILayout.Width(position.width - 160)) as GameObject;
@@ -143,13 +155,49 @@ namespace ActionTool
continue;
bool bChecked = ActionManager.CurrentAnimationName == animName;
EditorGUILayout.BeginHorizontal();
- bool check = GUILayout.Toggle(bChecked, animName, style, GUILayout.Width(position.width - 42), GUILayout.Height(15));
+
+ bool check = GUILayout.Toggle(bChecked, animName, style, GUILayout.Width(position.width - 60), GUILayout.Height(15));
if (check && ActionManager.CurrentAnimationName != animName)
ActionManager.OnSelectAnimation(animName);
- if(GUILayout.Button("", styles.selectObj, GUILayout.Width(15), GUILayout.Height(15)))
+
+ bool isFavorite = false;
+ if (animationAssets != null && animationAssets.ContainsKey(file))
+ {
+ var labels = AssetDatabase.GetLabels(animationAssets[file]);
+ for (int j = 0; j < labels.Length; ++j)
+ {
+ if (labels[j] == "GoodAnimation")
+ isFavorite = true;
+ }
+ }
+ if ((!animationAssets.ContainsKey(file) || animationAssets[file] == null) && coLoadAnimationAssets == null)
+ {
+ coLoadAnimationAssets = CoLoadAnimationAssets();
+ }
+ Color bgColor = GUI.backgroundColor;
+ GUI.backgroundColor = isFavorite ? Color.yellow : Color.gray;
+ if (GUILayout.Button("", styles.starButton, GUILayout.Width(12), GUILayout.Height(13)))
+ {
+ isFavorite = !isFavorite;
+ if(animationAssets.ContainsKey(file))
+ {
+ if(!isFavorite)
+ {
+ AssetDatabase.SetLabels(animationAssets[file], new string[0]);
+ }
+ else
+ {
+ AssetDatabase.SetLabels(animationAssets[file], new string[1] { "GoodAnimation" });
+ }
+ }
+ }
+ GUI.backgroundColor = bgColor;
+
+ if (GUILayout.Button("", styles.selectObj, GUILayout.Width(15), GUILayout.Height(15)))
{
ui.SelectObject(file);
}
+
EditorGUILayout.EndHorizontal();
}
@@ -159,8 +207,47 @@ namespace ActionTool
style.clipping = prevClipping;
style.richText = prevRichText;
}
-
}
- }
+ IEnumerator CoLoadAnimationAssets()
+ {
+ if (!ActionManager.HasSelectObj())
+ yield break;
+
+ if (animationAssets != null)
+ animationAssets.Clear();
+ else
+ animationAssets = new Dictionary<string, Object>();
+
+ string animFolder = ActionManager.unitAnimationClipFolder;
+
+ string[] animfiles = Directory.GetFiles(animFolder);
+
+ for (int i = 0; i < animfiles.Length; ++i)
+ {
+ string file = animfiles[i];
+ if (file.Contains(".meta"))
+ continue;
+ var animFile = AssetDatabase.LoadMainAssetAtPath(file);
+ if (animationAssets.ContainsKey(file))
+ {
+ animationAssets[file] = animFile;
+ }
+ else
+ {
+ animationAssets.Add(file, animFile);
+ }
+ this.Repaint();
+ yield return null;
+ }
+ }
+
+ void OnSelectObj(params object[] objs)
+ {
+ animationAssets.Clear();
+ coLoadAnimationAssets = CoLoadAnimationAssets();
+ }
+
+ }
+
} \ No newline at end of file
diff --git a/Assets/ActionTool/Editor/ActionEditorStyles.cs b/Assets/ActionTool/Editor/ActionEditorStyles.cs
index 6059f93a..18b0dde7 100644
--- a/Assets/ActionTool/Editor/ActionEditorStyles.cs
+++ b/Assets/ActionTool/Editor/ActionEditorStyles.cs
@@ -24,6 +24,9 @@ namespace ActionTool
public GUIStyle keyButton;
+ public GUIStyle starButton;
+ public GUIStyle starButton2;
+
public Texture2D selectIcon;
public Texture2D keyFrameIcon;
public Texture2D addFileIcon;
@@ -32,8 +35,10 @@ namespace ActionTool
public Texture2D infoIcon;
public Texture2D keyIcon;
public Texture2D recordIcon;
+ public Texture2D starIcon;
+ public Texture2D starIcon2;
- private static ActionEditorStyles s_instance;
+ private static ActionEditorStyles s_instance;
public static ActionEditorStyles Get()
{
bool flag = s_instance == null;
@@ -55,6 +60,8 @@ namespace ActionTool
deleteIcon = EditorGUIUtility.FindTexture("d_P4_DeletedLocal");
infoIcon = EditorGUIUtility.FindTexture("console.infoicon");
keyIcon = EditorGUIUtility.FindTexture("d_animationkeyframe");
+ starIcon = EditorGUIUtility.FindTexture("Favorite");
+ starIcon2 = EditorGUIUtility.FindTexture("Favorite Icon");
recordIcon = EditorGUIUtility.FindTexture("d_Animation.Record");
InitStyle(out textBoldBig, GUI.skin.label, s => {
@@ -108,13 +115,28 @@ namespace ActionTool
s.focused.textColor = Color.yellow;
s.hover.textColor = Color.yellow;
});
- InitStyle(out keyButton, GUI.skin.button, s => {
- s.normal.background = keyIcon;
- s.active.background = keyIcon;
- s.hover.background = keyIcon;
- s.focused.background = keyIcon;
- });
- InitStyle(out toggleSmallBold, GUI.skin.toggle, s => {
+ InitStyle(out keyButton, GUI.skin.button, s =>
+ {
+ s.normal.background = keyIcon;
+ s.active.background = keyIcon;
+ s.hover.background = keyIcon;
+ s.focused.background = keyIcon;
+ });
+ InitStyle(out starButton, GUI.skin.button, s =>
+ {
+ s.normal.background = starIcon;
+ s.active.background = starIcon;
+ s.hover.background = starIcon;
+ s.focused.background = starIcon;
+ });
+ InitStyle(out starButton2, GUI.skin.button, s =>
+ {
+ s.normal.background = starIcon2;
+ s.active.background = starIcon2;
+ s.hover.background = starIcon2;
+ s.focused.background = starIcon2;
+ });
+ InitStyle(out toggleSmallBold, GUI.skin.toggle, s => {
s.fontSize = 10;
//s.fontStyle = FontStyle.Bold;
});
diff --git a/Assets/ActionTool/Editor/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs
index f8eb327d..54322cd6 100644
--- a/Assets/ActionTool/Editor/ActionManager.cs
+++ b/Assets/ActionTool/Editor/ActionManager.cs
@@ -7,7 +7,10 @@ using UnityEngine;
namespace ActionTool
{
- public static class ActionManager
+ // ActionTool callback delegates
+ public delegate void CallbackHandler(params object[] objs);
+
+ public static class ActionManager
{
public enum UnitType
{
@@ -146,7 +149,9 @@ namespace ActionTool
public static int colliderIndex;
- public static void OnSelectObj(GameObject obj)
+ public static CallbackHandler onSelectObj;
+
+ public static void OnSelectObj(GameObject obj)
{
Release();
s_CurrentUnit = obj;
@@ -159,7 +164,8 @@ namespace ActionTool
s_UnitInstance = GameObject.Instantiate(obj);
InitializeUnitInstance(s_UnitInstance);
}
- }
+ onSelectObj?.Invoke(obj);
+ }
public static void OnSelectAnimation(string animation)
{
@@ -521,4 +527,4 @@ namespace ActionTool
copiedAnimationEvent = UnityEngine.Object.Instantiate(animEvent);
}
}
-} \ No newline at end of file
+} \ No newline at end of file
diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs
index d2582289..a305ad72 100644
--- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs
+++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs
@@ -347,8 +347,8 @@ namespace ActionTool
GUI.Label(new Rect(xr + 150, y, 110, 15), ActionManager.actionData.curAnimTimeNormal.ToString("f2"), styles.textMiddleBold);
GUI.Label(new Rect(xl + 150 * 2, y, 105, 15), "Event Frame:", styles.textMiddle);
GUI.Label(new Rect(xr + 150 + 125, y, 110, 15), ((int)ActionManager.actionData.curAnimFrame).ToString(), styles.textMiddleBold);
- GUI.Label(new Rect(xl + 150 + 130 + 130, y, 105, 15), "Time:", styles.textMiddle);
- GUI.Label(new Rect(xr + 150 + 130 + 70 , y, 510, 15), ((int)ActionManager.actionData.curAnimFrame).ToString(), styles.textMiddleBold);
+ //GUI.Label(new Rect(xl + 150 + 130 + 130, y, 105, 15), "Time:", styles.textMiddle);
+ //GUI.Label(new Rect(xr + 150 + 130 + 70 , y, 510, 15), ((int)ActionManager.actionData.curAnimFrame).ToString(), styles.textMiddleBold);
y += 15;
}
@@ -472,7 +472,7 @@ namespace ActionTool
float y = iy;
float contentHeight = ActionManager.GridRowCount * kFrameHeight + 40;
- Rect content = new Rect(0, 0, ((int)action.totalFrame + 1)* kFrameWidth + 30, contentHeight);
+ Rect content = new Rect(0, 0, ((int)Mathf.Ceil(action.totalFrame)) * kFrameWidth + 30, contentHeight);
float height = 300;
if (position.height - kTimeLineViewYOffset > contentHeight + 15)
height = contentHeight + 15;
@@ -497,7 +497,7 @@ namespace ActionTool
void GUI_FrameText(ref float y)
{
ActionData action = ActionManager.actionData;
- int sampleCount = (int)action.totalFrame + 1;
+ int sampleCount = (int)Mathf.Ceil(action.totalFrame);
Rect rect = new Rect(0, y, 20, 15);
for(int i = 0; i < sampleCount; i++)
{
@@ -538,7 +538,7 @@ namespace ActionTool
m_GridY = y;
ActionData action = ActionManager.actionData;
- int sampleCount = (int)action.totalFrame + 1;
+ int sampleCount = (int)Mathf.Ceil(action.totalFrame);
Rect bgRect = new Rect(kTimeLineViewXOffset, y, sampleCount * kFrameWidth, ActionManager.GridRowCount * kFrameHeight);
GUI.Box(bgRect, "");
@@ -701,7 +701,7 @@ namespace ActionTool
return;
ActionData action = ActionManager.actionData;
AnimationData animData = ActionManager.animationData;
- int sampleCount = (int)action.totalFrame + 1;
+ int sampleCount = (int)Mathf.Ceil(action.totalFrame);
float y = m_GridY + (ActionManager.MaxEventsPerFrame + 1) * kFrameHeight + (animData.overrideRootMotion ? kFrameHeight : 0);
Vector2 position = e.mousePosition;
int boxCount = ActionManager.animationData.GetBoxesCount();
@@ -977,7 +977,7 @@ namespace ActionTool
return;
ActionData action = ActionManager.actionData;
- int sampleCount = (int)action.totalFrame + 1;
+ int sampleCount = (int)Mathf.Ceil(action.totalFrame);
Vector2 position = Event.current.mousePosition;
Rect eventRegion = new Rect(kTimeLineViewXOffset, m_GridY, sampleCount * kFrameWidth, (ActionManager.MaxEventsPerFrame + 1) * kFrameHeight);
if (!eventRegion.Contains(position))
diff --git a/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot.prefab b/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot.prefab
index 4cf8a46c..73baeb6d 100644
--- a/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot.prefab
+++ b/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot.prefab
@@ -57,15 +57,15 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1357685695}
- m_LocalRotation: {x: -0.24720925, y: -0.40268856, z: 0.18871981, w: -0.86088}
- m_LocalPosition: {x: 0.1611, y: -0.1365, z: 0.21}
+ m_LocalRotation: {x: -0.26233202, y: -0.2770635, z: 0.24158631, w: -0.8922185}
+ m_LocalPosition: {x: 0.06, y: -0.161, z: 0.279}
m_LocalScale: {x: 0.01006957, y: 0.014763792, z: 0.9952188}
m_Children:
- {fileID: 2135912540}
- {fileID: 332159091}
m_Father: {fileID: 6930305872343221556}
m_RootOrder: 5
- m_LocalEulerAnglesHint: {x: 144.716, y: 227.31201, z: 171.132}
+ m_LocalEulerAnglesHint: {x: 142.988, y: 207.414, z: 159.033}
--- !u!33 &1357685700
MeshFilter:
m_ObjectHideFlags: 0
@@ -592,6 +592,7 @@ GameObject:
m_Component:
- component: {fileID: 6930345995811640846}
- component: {fileID: 7023111129766813114}
+ - component: {fileID: 1704775273}
m_Layer: 0
m_Name: Erika_Robot
m_TagString: Untagged
@@ -635,6 +636,19 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
+--- !u!114 &1704775273
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 6928033330946439154}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 19d4fad3ce933bf45a32ff4d0d7e328a, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ afterImageAvatarPath: Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot_AfterImage.prefab
--- !u!1 &6928056367075676882
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot_AfterImage.prefab b/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot_AfterImage.prefab
index 0c9b4f45..508a3826 100644
--- a/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot_AfterImage.prefab
+++ b/Assets/Bundle/Unit/PC/Erika/Prefabs/Erika_Robot_AfterImage.prefab
@@ -433,7 +433,7 @@ Transform:
m_GameObject: {fileID: 6928033330946439154}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.54, y: 3.34, z: -12.52}
- m_LocalScale: {x: 1, y: 1, z: 1}
+ m_LocalScale: {x: 0.7, y: 0.7, z: 0.7}
m_Children:
- {fileID: 6930312115733728132}
- {fileID: 6930221487356679114}
diff --git a/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs b/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs
index ce34cb61..ec04f3be 100644
--- a/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs
+++ b/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs
@@ -2,19 +2,48 @@
using System.Collections.Generic;
using UnityEngine;
+// 单个残影的参数
+public struct AfterImageAvatarInfo
+{
+
+}
+
public class AfterImageAvatar : MonoBehaviour
{
#region inspector
-
public Renderer[] renderers;
- public Animator animator;
+ public Animator animator;
+ #endregion
- #endregion
+ float m_CurTime;
+
+ float m_LifeTime;
+
+ public void Initialize(AfterImageAvatarInfo info)
+ {
+
+ }
- public void Initialized()
+ public void Initialize(UnitController prototype)
{
+ transform.position = prototype.transform.position;
+
+ animator.runtimeAnimatorController = prototype.unitAnimation.animator.runtimeAnimatorController;
+ animator.Play(prototype.unitAnimation.baseLayer.stateHash, 0, prototype.unitAnimation.baseLayer.playbackNormalizedTime);
+ animator.speed = 0.02f;
+ animator.Update(1 / 60f);
+
+ m_LifeTime = 0.2f;
+ }
+ public void Update()
+ {
+ m_CurTime += Time.deltaTime;
+ if (m_CurTime > m_LifeTime)
+ {
+ GameObject.Destroy(this.gameObject);
+ }
}
}
diff --git a/Assets/Scripts/Unit/Controller/UnitController.cs b/Assets/Scripts/Unit/Controller/UnitController.cs
index bbcdc745..384299de 100644
--- a/Assets/Scripts/Unit/Controller/UnitController.cs
+++ b/Assets/Scripts/Unit/Controller/UnitController.cs
@@ -39,6 +39,8 @@ public class UnitController : MonoBehaviour/*, Interactable*/
public UnitCollider unitCollider;
+ public UnitParts unitParts;
+
public GameObject unitObj; // 角色模型
#region 事件监听
@@ -118,7 +120,9 @@ public class UnitController : MonoBehaviour/*, Interactable*/
unitCollider = gameObject.GetOrAddComponent<UnitCollider>();
unitCollider.Initialize();
- }
+
+ unitParts = gameObject.GetComponentInChildren<UnitParts>();
+ }
public virtual void Update()
{
diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs
index e3ce605e..3310f6cd 100644
--- a/Assets/Scripts/Unit/TimelineEventProxy.cs
+++ b/Assets/Scripts/Unit/TimelineEventProxy.cs
@@ -249,10 +249,26 @@ public partial class TimelineEventProxy
void EventMesh_AfterImage(AnimationEventBase animEvent)
{
+#if UNITY_EDITOR
+ if (isInEditMode)
+ return;
+#endif
EventMesh_AfterImage afterImage = animEvent as EventMesh_AfterImage;
if (afterImage == null)
return ;
-
+ string avatarPath = owner.unitParts.afterImageAvatarPath;
+ GameObject go = ResourceManager.Instance.LoadAsset<GameObject>(avatarPath);
+ if(go)
+ {
+ GameObject instance = GameObject.Instantiate(go);
+ AfterImageAvatar avatar = instance.GetOrAddComponent<AfterImageAvatar>();
+ if(!avatar)
+ {
+ GameObject.DestroyImmediate(instance);
+ return;
+ }
+ avatar.Initialize(owner);
+ }
}
void EventUnit_SetPosition(AnimationEventBase animEvent)
diff --git a/Assets/Scripts/Unit/UnitParts.cs b/Assets/Scripts/Unit/UnitParts.cs
index a7af9c50..88c9cb23 100644
--- a/Assets/Scripts/Unit/UnitParts.cs
+++ b/Assets/Scripts/Unit/UnitParts.cs
@@ -2,11 +2,21 @@
using System.Collections.Generic;
using UnityEngine;
-
// 部件
[DisallowMultipleComponent]
public class UnitParts : MonoBehaviour
{
+ public enum EUnitPart
+ {
+ Sword = 1,
+ Gun = 2,
+ LHand = 3,
+ RHand = 4,
+ }
+
+ [Tooltip("残影用的prefab")]
+ public string afterImageAvatarPath;
+
}