Instantiate object with button and place another object with mouse click

Hi, I’d like some help about this thing. I read a lot of tutorials and examples but couldn’t find what I need.
So, I’m trying to make a game object instantiate after clicking a UI Button and then wait for another mouse click to place another object. Like, the button will instantiate a small house and the second click will instantiate a bigger house. Anyone has any ideas on how to make this work? Thanks!

I was looking into this before and seem to work it out, are you familiar with Ray casts? That’s what you need. Here’s an example, it should get you stared, i figured it out last night so didn’t have much time to experiment and modify the code but it’ll do what you need.

    void Update()
    {
        ghost();
    }

	void ghost () {

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit hit;

        if (Physics.Raycast(ray,out hit))
        {
            transform.position = new Vector3(hit.point.x, hit.point.y, hit.point.z);
        }
	
	}
}

Attach that piece of code to the item that you want to ‘mimic’.
Make sure that its in the scene too.

Just answered a similar question for someone else, you might get more info from the script in that answer:

Old-GUI-to-New-GUI

what it does is click on a 4.6 UI button which instantiates an Image of a building that follows the mouse position and when the terrain is clicked it then instantiates that building at the terrain with a Raycast.

You could easily replace the Image with a smaller 3D copy of the house.