| | 1 | | using TMPro; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace DCLServices.MapRendererV2.MapLayers.PointsOfInterest |
| | 5 | | { |
| | 6 | | internal class SceneOfInterestMarkerObject : MapRendererMarkerBase |
| | 7 | | { |
| 16560 | 8 | | [field: SerializeField] internal TextMeshPro title { get; set; } |
| 38640 | 9 | | [field: SerializeField] internal SpriteRenderer[] renderers { get; private set; } |
| | 10 | |
|
| | 11 | | private float titleBaseScale; |
| | 12 | | private Vector3 titleBasePosition; |
| | 13 | |
|
| | 14 | | private const float Y_POSITION_OFFSET = -0.2f; |
| | 15 | |
|
| | 16 | | private void Awake() |
| | 17 | | { |
| 5520 | 18 | | titleBaseScale = title.transform.localScale.x; |
| 5520 | 19 | | titleBasePosition = title.transform.localPosition; |
| 5520 | 20 | | } |
| | 21 | |
|
| | 22 | | public void SetScale(float baseScale, float newScale) |
| | 23 | | { |
| 0 | 24 | | transform.localScale = new Vector3(newScale, newScale, 1f); |
| | 25 | |
|
| | 26 | | // Apply inverse scaling to the text object |
| 0 | 27 | | float positionFactor = newScale / baseScale; |
| 0 | 28 | | float yOffset = (1 - positionFactor) * Y_POSITION_OFFSET; |
| | 29 | |
|
| 0 | 30 | | float yValue = yOffset < 0.9f |
| | 31 | | ? titleBasePosition.y + yOffset |
| | 32 | | : titleBasePosition.y / positionFactor; |
| | 33 | |
|
| 0 | 34 | | title.transform.localPosition = new Vector3(titleBasePosition.x, yValue, titleBasePosition.z); |
| | 35 | |
|
| 0 | 36 | | float textScaleFactor = baseScale / newScale; // Calculate the inverse scale factor |
| 0 | 37 | | title.transform.localScale = new Vector3(titleBaseScale * textScaleFactor, titleBaseScale * textScaleFactor, |
| 0 | 38 | | } |
| | 39 | | } |
| | 40 | | } |