public int ResolveDriver(IReadOnlyReanimatorState previousState, ReanimatorState nextState, int size) { if (size == 0) { return(0); } string driverName = string.IsNullOrEmpty(name) ? guid : name; if (percentageBased) { float floatDriverValue = Mathf.Clamp01(previousState.GetFloat(driverName)); if (floatDriverValue < 1) { return(Mathf.FloorToInt(floatDriverValue * size)); } return(size - 1); } int driverValue = previousState.Get(driverName) % size; if (autoIncrement) { nextState.Set(driverName, (driverValue + 1) % size); } return(driverValue); }
public void ShouldUseCorrectDriver() { _previousState.Clear(); _nextState.Clear(); _previousState.Set(DriverName, 2); var frame = _testedNode.ResolveCel(_previousState, _nextState); Assert.AreEqual(frame, _keyframes[2]); }