This works fine, but I’d like to be able to get this path as a relative one, using the “Data Source Folder” as a root.
The “Data Source Folder” option is in “Editor Preferences > General > Miscellaneous > Import > Data Source Folder”.
Is such an information accessible by script?
@unreal.uclass()
class EditorUtility(unreal.GlobalEditorUtilityBase):
_instance = None
@classmethod
def get(cls):
if not EditorUtility._instance:
EditorUtility._instance = EditorUtility()
return EditorUtility._instance
def get_data_source_folder():
"""Get the data source folder for the project.
:raises: RuntimeError if the data source folder is not set
:return:
"""
settings = EditorUtility.get().get_editor_user_settings()
data_source_folder = settings.get_editor_property("data_source_folder")
if not data_source_folder or not data_source_folder.path:
raise RuntimeError(
"No Data Source Folder set. Set the Data Source Folder in "
"Editor Preferences > Miscellaneous > Import > Data Source Folder"
)
return data_source_folder.path