Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Design pattern for "Reference Counting" assets?

Discussion in 'Scripting' started by sebj, Feb 6, 2019.

  1. sebj

    sebj

    Joined:
    Dec 4, 2013
    Posts:
    70
    Hi,

    I have a component that builds BVHs.

    While only a few mb, they are big enough to make large scenes pose a problem for the source control system when serialised as part of a scene.

    I know the correct solution is to save these as an asset, and store the reference. I don't want to bother the developer with handling these assets though.

    The BVH's will not be shared. They are quick to build. (And while I know its common, I don't think they should be shared between meshes, as there are many cases in which meshes may be modified on a per object basis.)

    I'd like it to appear as if the BVH were a member of the instance of the Component saved with a scene/prefab, when in fact they are stored in a separate file.
    When the Component is deleted, reset, the editor crashes without saving, etc, that file is cleaned up.

    Is there a design pattern that does this?