Skip to content

Commit 80a281e

Browse files
committed
feat: show total time in auto shape emitter
1 parent a4a944a commit 80a281e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Packages/bullet-storm-unity/Scripts/Runtime/Emitters/AutoShapeEmitter.cs

+21-1
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ public class AutoShapeEmitter : AutoEmitterBase
2929
[Tooltip("A list where you can config every emission here."), ReorderableList, SerializeField]
3030
private ShapeConfig[] emissions;
3131

32+
[ShowNativeProperty]
33+
private float TotalTime => emissions?.Aggregate(0f, (f, config) => f + config.TotalTime) ?? 0;
34+
3235
#region reflection use only
3336

3437
// ReSharper disable once UnusedMember.Local
3538
private float EmitTimes =>
36-
emissions?.Aggregate(0, (i, config) => i + (config.repeat ? config.repeatTimes : 1)) ?? 0;
39+
emissions?.Aggregate(0, (i, config) => i + config.RepeatTimes) ?? 0;
3740

3841
#endregion
3942

@@ -124,6 +127,23 @@ public IReadOnlyList<BulletEmitParam> OverridenShape
124127
return copy;
125128
}
126129
}
130+
131+
public int RepeatTimes => repeat ? repeatTimes : 1;
132+
133+
public float TotalTime
134+
{
135+
get
136+
{
137+
var time = 0f;
138+
if (oneByOne && shape)
139+
{
140+
time += shape.shape.Count > 0 ? (shape.shape.Count - 1) * interval : 0;
141+
}
142+
time += wait;
143+
time *= RepeatTimes;
144+
return time;
145+
}
146+
}
127147
}
128148
}
129149
}

0 commit comments

Comments
 (0)