Search Unity

ScriptedImporter - Creating directories and files?

Discussion in 'Editor Workflows' started by jwvanderbeck, Aug 21, 2017.

  1. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    I hope this is the correct place to post this.

    I am trying to build a custom importer for our in house asset system, and I am using the ScriptedImporter working off a sample Alembic one that I found on GitHub.

    I have the basics working in a test environment with manually setup assets, but one thing that I need to do as part of the import process for real is, for a given Model asset, I need to COPY over the physical file from our asset system to the local project, create a new directory for the textures, and physically copy over the textures along with a sidecar file.

    I'm unclear on how to go about doing the copying and what not. Do I just use standard .NET methods for file manipulation here, and is that ok to do during the importer process, or do I need to use some custom Unity stuff that manipulates the project database?

    EDIT to add: Another part of this would be coordinating things. I imagine that if I copy of the JPG files from our asset system to the local project that Unity it going to go ahead and try to ingest them on its own, which I want, but I also need to hook those up to materials that acre created as part of the Model import system. How do I make sure these things happen in the correct order so that the textures are imported and available to be used in the Model import, yet I need to import the textures as part of the model process, unless I get really creative (the model package in our pipeline is what points me to the textures so I don't know where they are or which ones to grab until I start parsing the model asset)
     
  2. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    As an addendum to this, would it be possible to make the image files for the textures be sub assets of the main model rather than loosely imported files that are then linked?
     
  3. markvi

    markvi

    Joined:
    Oct 31, 2016
    Posts:
    118