We will then convert them to prefabs which we can re use in our c# script to place them in a given area. Creating objects for random placement in unityįor this tutorial we want to create two basic shapes in unity so we can go and instantiate them in our scene. Let’s now look at creating our 2d objects which we want to place in random positions in our scene. Position it using the move tool in the top left.
![unity number generator unity number generator](https://saliu.com/images/ultimate-lottery-software-30.gif)
Your button should now be visible like this. Use the blue arrow to drag your quad behind your canvas like this. Then double click on your Quad and zoom out using your mouse wheel button. To fix this click on the 2d button to switch over into 3d mode. Once done you might notice that your button is not showing in your scene this is because of the depth of field of your canvas. On the right in the inspector change your text to generate. So on your canvas in the hierarchy right click on the canvas and go to ui and button.Ĭlick on the little drop down and click on the text ui element or game object. Once that is done your canvas should snap to the size of your camera view. As well as drag your camera into your render camera slot. Select the canvas in the hierarchy and go over the inspector on the right and change this option. To do this right click in the hierarchy again and go to ui and click on canvas. To create some UI for our scene we need to add a canvas inside of our scene. UI for our unity spawn an object at a random position tutorial Next we want to create a UI so we can generate random objects at random positions on the click of a button. Go ahead and resize it up so that it fills the whole camera view like this. You will now end up with a quad in the middle of the screen like this.
![unity number generator unity number generator](https://i.stack.imgur.com/8LAJX.png)
So go ahead and right click in the hierarchy and create a new 3d quad. To do this we will use a simple 3d quad to place into our 2d world. So let us now start off by creating a make shift terrain to spawn our objects onto. I called my project unity spawn object at random position 2d.