socialpoint-labs / unity-yaml-parser

Python3 library to manipulate Unity serialized files from outside the Unity Editor.
https://pypi.org/project/unityparser/
MIT License
137 stars 24 forks source link

fails to load utf-8 scene file #58

Open danilwhale opened 1 year ago

danilwhale commented 1 year ago

it just throws error that it cant load it python by default tries to open file in windows-1252, but it fails would be good if UnityDocument.load_yaml would use utf-8 encoding by default

@classmethod
    def load_yaml(cls, file_path):
        register = UnityScalarRegister()
        with open(file_path, newline='', encoding='utf8') as fp:
            data = [d for d in load_all(fp, register)]
            # use document line endings if no mixed lien endings found, else default to linux
            line_endings = UNIX_LINE_ENDINGS if isinstance(fp.newlines, tuple) else fp.newlines
        doc = UnityDocument(data, newline=line_endings, file_path=file_path, register=register)
        return doc
sp-ricard-valverde commented 1 year ago

Thanks for the report ! Feel free to open a PR following the contributing guidelines otherwise I'll eventually fix it.