CanvasData.cs 438 B

12345678910111213141516171819202122
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class CanvasData : MonoBehaviour
  6. {
  7. public float UIScale
  8. {
  9. get
  10. {
  11. return Screen.width / referenceResolutionX;
  12. }
  13. }
  14. private float referenceResolutionX;
  15. private void Awake()
  16. {
  17. referenceResolutionX = GetComponent<CanvasScaler>().referenceResolution.x;
  18. }
  19. }