- Home /
assign file type to a game?
Hi,
i want to make a mac game with a simple level editor that allows people to write a custom XML file type with my own extension they can share.
Is there a way to register my unity game to open this file type in OS X (and to do this abstract for the user, so when they got the game from the app store, the icons for the level XMLs should change to my defined icon). SO when people double-click the XML someone sent them via e-mail, it should simply open the game and load the level from the file.
Does anyone have an answer for OSX?
Double clicking on a file on OSX does not put the filename on the command-line arguments, as it does on windows. $$anonymous$$odifying the Info.plist is only part of the answer. You also need to provide a custom implementation for NSApplicationDelegate openFile.
How do you hook that into a unity project?
Sorry, I know this is an old post, but did you manage to get it work? I have exactly the same problem and this issue seems to still be, six years later, poorly documented.
Answer by Landern · Oct 12, 2014 at 03:20 PM
Update your applications info.plist and associate with your xml file type.
You can get the command line arguments with System.Environment.GetCommandLineArgs, i assume osx/windows standalone will pass in the full path of the argument(the file).
You may want the first scene to have an awake method/function that checks for the arguments if it has arguments, take action, otherwise load other scene(default).
Would that not associate all xml's with his program, if so that seems to me to be a bad idea, as the user might have the X$$anonymous$$L file already associated with some of editor etc. I know I would be angry if a game I played broke my X$$anonymous$$L editor link.
Wound't creating a different extension, like *.SomianGameLevel, and then associate that with his game? An X$$anonymous$$L file doesn't have to have an X$$anonymous$$L extension.
Like I stated above, i'll use my own extension and just name it .awesomeGameLevel or something :)
thanks.
That's the first part. the second is: how does my game know it's supposed to load the level right away when it launches? And how does it get the path to the level the user opened?
@$$anonymous$$pjComp the specificity was already in @Somian's original question ("custom X$$anonymous$$L file type with my own extension they can share"), so others won't get all jumpy, i've updated my answer.
An X$$anonymous$$L file doesn't have to have an X$$anonymous$$L extension.
Never said it did.
Yeah don't worry, it was they way I interpreted this bit -> "and associate with your xml file type." For some reason the word type didn't register.
Your answer
![](https://koobas.hobune.stream/wayback/20220613164937im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Refresh assets during build. 1 Answer
A node in a childnode? 1 Answer
Include a file to build - and keep it editable 0 Answers
Errors in .exe after build (maybe caused by not correct reading xml files) 0 Answers
IsolatedStorageException when creating new XmlDocument variable only on android build. 0 Answers