I am new to unity and I was wondering how would I get a image to always stay in the top right corner, no matter what the screen size. Also would it be possible to place the text “x3” to the right of the image?
Not sure if this will help, but take a look at this and see what you think.
This should work for an object (transform) in 2d, I didn’t test it so you might need to change some stuff.
yourobject.position = new Vector2 (MCam.ScreenToWorldPoint (new Vector3 (Screen.width, 0f, 0f)).x + 0f, 3.5f);
Are you trying to make some HUD? For a HUD or other 2D GUI Unity has a whole new system to make things easier.
You have the legacy GUI system, where you need to handle everything with code, and you have the new uGUI system, where you place objects in the hierarchy just like any other object.
Using the uGUI you have to add an Image to your hierarchy (Create → UI → Image). This will add a Canvas with the Image inside, and an EventSystem.
The Canvas has a CanvasScaler component that handles how all the UI is resized (or not). To always fit the screen use the UI Scale Mode “Scale with screen size”, and in the Screen Match mode select Expand. This setup will make sure your canvas always fits inside your screen.
Now, the UI Image (or any UI component) can be anchored to different parts of the screen or their parent objects. For your question the Image should have it’s pivot set to the top-right corner, the anchor to top-right too, and make sure posX and posY are set to 0.
This will place the Image at the top right, but your next question was to add a “x3” at the right, so you’ll have to make something different.
You can create an empty game object inside the canvas and place that game object in the top-right corner. Then inside that object you can add the UI Image and a UI Text.
Look here to understand how the new UI works: https://unity3d.com/es/learn/tutorials/modules/beginner/ui/ui-canvas