Skip to content

Commit 6001817

Browse files
committed
Fix 1233044 - capacity cannot be zero (#21)
* Prevent capacity from being 0 * Fix strip capacity as well
1 parent d90169c commit 6001817

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/VFXDataTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,34 @@ public void CheckAttributes()
161161
Assert.IsFalse(data.IsCurrentAttributeWritten(attrib3));
162162
Assert.IsTrue(data.IsCurrentAttributeWritten(attrib4));
163163
}
164+
165+
[Test]
166+
public void CheckCapacityCannotBeZero()
167+
{
168+
var init = ScriptableObject.CreateInstance<ContextTestInit>();
169+
var data = init.GetData();
170+
data.SetSettingValue("capacity", 0u);
171+
uint capacity = (uint)data.GetSettingValue("capacity");
172+
Assert.NotZero(capacity);
173+
}
174+
175+
[Test]
176+
public void CheckStripCapacityCannotBeZero()
177+
{
178+
var init = ScriptableObject.CreateInstance<ContextTestInit>();
179+
var data = init.GetData();
180+
data.SetSettingValue("dataType", VFXDataParticle.DataType.ParticleStrip);
181+
data.SetSettingValue("stripCapacity", 0u);
182+
data.SetSettingValue("particlePerStripCount", 0u);
183+
184+
uint capacity = (uint)data.GetSettingValue("capacity");
185+
uint stripCapacity = (uint)data.GetSettingValue("stripCapacity");
186+
uint particlePerStripCount = (uint)data.GetSettingValue("particlePerStripCount");
187+
188+
Assert.NotZero(capacity);
189+
Assert.NotZero(stripCapacity);
190+
Assert.NotZero(particlePerStripCount);
191+
}
164192
}
165193
}
166194
#endif

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
9+
### Fixed
10+
- Prevent capacity from being 0 [Case 1233044](https://issuetracker.unity3d.com/product/unity/issues/guid/1233044/)
11+
712
## [9.0.0] - 2020-07-09
813

914
### Added

com.unity.visualeffectgraph/Editor/Data/VFXDataParticle.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class VFXDataParticle : VFXData, ISpaceable
195195
{
196196
public override VFXDataType type { get { return hasStrip ? VFXDataType.ParticleStrip : VFXDataType.Particle; } }
197197

198-
protected enum DataType
198+
internal enum DataType
199199
{
200200
Particle,
201201
ParticleStrip
@@ -215,6 +215,14 @@ protected enum DataType
215215
protected override void OnSettingModified(VFXSetting setting)
216216
{
217217
base.OnSettingModified(setting);
218+
219+
if (setting.name == "capacity" && capacity == 0)
220+
capacity = 1;
221+
else if (setting.name == "stripCapacity" && stripCapacity == 0)
222+
stripCapacity = 1;
223+
else if (setting.name == "particlePerStripCount" && particlePerStripCount == 0)
224+
particlePerStripCount = 1;
225+
218226
if (hasStrip)
219227
{
220228
if (setting.name == "dataType") // strip has just been set

0 commit comments

Comments
 (0)