Search Unity

Question Add files to Assets folder on package import

Discussion in 'Package Manager' started by HCTQ, Mar 19, 2024.

  1. HCTQ

    HCTQ

    Joined:
    Jun 2, 2023
    Posts:
    1
    So I am creating a package for easily spinning up new projects using a set baseline. To this end i would like to add some files contained in the package to the user's Assets folder.

    Currently the samples system does this decently well. My main issues with this solution is that it moves folders to a Samples folder and not folders i can specify in the package, and that it requires an extra click in the package manager which is just annoying.

    Some Unity packages already do this like the XR Interaction Toolkit which ads an XRI folder to the users Assets when you install it.

    Is there some built in functionality in the package system that can do this? Or do i need to write an editor script that does it for me?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,025
    You need an editor script either way. I think the importPath property is the closes candidate. I have no exp but I would assume you new or get an instance of this when installing a package or sample and then you can assign the importPath of your choice.

    Otherwise, check the XR Interaction package. If this package does something special when installing you'll find this in some editor script in that package.