/// <summary> /// Sets the RawValue of this Interpolator and invokes the value changed events. /// </summary> public void SetRawValue(float rawValue, bool notify = true) { _rawValue = Mathf.Clamp01(rawValue); if (notify) { //invoke value changed events for any scripts that use them RawValueChanged?.Invoke(RawValue); ValueChanged?.Invoke(Value); //let attached objects know that value has changed as well for (int i = 0; i < InterpolatableObjects.Count; i++) { GameObject io = InterpolatableObjects[i]; if (!io || !io.activeInHierarchy) { continue; } //set value on all IInterpolatable components from the attached GameObject foreach (IInterpolatable ii in io.GetComponents <IInterpolatable>()) { //skip disabled objects if (!ii.IsActive()) { continue; } //set the value! ii.SetValue(Value); } } } }
protected virtual void OnRawValueChanged() { RawValueChanged?.Invoke(this, EventArgs.Empty); }