diff options
author | chai <chaifix@163.com> | 2021-08-31 19:07:21 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-08-31 19:07:21 +0800 |
commit | ffd1d5af496e0a0eff343b27c4f0f965bbbf79eb (patch) | |
tree | c5a8ae2116040ce8c483454b2e82093f247db341 /Assets/Scripts/Unit/TimelineEventProxy.cs | |
parent | 476abf41a7357db0dd870f0d221f1a26481ab2bf (diff) |
*projectile
Diffstat (limited to 'Assets/Scripts/Unit/TimelineEventProxy.cs')
-rw-r--r-- | Assets/Scripts/Unit/TimelineEventProxy.cs | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs index 7a76cd73..51d437fe 100644 --- a/Assets/Scripts/Unit/TimelineEventProxy.cs +++ b/Assets/Scripts/Unit/TimelineEventProxy.cs @@ -7,7 +7,13 @@ using UnityEngine; // 执行帧事件 [DisallowMultipleComponent] public partial class TimelineEventProxy -{ +{
+#if UNITY_EDITOR // ActionTool里 + public bool isInEditMode;
+ public delegate void RegisterProjectileHandle(Projectile projectile);
+ public RegisterProjectileHandle registerProjectile;
+#endif +
public enum EEventType { EventCamera_Zoom, // 相机聚焦 @@ -118,4 +124,42 @@ public partial class TimelineEventProxy } + void EventProjectile(AnimationEventBase animEvent)
+ {
+ EventProjectile e = animEvent as EventProjectile;
+ if (e == null)
+ return;
+ string projectilePath = e.projectilePath;
+ GameObject prefab = ResourceManager.Instance.LoadAsset<GameObject>(projectilePath);
+ if(prefab == null)
+ {
+ LogHelper.LogError("缺少对应的projectile, " + projectilePath);
+ return;
+ }
+ if(prefab.GetComponent<Projectile>() == null)
+ {
+ LogHelper.LogError("没有projectile脚本");
+ return;
+ }
+ GameObject obj = GameObject.Instantiate(prefab);
+ Projectile projectile = obj.GetComponent<Projectile>();
+ ProjectileInfo info = new ProjectileInfo();
+ info.owner = m_Owner;
+ info.position = m_Root.transform.position + e.posOffset;
+ info.rotation = e.rotation;
+ info.scale = e.scale;
+ info.direction = Vector3.right;
+ info.velocity = Vector3.right * 10f;
+ info.lifetime = 5;
+ info.sparkPath = e.sparkPath;
+ projectile.Initialize(info);
+
+#if UNITY_EDITOR
+ if(isInEditMode && registerProjectile != null)
+ {
+ registerProjectile(projectile);
+ }
+#endif
+ } + }
\ No newline at end of file |