summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assets/Scripts/Effects/FxClear.cs167
-rw-r--r--Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs2
-rw-r--r--Assets/Scripts/Unit/TimelineEventProxy.cs38
3 files changed, 80 insertions, 127 deletions
diff --git a/Assets/Scripts/Effects/FxClear.cs b/Assets/Scripts/Effects/FxClear.cs
index 6b26da6c..507da824 100644
--- a/Assets/Scripts/Effects/FxClear.cs
+++ b/Assets/Scripts/Effects/FxClear.cs
@@ -26,7 +26,6 @@ public static class TransformEx
public struct PlayEffectInfo
{
- public int dbId { get; set; }
public string path { get; set; }
public Transform rootTr { get; set; }
public bool bAttached { get; set; }
@@ -34,20 +33,6 @@ public struct PlayEffectInfo
public Vector3 rot { get; set; }
public Vector3 scale { get; set; }
public EffectPlayTypes playEffectType { get; set; }
- public bool bUIEffect { get; set; }
-
- public PlayEffectInfo(string path, EffectPlayTypes type, Transform rootTr, Vector3 posOffset, Vector3 rot, Vector3 scale, int dbId = 0, bool bAttached = false, bool bUIEffect = false)
- {
- this.path = path;
- this.playEffectType = type;
- this.rootTr = rootTr;
- this.rot = rot;
- this.scale = scale;
- this.dbId = dbId;
- this.bAttached = bAttached;
- this.posOffset = posOffset;
- this.bUIEffect = bUIEffect;
- }
}
public class FxClear : MonoBehaviour
@@ -57,25 +42,27 @@ public class FxClear : MonoBehaviour
private EffectPlayTypes m_EffectPlayType = EffectPlayTypes.None;
- public float time { get { return m_curTime; } }
-
- private Transform m_rootTr = null;
- private float m_curTime = 0.0f;
- private bool m_bAttached = false;
+ private Transform m_Root = null; //根节点,可以是角色或者某个骨骼,如果是空,代表是世界空间
+ private bool m_Attached = false; // 跟随根节点运动
- private Vector3 m_offset = Vector3.zero;
- private Vector3 m_rot = Vector3.zero;
- private Vector3 m_scale = Vector3.zero;
+ private Vector3 m_Offset = Vector3.zero;
+ private Vector3 m_Rotation = Vector3.zero;
+ private Vector3 m_Scale = Vector3.one;
+
+ private Quaternion m_RootRot = Quaternion.identity;
+ private Vector3 m_RootPos = Vector3.zero;
#if UNITY_EDITOR
- private double m_prevTime = 0.0f;
- private float m_removeWaitTime = 0.0f;
- private bool m_destroyRequested = false;
+ private double m_PrevTime = 0.0f;
+ private float m_RemoveWaitTime = 0.0f;
+ private bool m_DestroyRequested = false;
#endif
+
+ private float m_CurTime = 0.0f;
+ public float time { get { return m_CurTime; } }
private void Awake()
{
- // 0 이면 무한 루프로 삭제하지 않게 사용하기로 그래픽과 합의함 - 해당 룰 그대로 가져옴(FxClear에서)
if (ClearTime <= float.Epsilon)
m_EffectPlayType = EffectPlayTypes.Loop;
}
@@ -92,13 +79,18 @@ public class FxClear : MonoBehaviour
public void Initialize(PlayEffectInfo info)
{
m_EffectPlayType = info.playEffectType;
- //m_bExistTr = info.rootTr != null;
- m_rootTr = info.rootTr;
- m_curTime = 0.0f;
- m_offset = info.posOffset;
- m_rot = info.rot;
- m_scale = info.scale;
- m_bAttached = info.bAttached;
+ m_Root = info.rootTr;
+ m_CurTime = 0.0f;
+ m_Offset = info.posOffset;
+ m_Rotation = info.rot;
+ m_Scale = info.scale;
+ m_Attached = info.bAttached;
+
+ if(info.rootTr != null)
+ {
+ m_RootPos = info.rootTr.transform.position;
+ m_RootRot = info.rootTr.transform.rotation;
+ }
SyncTr();
gameObject.SetActive(true);
@@ -106,103 +98,42 @@ public class FxClear : MonoBehaviour
public void Release()
{
- m_rootTr = null;
- m_curTime = 0.0f;
- m_bAttached = false;
- m_offset = Vector3.zero;
- m_rot = Vector3.zero;
- m_scale = Vector3.zero;
+ m_Root = null;
+ m_CurTime = 0.0f;
+ m_Attached = false;
+ m_Offset = Vector3.zero;
+ m_Rotation = Vector3.zero;
+ m_Scale = Vector3.zero;
}
+ // 同步特效的缩放、旋转和位置
private void SyncTr()
{
-#if UNITY_EDITOR
if (transform == null || transform.gameObject == null)
return;
- //if (m_runInEditor)
- //{
- // if (m_rootTr == null)
- // {
- // transform.position = m_offset;
- // }
- // else
- // {
-
- // transform.localRotation = m_rootTr.rotation;
-
- // if (m_bAttached)
- // {
- // transform.position = m_rootTr.position + (m_rootTr.rotation * m_offset);
- // }
- // else
- // {
- // transform.position = m_rootTr.position - (m_rootTr.rotation * m_offset);
- // }
- // }
- //}
- //else
- //{
- if (m_rootTr == null)
- {
- transform.position = m_offset;
- }
- else
- {
- if (m_bAttached)
- {
- transform.localRotation = m_rootTr.rotation;// * Quaternion.LookRotation(Vector3.back);
- }
- else
- {
- transform.localRotation = m_rootTr.rotation * Quaternion.LookRotation(Vector3.back);
- }
-
- transform.position = m_rootTr.position + (m_rootTr.rotation * m_offset);
- }
- //}
-#else
- if (m_rootTr == null)
+
+ if (m_Scale != Vector3.zero)
{
- transform.position = m_offset;
+ transform.localScale = m_Scale;
+ }
+
+ if (m_Root == null) // 世界空间
+ {
+ transform.position = m_Offset;
+ transform.rotation = Quaternion.Euler(m_Rotation);
}
else
{
- if (m_bAttached)
+ if (m_Attached)
{
- transform.localRotation = m_rootTr.rotation;// * Quaternion.LookRotation(Vector3.back);
+ transform.rotation = m_Root.rotation * Quaternion.Euler(m_Rotation);
+ transform.position = m_Root.TransformPoint(m_Offset);
}
else
{
- transform.localRotation = m_rootTr.rotation * Quaternion.LookRotation(Vector3.back);
+ transform.rotation = m_RootRot * Quaternion.Euler(m_Rotation);
+ transform.position = m_RootPos + (m_Root.rotation * m_Offset);
}
-
- transform.position = m_rootTr.position + (m_rootTr.rotation * m_offset);
- }
-#endif
-
-#if UNITY_EDITOR
-
- if (m_bAttached && m_rootTr != null)
- {
- transform.SetParent(m_rootTr);
- }
-
-#else
-
- if (m_bAttached && m_rootTr != null)
- {
- transform.SetParent(m_rootTr);
- }
-
-#endif
- if (m_rot != Vector3.zero)
- {
- transform.rotation = Quaternion.Euler(m_rot.x, m_rot.y, m_rot.z);
- }
-
- if (m_scale != Vector3.zero)
- {
- transform.localScale = m_scale;
}
}
@@ -213,9 +144,9 @@ public class FxClear : MonoBehaviour
public void UpdateFunc(float dt)
{
- m_curTime += dt;
+ m_CurTime += dt;
SyncTr();
- if (m_EffectPlayType != EffectPlayTypes.Loop && m_curTime >= ClearTime)
+ if (m_EffectPlayType != EffectPlayTypes.Loop && m_CurTime >= ClearTime)
{
Restore();
return;
diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs
index 48e8a083..d036c5b4 100644
--- a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs
+++ b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs
@@ -187,7 +187,7 @@ public class AnimatorLayerInfo
this.m_Animator = animator;
this.layer = layer;
m_CalcPlaybackTimeCoroutine = unitAnimation.StartCoroutine(CalcPlaybackRealTimeCoroutine());
- m_TimelineEventProxy = new TimelineEventProxy(unitAnimation.owner.transform, unitAnimation.owner);
+ m_TimelineEventProxy = new TimelineEventProxy(unitAnimation.owner);
applySpeedCurve = true;
}
diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs
index 3310f6cd..6d4650fc 100644
--- a/Assets/Scripts/Unit/TimelineEventProxy.cs
+++ b/Assets/Scripts/Unit/TimelineEventProxy.cs
@@ -87,10 +87,16 @@ public partial class TimelineEventProxy
private AnimationData m_PrevAnimationData;
- public TimelineEventProxy(Transform root, UnitController owner = null)
- {
- m_Root = root;
- this.owner = owner;
+ public TimelineEventProxy( UnitController owner)
+ {
+ this.owner = owner;
+ m_Root = owner.transform;
+ m_PrevAnimationData = null;
+ }
+
+ public TimelineEventProxy(Transform root)
+ {
+ m_Root = root;
m_PrevAnimationData = null;
}
@@ -173,13 +179,29 @@ public partial class TimelineEventProxy
onClear.gameObject.name = prefab.name + "(Clone)";
if(owner != null)
{
- Quaternion rot = owner.transform.rotation * Quaternion.Euler(effect.rotation);
- Debug.Log(effect.rotation);
- onClear.Initialize(new PlayEffectInfo(path, EffectPlayTypes.Oneshot, m_Root, effect.position, effect.rotation, effect.scale, 0, false));
+ PlayEffectInfo info = new PlayEffectInfo();
+ info.path = path;
+ info.playEffectType = EffectPlayTypes.Oneshot;
+ info.rootTr = m_Root;
+ info.posOffset = effect.position;
+ info.rot = effect.rotation;
+ info.scale = effect.scale;
+ info.bAttached = true;
+
+ onClear.Initialize(info);
}
else
{
- onClear.Initialize(new PlayEffectInfo(path, EffectPlayTypes.Oneshot, m_Root, effect.position, effect.rotation, effect.scale, 0, false));
+ PlayEffectInfo info = new PlayEffectInfo();
+ info.path = path;
+ info.playEffectType = EffectPlayTypes.Oneshot;
+ info.rootTr = m_Root;
+ info.posOffset = effect.position;
+ info.rot = effect.rotation;
+ info.scale = effect.scale;
+ info.bAttached = true;
+
+ onClear.Initialize(info);
}
#if UNITY_EDITOR
if (isInEditMode && registerParticleSystem != null)