SerializedProperty GetValueProperty(AudioOption.Types type, bool hasCurve, SerializedObject dummy) { var propertyName = type.ToString() + (hasCurve ? "Curve" : ""); var valueProperty = dummy.FindProperty(propertyName); return(valueProperty); }
void InitializeValue(AudioOption.Types type) { if (dynamicValue.IsArray || (dynamicValue.Type == DynamicValue.ValueTypes.Null && dynamicValue.Value == null)) { dynamicValue.Value = AudioOption.GetDefaultValue(type); } if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale) { var data = audioOption.GetValue <Vector3>(); valueProperty.SetValue(data.x); timeProperty.SetValue(data.y); easeProperty.SetValue((TweenUtility.Ease)data.z); } else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut) { var data = audioOption.GetValue <Vector2>(); valueProperty.SetValue(data.x); easeProperty.SetValue((TweenUtility.Ease)data.y); } else { valueProperty.SetValue(dynamicValue.Value); } }
bool CanHaveCurve(AudioOption.Types type) { return (type == AudioOption.Types.SpatialBlend || type == AudioOption.Types.ReverbZoneMix || type == AudioOption.Types.Spread || type == AudioOption.Types.RolloffMode); }
bool HasCurve(AudioOption.Types type, object value) { return (type == AudioOption.Types.SpatialBlend || type == AudioOption.Types.ReverbZoneMix || type == AudioOption.Types.Spread || (type == AudioOption.Types.RolloffMode && (AudioRolloffMode)value == AudioRolloffMode.Custom)); }
SerializedProperty GetCurveProperty(AudioOption.Types type, object value, SerializedProperty property) { SerializedProperty curveProperty = null; if (HasCurve(type, value)) { curveProperty = property.FindPropertyRelative("curve"); } return(curveProperty); }
SerializedProperty GetEaseProperty(AudioOption.Types type, SerializedObject dummy) { SerializedProperty easeProperty = null; if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale || type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut) { easeProperty = dummy.FindProperty("EaseType"); } return(easeProperty); }
SerializedProperty GetTimeProperty(AudioOption.Types type, SerializedObject dummy) { SerializedProperty timeProperty = null; if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale) { timeProperty = dummy.FindProperty("EaseTime"); } return(timeProperty); }
void SetValue(AudioOption.Types type, bool hasCurve) { serializedObject.ApplyModifiedProperties(); var valueType = AudioOption.ToValueType(type, hasCurve); dynamicValue.SetType(valueType, isArray); if (type == AudioOption.Types.VolumeScale || type == AudioOption.Types.PitchScale) { dynamicValue.Value = new Vector3(valueProperty.GetValue <float>(), timeProperty.GetValue <float>(), (float)easeProperty.GetValue <TweenUtility.Ease>()); } else if (type == AudioOption.Types.FadeIn || type == AudioOption.Types.FadeOut) { dynamicValue.Value = new Vector2(valueProperty.GetValue <float>(), (float)easeProperty.GetValue <TweenUtility.Ease>()); } else { dynamicValue.Value = valueProperty.GetValue(); } dynamicValue.Serialize(); serializedObject.Update(); }