Button Instantiate a Perab

I want to create spell so when player click on button it instantiate perfab on mouse cursor and it is not active until player put it somewhere.Any help?

void Update() {
   if (GUI.Button(new Rect(Screen.width / 4 * 3, Screen.height / 4, 25, 10), "Example Spell")) {
      // The button has been clicked and it instantiate a pefab on mouse cursor, but it still need to player place perfab to be active
   }
 }

bump

and

use those together and you can instantiate a prefab at the cursor easy.

I tried but i really cant recreate what i want:
(This):

You see, when player press buton (P - example) , something like crossair is spawned at mouse and when player click with that crossair (aim) somewhere, it spawn an “attack perfab” . How to do it? Please.

Im working with JS.

bump

bool SpellActive= false;


void Update()
{
  if(Input.GetKeyDown(KeyCode.P))
    SpellActive= true;

   ActivateSpell();

}


void ActivateSpell()
{
 if(!SpellActive) return;

  if(Physics.RayHit( .... )) // cant remember this code off hand... sure you can figure it out
 {
   //active the spell stuff

 SpellActive = false;
}

}

thanks even i work with js, this helped me to figure out how to make it.Thanks!