Search Unity

Feedback Add LineRenderer.BakeMesh API which does not require a camera

Discussion in 'Scripting' started by Xarbrough, Aug 24, 2019.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I really like the existing LineRenderer.BakeMesh API, but there's one thing that bugs me a about it: It requires Camera.main to be available when called. If there is no camera in the scene, BakeMesh throws an exception and does not create the mesh. I understand that the camera will be used to determine how the LineRenderer line is oriented towards the camera, if it uses view/camera alignment.

    However, in my case, my LineRenderer is set to Transform Z Alignment, which means, that it does not align to the view and does not need a camera at all. When I call BakeMesh I can ensure that the settings are correct and I really don't want to have a camera in the scene. I also don't see any reason why the BakeMesh function would need a camera other than for alignment.

    Would it be possible for Unity to remove this dependency on the camera and provide a BakeMesh call which does not support view alignment and does not require a camera?
     
  2. LuisMer

    LuisMer

    Joined:
    Jan 22, 2019
    Posts:
    3
    I do agree. To have a line renderer with a fixed orientation is quite a feasable scenario.
    As far as I checked the overload with not camra argument is not working ("public void BakeMesh(Mesh mesh, bool useTransform = false);"). Error in console appear logging that the camera argument cannot be null, and the mesh is not created. Maybe I am doing something wrong.
    Moreover to set the line renderer orientation I think it is much more reasonable to have a Vector3 or a Quaternion overload than a camera. Very probably that has an explanation which I am not aware of and of whom I would be very glad to hear about.
     
  3. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    226
    I just ran into this problem myself. I am using BakeMesh for some procedural mesh generation and I do that in a scene that gets loaded asynchronously. So it works fine when I play the scene that loads this scene via async, but if I want to test the scene directly I can't.