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 Writing imported asset mesh data at runtime to file to generate prefab later?

Discussion in 'Asset Importing & Exporting' started by mcbauer, Dec 16, 2022.

  1. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    524
    So I have been banging my head around on this one, and I keep coming back to "just use the unity editor" as the solution, but its not what my client wants. We are trying to give them an app that removes the complex UX of a 3d game engine and simplify their need to add models, build interactions, save and reload data. They are not able to hire a unity dev to do all this, it needs to be their instructional designers.

    The problem I'm trying to solve is this:

    User runs the exe, imports some random fbx model ( thanks TriLib ) and can do whatever they want with it while the app is running. However, once the app is closed, we need to have access to the game object without re-importing it, as it now should be a part of their library.

    My thought was after import, write the mesh data to a file, and then rebuild at runtime, and re-construct the game object. But is this really any different than just straight importing? I don't believe it is.

    I am beginning to believe that what I need to do is add in a loading screen when the app first runs, and just handle all the importing at that time.

    What I'd love to be able to do, is save the model that is imported as a prefab so it can be loaded via Resources later, but I'm not sure this is possible.

    Is my solution just to reimport with each load of the app?
     
  2. bastien_humeau

    bastien_humeau

    Unity Technologies

    Joined:
    Jun 14, 2017
    Posts:
    191
    I think it really depends on the complexity of the mesh and how much process TriLib is doing on them. Meshes in Unity require triangulated polygons which is not always the case in most common formats, so saving the resulting Mesh directly instead of re-using the original file can save you some time the import spend on modifying that data.

    Resources are built and packaged during the build to be as optimal as possible for runtime, they are then part of the read-only game data, so you can't modify them while using your application.