Search Unity

Graphics.DrawMesh in Prefab Stage

Discussion in 'Prefabs' started by Dmitry-Pyalov, Apr 16, 2019.

  1. Dmitry-Pyalov

    Dmitry-Pyalov

    Joined:
    Dec 13, 2011
    Posts:
    125
    Is there a way to make Graphics.DrawMesh render something in Prefab Stage? It works fine in editor but not in Prefab Stage.

    ExecuteAlways is set and Update method is being called, just doesn't render anything.
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    I don't think so. Generally all runtime APIs affect the main stage since Unity has no way of knowing that the method call comes from a Prefab stage. Except if the method call is on a component; then we can check which GameObject the component is on and whether that is in a Prefab stage; but for a static method like DrawMesh there's no way.
     
  3. Dmitry-Pyalov

    Dmitry-Pyalov

    Joined:
    Dec 13, 2011
    Posts:
    125
    It would be nice if there was a way to pass stage to DrawMesh or get the prefab stage camera to pass it to DrawMesh.

    And is it possible to create a utility MeshRenderer in a prefab stage and make sure that it doesn't get saved into prefab (HideAndDontSave or something)?
     
  4. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
  5. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    219
    HideAndDontSave should prevent objects being saved to the Prefab asset
     
  6. Dmitry-Pyalov

    Dmitry-Pyalov

    Joined:
    Dec 13, 2011
    Posts:
    125
    Thank you for your reply.

    SceneView.camera works only partially and is not usable for my case.
    HideAndDontSave works almost perfectly but the MeshRenderer, created in such way is still shown in the components list, though it is greyed out.