Search Unity

ProBuilder Export asset not working with .NET 4.x API

Discussion in 'World Building' started by se, May 17, 2018.

  1. se

    se

    Joined:
    May 20, 2013
    Posts:
    26
    I'm using 2018.1.0f2 on Windows 10.

     
    phobos2077 likes this.
  2. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    Having the same issue with 2018.1.3f1. Any solution yet? (except to use old .NET runtime)
     
  3. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    173
    Could you please open a case for this in Fogbugz?
     
  4. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    Could you give a link?

    This issue is rather annoying as it prevents me from using new version of C# because I need "Export asset" as part of my prototyping workflow (very convenient to make simple models for prefabs in-editor without going to Maya).
     
  5. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    173
    You can report a bug using the menu item "Help / Report a bug..."

    I wasn't able to reproduce the problem on my machine, but with a bug report our testers will be able to test with a variety of setups.
     
  6. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    Just tested again by creating a blank project with just a ProBuilder 3.0.9 installed, some stairs and .NET 4.x selected in the Player Settings. The issue is 100% reproducible.

    I have sent the bug report via menu item in Unity.
     
  7. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    So I got tired of waiting for a fix and decided to look into it. It turns out the reason for error is function Path.GetDirectoryName() returning the path with "\" as directory separator on my windows, while the rest of Unity functions that deal with paths return path with "/" as separator. This issue is only with ".NET 4.x equivalent". This is rather serious issue IMO and should be dealt sooner rather than later, as it can potentially break a lot of stuff not just ProBuilder.

    It turns out the Probuilder functions involved are public and so I created my own implementation of asset export without this issue and with some QoL improvements:
    https://gist.github.com/phobos2077/5cc09cac2bc2cbe5c877d3cd11aac9db
     
    unity_NslhCrUTTOWLXw likes this.
  8. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    215
    Not anymore.

    using ProBuilder.EditorCore;

    Not there.
     
  9. Elapse

    Elapse

    Joined:
    Feb 5, 2016
    Posts:
    5
    I have the same issue. Just updated from 2018.2.9 to 2018.2.14 with no change.
    I'd like to use your fix Phobos. Could you tell me please, how to implement and make use of it?
     
  10. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    215
    What's weird is if you look at the bug page, it says fixed in Probuilder 4.0. However We cnnot get PB 4.0. so what is the point?
     
  11. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    In my post there is a link. Just save that file to your Scripts/Editor folder, change the path in the code (it is specific to my game now), and you should be good to go.

    I used this solution for some time and it still works pretty well for me. But in other thread I think ProBuilder developer told me they fixed/revamped this functionality in new version of ProBuilder. Haven't checked that one yet.
     
  12. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    274
    Not fixed in the old version on the store. Need to use that for a 2017.4 project..
     
  13. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    So I checked the latest version and "Export Asset" function still doesn't work as well as it could. It uses the random internal ProBuilder mesh name for the mesh asset instead of the (more logical) object name. Who would want to have mesh asset named incomprehensibly?

    @gabrielw_unity please consider my solution in the post above. It has a bunch of improvements that you might find useful.
     
  14. DarkNBlood

    DarkNBlood

    Joined:
    Jun 19, 2014
    Posts:
    28
    Hi,
    trying your script but errors :
    Code (CSharp):
    1. Assets\Scripts\Editor\ProBuilderTools.cs(5,7): error CS0246: The type or namespace name 'ProBuilder' could not be found (are you missing a using directive or an assembly reference?)
    Any idea ? Using Unity 2018.3.12f1

    Thanks
     
  15. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    It seems the code needs to be updated for 4.x version. It was written for 3.x.

    Edit: I've upgraded the gist to work with latest ProBuilder. Didn't change the code much from the way it was (based on 3.x original export code), but still works and works better than built-in export. May required to use an assembly definition file for the folder where this script resides in (you need to add reference to Unity.ProBuilder and Unity.ProBuilder.Editor).

    Found out that ProBuilder code is not open source. I'll probably make this into a pull request (to improve original menu item instead of hacking a new one) later.

    Issues that I'd like to address (that are fixed in my code above):
    - Mesh asset is saved under internal Mesh object name (like "pb_Mesh22270") instead of more helpful game object name
    - Prefab replacement is not handled at all. If you either used the generated prefab or just the mesh asset directly, your game objects will be broken after you "Export asset" with the same name
     
    Last edited: Apr 14, 2019
    unity_NslhCrUTTOWLXw likes this.
  16. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    57
    My pull request was accepted, if anyone needs the asset export improvements explained above you may grab the version 4.1.0 or later.
     
    kaarrrllll likes this.