random stuff i forgot to commit
This commit is contained in:
parent
274af1e5a1
commit
b0625ae834
59 changed files with 7806 additions and 664 deletions
22
Assets/Scripts/GetPixelSize.cs
Normal file
22
Assets/Scripts/GetPixelSize.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class GetPixelSize : MonoBehaviour
|
||||
{
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
Bounds bounds = spriteRenderer.bounds; // World-space boundary box
|
||||
|
||||
// Convert the minimum and maximum world space corners to screen pixel positions
|
||||
Vector3 minScreenPos = Camera.main.WorldToScreenPoint(bounds.min);
|
||||
Vector3 maxScreenPos = Camera.main.WorldToScreenPoint(bounds.max);
|
||||
|
||||
// Calculate the actual screen pixel delta
|
||||
float screenPixelWidth = maxScreenPos.x - minScreenPos.x;
|
||||
float screenPixelHeight = maxScreenPos.y - minScreenPos.y;
|
||||
|
||||
Debug.Log($"Name: {gameObject.name}Actual Screen Size: {screenPixelWidth}x{screenPixelHeight} physical pixels");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue