How do I set a gameobject to appear in the same location regardless of build type?

I made a 2D game that has a number of sprites and spawn points based aligned to a canvas background. It works fine on a desktop build, even when changing resolutions, but when I change the build to Android, the gameobjects have all shifted their positions. What can I do to make sure that the objects will keep their positions when I change builds?

80681-correct.png

If your elements are inside Canvas, then change that Canvas’s “Canvas scalar” Components property “UI Scale Mode” to ‘Scale with screen size’ and set the “Match” value to 0.5

After more Googling and trying a couple of different solutions, I finally found the following to work for me:

float cameraHeight = Camera.main.orthographicSize * 2;
float cameraWidth = cameraHeight * Screen.width / Screen.height;

#if UNITY_ANDROID || UNITY_IOS || UNITY_WP8
	gameObject.transform.localScale = Vector3.one * cameraHeight / 11.0f;
#else
	gameObject.transform.localScale = Vector3.one * cameraHeight / 10.0f;
#endif

Hope it helps someone else with the same problem.