Search Unity

Runtime editing - Is there a way to perform common ProBuilder actions w/o reinventing the wheel?

Discussion in 'World Building' started by Lipoly, Jul 15, 2020.

  1. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    I'm curious if there is a way to perform such actions such as translating/scaling/rotating/extruding/etc. a face/edge/vertex w/o going to the GitHub repo for ProBuilder and copy/pasting code.

    For example, is it possible to perform something like Scale(face, scale), Rotate(face, rotation, pivot), Translate(edge, translation), Scale(vertices, scale, pivot), etc?

    I know all the code is available on Github, and I could "re-implement" functionality to suite my needs, but I'm just curious if I'm missing something more simple to accomplish this.
     
    Last edited: Jul 15, 2020
  2. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
  3. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    Thanks. I know about the API, what I'm saying is unless I'm missing something, the API appears to be missing basic transform utilities for many operations. Most of the code seems to be buried in editor-only code and cannot be directly used at runtime.

    There is a translate method for vertices (https://docs.unity3d.com/Packages/c...UnityEngine.ProBuilder.VertexPositioning.html), but what about scaling/rotating vertices about a pivot?
     
  4. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    There are some convenience functions like TranslateVertices, but for the most part it's expected that you handle the math operations yourself. The ProBuilder API is more aimed at mesh actions, like extrusion or subdivision for example.

    I agree that more of these helper functions would be nice, especially when it comes to applying rotation and scale relative to a point. In the meantime I'd suggest just copying the logic from the relevant vertex tools.
     
  5. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    Thanks for the reply...I just wanted to make sure I wasn't missing something and unnecessarily duplicating code.