Straightforward, I would like something that gives me the same result from Screen.width and Screen.height without using Screen.
I suppose you could have a ui component that stretches across the height and width and then access it’s recttransform to get the width and height of the rect. I believe that would give the same numbers, but not sure why you’d want that over the Screen.width/.height
Why are you avoiding Screen?
the guy that is working with me created a script called Screen and now unity complains that Screen.width do not exist, so I got curious if there was another simple way (instead of UnityEngine.Screen.width)
It’s been answered in the other post now. Use Display https://docs.unity3d.com/ScriptReference/Display.html.
Just put that guys Screen class in a namespace. Then make sure to tell them to not make conflicting names without also putting them in a namespace. You should be able to use the API its there for easy of use.
Yep, just use a namespace…or, use Unity’s namespace.
So you could do
int screenWIdth = UnityEngine.Screen.width; For example to access Unity’s Screen vs the one created.
You could also use an using alias to remap a namespace to whatever you prefer:
using UnityScreen = UnityEngine.Screen;
public class Test : MonoBehaviour
{
private void Update()
{
Debug.Log("Width = " + UnityScreen.width);
}
}
Of course, I’d still go yell at the other guy for not putting his code into a namespace.
Or threaten him with creating your own UnityEngine class and let them sort out the namespace mess that’d create.