Can prefab always on top of camera?

I will move my camera transform position x each time i press a button and in a same time it will instantiate my prefab.
May i make my prefab always follow the camera and transform position x each time i press the button?

If I understand what you mean, it should work. If you show what you want to do it will be easier to tell.

1368345--68607--$NewMemo_25092013_164418.jpg
That is my theory.
I just do the camera part.
Prefab part don’t know how to do.

using UnityEngine;
using System.Collections;

public class CameraScript : MonoBehaviour {


	// Use this for initialization
	void Start () 
    {
	
	}
	
	// Update is called once per frame
	void Update () 
    {
        if (Input.GetMouseButtonDown(0))
            OnMouseDown();
        return;
	
	}

    void OnMouseDown() 
    {
        Vector3 myCamera = transform.position;
        myCamera.y += 0.2f;
        transform.position = myCamera; 
        
    }
}

Do you want to instantiate a new prefab each time you move the camera? Or only once and then have that one prefab follow the camera?

instantiate new prefab. Can it be?

using UnityEngine;using System.Collections;


public class CameraScript : MonoBehaviour
{
    public GameObject myPrefab; // Drag prefab here


    // Use this for initialization
    void Start()
    {


    }


    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
            OnMouseDown();
        return;
    }


    void OnMouseDown()
    {
        Vector3 myCamera = transform.position;
        myCamera.y += 0.2f;
        transform.position = myCamera;

        // This spawn prefab
        GameObject go = (GameObject)Instantiate(myPrefab, (myCamera - new Vector3(0,10,0)), Quaternion.identity);
    }
}

Adjust where I put (myCamera - new Vector3(0, 10, 0)) for where you want it and Quaternion.identity for rotation

What GameObject go use for?
And i got error cannot assigned variable myprefab. << Fix
But my prefab become at bottom? Help!

go uses myPrefab I only assign it because I assume you want to do something with the prefab, if you don’t just remove and spawn without assigning.
If you want to change prefab spawn point change (myCamera - new Vector3(0, 10, 0)) and make it where you want to spawn it. if you want to spawn exactly same position as camera just use myCamera, otherwise specify by add or subtract with Vector3 like my example.

Thanks! It fix my problem.