Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

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

  1. Xarbrough


    Dec 11, 2014
    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


    Jan 22, 2019
    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


    Jun 25, 2018
    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.