title: How CreatePrimitive custom object in unity c#?
body: <p>Im trying to make a conveyor belt system in unity, where I have a grid that all the objects will be placed on when I click there (it is from a tutorial video by jason weimanns). Right now it just makes cubes. Is there any way I could have a pre-made object with materials, textures and components and stuff, then copy it instead of the plain cube?</p>
  <p>This is the relevant code:</p>
  <pre><code>using UnityEngine;
  
  public class CubePlacer : MonoBehaviour
  {
      private Grid grid;
  
      private void Awake()
      {
          grid = FindObjectOfType&lt;Grid&gt;();
      }
  
      private void Update()
      {
          if (Input.GetMouseButtonDown(0))
          {
              RaycastHit hitInfo;
              Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  
              if (Physics.Raycast(ray, out hitInfo))
              {
                  PlaceCubeNear(hitInfo.point);
              }
          }
      }
  
      private void PlaceCubeNear(Vector3 clickPoint)
      {
          var finalPosition = grid.GetNearestPointOnGrid(clickPoint);
          GameObject.CreatePrimitive(PrimitiveType.Cube).transform.position = finalPosition;
  
          //GameObject.CreatePrimitive(PrimitiveType.Sphere).transform.position = nearPoint;
      }
  }
  </code></pre>