Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Is it possible to modify .blend file geometry data using C# in Unity at runtime?

Discussion in 'Scripting' started by ue_dev, Feb 1, 2023.

  1. ue_dev

    ue_dev

    Joined:
    Feb 1, 2023
    Posts:
    8
    So I'm wonder how to access .blend file data such as specific vertex, line, face, or geometry nodes etc. and modify it using C# in Unity at runtime.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,890
    Bunny83 and ue_dev like this.
  3. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    Yeah. When you import a .blend file, Unity uses your Blender install to export the model to FBX (iirc), then handles that file as usual.

    Hence why I now keep .blend files out of Assets -- it has caused headaches for teammates who don't have Blender installed! Instead, I use this exporter add-on so that I can hit a button to export a new .fbx file (with all of the important settings remembered so that I don't have to configure them every time!)
     
    Kurt-Dekker and ue_dev like this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    TIL! This is why I hang out here, I learn interesting things every day.

    The other drawback with Blender files is that you could never use Unity cloud build, but since that seems like less of a thing these days than in the past, it may be no factor.

    OP: if you want examples of manipulating geometry, check out my MakeGeo project.

    The hardest part will be identifying which vertices you want to change, as well as understanding that a single vertex in Blender can have many UVs/colors/normals associated with different faces, BUT in Unity it must always be separate vertices at the same positions, each with different other data. This change happens at import time.

    MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo
     
    ue_dev likes this.
  5. JuanGuzmanH

    JuanGuzmanH

    Joined:
    Feb 8, 2018
    Posts:
    73
    This is not exactly what you ask, but have a look to this experimental package that sync the mesh in realtime


     
    ue_dev likes this.
  6. ue_dev

    ue_dev

    Joined:
    Feb 1, 2023
    Posts:
    8
    Hi, this seems to be so good but I don't see any tutorials about it in Unity.
    I'm just starting Unity so I don't really know how to access and modify the .fbx file's data yet.
    Can you atleast tell me your workflow step by step and with screenshots if possible?
    That's if I'm not bothering you, of course.
     
    Last edited: Feb 2, 2023
  7. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,610
    As mentioned you need to use Unity's Mesh API linked in the first response in this thread.

    Plenty of examples in the docs, and I'm sure there's tutorials out there on the net too.

    Mind you mesh stuff is intermediate to advanced stuff. I only touched it for the first time after using Unity for two or so years now and it took a while for me to get my head around it.
     
    ue_dev likes this.
  8. ue_dev

    ue_dev

    Joined:
    Feb 1, 2023
    Posts:
    8
    Oh, so that's why it's hard to find tutorials about it.

    Is this Runtime Mesh Manipulation related to Mesh API?
    https://www.kodeco.com/3169311-runtime-mesh-manipulation-with-unity

    If so, can I use this to make my Character Customization System or is there a more better way on creating this feature?
     
    Last edited: Feb 2, 2023
  9. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    Could you explain what you want to do, exactly?
     
    ue_dev likes this.
  10. ue_dev

    ue_dev

    Joined:
    Feb 1, 2023
    Posts:
    8
    The Blender add-on you shared to us is what I exactly need.
    I wanted to access the FBX's Custom Property from Blender in Unity, and I've learned that the add-on saves a lot of useful stuffs when exporting.

    Now I wanted to ask you if I include Custom Properties when using Exporter Add-On, how do I access these in Unity? Will it automatically show on the editor or is there something else I need to do? Also, will I be able to modify these Custom Properties from the FBX and see the changes in runtime and binary builds?

    Sorry for taking too long to reply, I was looking to use Unreal Engine the past weeks but it seems Unity is the best when it comes to working with cel shading. Thanks a lot for sharing the exporter add-on!