/*protected override void OnPingFinish() * { * SetAmountToScale(true, 1f); * } * * protected override void OnPongFinish() * { * SetAmountToScale(false, 1f); * }*/ #endregion #region Other Methods private void CheckIfCanClampInitialValues(bool p_isPing) { if (Target != null) { if (UseVectorsToClampInitialValues && ScaleTypeOption != ScaleTypeOptionEnum.ScaleBy && ScaleTypeOption != ScaleTypeOptionEnum.ScalePercentBy) { if (p_isPing) { if (IsLocalScale) { Vector3 v_vectorLocal = new Vector3(Target.localScale.x, Target.localScale.y, Target.localScale.z); v_vectorLocal.x = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToX) ? ScaleBackVector.x : v_vectorLocal.x; v_vectorLocal.y = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToY) ? ScaleBackVector.y : v_vectorLocal.y; v_vectorLocal.z = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToZ) ? ScaleBackVector.z : v_vectorLocal.z; Target.localScale = v_vectorLocal; } else { Vector3 v_vectorGlobal = new Vector3(Target.lossyScale.x, Target.lossyScale.y, Target.lossyScale.z); v_vectorGlobal.x = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToX) ? ScaleBackVector.x : v_vectorGlobal.x; v_vectorGlobal.y = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToY) ? ScaleBackVector.y : v_vectorGlobal.y; v_vectorGlobal.z = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToZ) ? ScaleBackVector.z : v_vectorGlobal.z; ScaleTween.SetLossyScale(Target, v_vectorGlobal); } } else if (UseScaleBackVector) { if (IsLocalScale) { Vector3 v_vectorLocal = new Vector3(Target.localScale.x, Target.localScale.y, Target.localScale.z); v_vectorLocal.x = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToX) ? ScaleVector.x : v_vectorLocal.x; v_vectorLocal.y = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToY) ? ScaleVector.y : v_vectorLocal.y; v_vectorLocal.z = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToZ) ? ScaleVector.z : v_vectorLocal.z; Target.localScale = v_vectorLocal; } else { Vector3 v_vectorGlobal = new Vector3(Target.lossyScale.x, Target.lossyScale.y, Target.lossyScale.z); v_vectorGlobal.x = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToX) ? ScaleVector.x : v_vectorGlobal.x; v_vectorGlobal.y = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToY) ? ScaleVector.y : v_vectorGlobal.y; v_vectorGlobal.z = EnumExtensions.ContainsFlag(ScaleTypeOption, ScaleTypeOptionEnum.ScaleToZ) ? ScaleVector.z : v_vectorGlobal.z; ScaleTween.SetLossyScale(Target, v_vectorGlobal); } } } } }
protected virtual void SetAmountToScale(bool p_isPing, float p_timeScale) { if (Target != null) { float v_timeScale = p_timeScale; Vector3 v_timeScaleVector = new Vector3(ScaleValueBy.x * v_timeScale, ScaleValueBy.y * v_timeScale, ScaleValueBy.z * v_timeScale); Vector3 v_vectorToAdd = new Vector3(v_timeScaleVector.x - CurrentScaledValueBy.x, v_timeScaleVector.y - CurrentScaledValueBy.y, v_timeScaleVector.z - CurrentScaledValueBy.z); CurrentScaledValueBy = v_timeScaleVector; if (!p_isPing && !UseScaleBackVector && ScaleTypeOption != ScaleTypeOptionEnum.ScalePercentBy) { v_vectorToAdd = new Vector3(-v_vectorToAdd.x, -v_vectorToAdd.y, -v_vectorToAdd.z); } if (m_isLocalScale) { Target.localScale = new Vector3(Target.localScale.x + v_vectorToAdd.x, Target.localScale.y + v_vectorToAdd.y, Target.localScale.z + v_vectorToAdd.z); } else { Vector3 v_newLossyScale = new Vector3(Target.lossyScale.x + v_vectorToAdd.x, Target.lossyScale.y + v_vectorToAdd.y, Target.lossyScale.z + v_vectorToAdd.z); ScaleTween.SetLossyScale(this.transform, v_newLossyScale); } } }