android - Generate a Unity 2d Game Object Dynamically within the different devices screen bounds -


i new unity , developing game wish create game object dynamically. problem how calculate random position game object remains within screen on different android devices. here have tried, approach correct? give me proper random position on android , ios devices?

//calculate screen width , screen height screenheight = camera.main.orthographicsize * 2.0f; screenwidth = screenheight * screen.width / screen.height;  //get random number in width of screen float randomx = random.range(-screenwidth / 2, screenwidth / 2);  //get random number in height of screen float randomy = random.range(-screenheight / 2, screenheight / 2); 

now game objects position (randomx, randomy).


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -