Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Feature Request 'Unity as Library' Change Data Folder

Discussion in 'Editor & General Support' started by CyRaid, Feb 5, 2021.

  1. CyRaid

    CyRaid

    Joined:
    Mar 31, 2015
    Posts:
    134
    I'm using the Unity as Library UnityLibrary.dll, and calling the UnityMain, but I really do not want the data folder next to my executable.

    Can you *please* add, say, a command line option to change the data directory to a different path? Even as much as allowing me to set current directory first if you really need to.

    I'm sure there would be many pleased in general if you allowed a player command line to change the data directory as well.
     
  2. Teolog

    Teolog

    Joined:
    Jun 4, 2014
    Posts:
    4
    +1.
    Try use unity as library but can't. Unity data search path hardcoded to main process executable, but not UnityPlayer.dll module and can't be changed.
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,521
    Pass in "-datafolder" command line argument when invoking UnityMain, like "-datafolder path\to\my\data\folder".
     
  4. Teolog

    Teolog

    Joined:
    Jun 4, 2014
    Posts:
    4
    "-datafolder absolutepath" not work at least for Unity 2021.3.24.
    For some reason Unity still not use defined folder, but searching for "{exename}_data" in directory there exe located.
    Error:

    Application folder:
    D:/ProjectDir/bin/Debug/net6.0
    There should be 'SimpleEngine_Data'
    folder next to the executable
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,521
    Ah darn, that was added to Unity 2022.2.
     
  6. TheKramer

    TheKramer

    Joined:
    Aug 23, 2021
    Posts:
    1
    > Ah darn, that was added to Unity 2022.2.

    Tried this with Unity 2023.3. It did not seem to work. Is this feature actually implemented?

    I couldn't find it in the command-line documentation: https://docs.unity3d.com/2023.3/Documentation/Manual/PlayerCommandLineArguments.html

    EDIT: This seems to work, however without the mono runtime (MonoBleedingEdge) being in the same folder as the executable, this seems to still fail.

    This folder structure Unity requires is quite rigid. Is there no hope for developers who would like to execute UnityMain from a path that's completely outside of Unity's required folder structure?
     
    Last edited: Oct 2, 2023
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,521
    That should work with IL2CPP, I believe. MonoBleedingEdge folder is hardcoded to be next to the executable, though :(.