private void ApplyChanges(Image[] children) { var targetRotation = _graph.IsFlipped ? Quaternion.Euler(0, 0, -90) : Quaternion.identity; if (_rotationAnimation.End != targetRotation) { _rotationAnimation.Restart(targetRotation); } transform.localRotation = _rotationAnimation.CurrentValue; var targetColor = _graph.IsColored ? Globals.FilterActiveColor : new Color32(255, 255, 255, 255); targetColor.a = (byte)(_isEnabled ? 255 : 0); if (_colorAnimation.End.r != targetColor.r || _colorAnimation.End.g != targetColor.g || _colorAnimation.End.b != targetColor.b || _colorAnimation.End.a != targetColor.a) { _colorAnimation.Restart(targetColor); } foreach (var icon in children) { icon.material.color = _colorAnimation.CurrentValue; icon.enabled = _colorAnimation.CurrentValue.a > 0; } }
private void LateUpdate() { Offset = _graph.IsSelected ? OffsetSelected : OffsetNormal; Height = _graph.IsPickedUp ? HeightPickedUp : HeightNormal; var rotZ = _graph.IsFlipped ? 90 : 0; var rotY = 0; if (_graph.IsFlipped) { rotY = _graph.IsSelected ? 180 : -90; } else { rotY = _graph.IsSelected ? 0 : 90; } var targetRotation = Quaternion.Euler(0, rotY, rotZ); if (_rotationAnimation.End != targetRotation) { _rotationAnimation.Restart(targetRotation); } if (_needsUpdate || _heightAnimation.IsRunning || _offsetAnimation.IsRunning || _rotationAnimation.IsRunning) { ApplyPosition(); ApplyRotation(); _needsUpdate = false; } #if UNITY_EDITOR transform.localScale = Vector3.one * Scale; #endif }
private void RestartAnimations(Vector3 targetPosition, Quaternion targetRotation) { _positionAnimation.Restart(transform.position, targetPosition); _rotationAnimation.Restart(transform.rotation, targetRotation); }