A bidirectional converter between scml projects and klei animation files.
Please take a look at an updated version by skairunner here. It is a convenient to use standalone program with additional features like interpolating between keyframes
For the direction (klei animation files -> scml project) this tool must be used in tandem with a unity asset extractor. You will have to use the asset extractor to get the game files - specifically you are looking for the
atlas file (a single png that contains image data for an animation) and the corresponding (they have the same name)
*.build
and *.anim
file. Then this tool can convert that into an scml project.
For the direction (scml project -> klei animation files) this tool must be used in tandem with an actual full unity
install. Use version 2018 because that is the version that Oxygen not included runs on. This is because after this
tool creates the klei animation files from your scml project you will need to use unity to create an asset bundle
that contains the atlas file (*.png
file), the build file (*.build
) and the animation file (*.anim
).
The conversion from (klei animation files -> scml project) is a lossy conversion because klei animation format is more powerful than spriter (main limitation is skew transforms aren't part of spriter). But the conversion from (scml project -> klei animation file) is correct.
Both directions have been tested and confirmed to work. A more clear tutorial on how to use this tool to create asset mods for Oxygen not included will be made.
Because of limitations of the klei animation format you cannot convert all Spriter projects to klei animations. The requiremets for a Spriter project to be converted to a klei animation are listed here. If you do not exactly follow these requirements in your Spriter project it will not convert to a klei animation properly and you will be sad and I will be unable to help.
- Name all of your image files with an underscore and a number at the end. For example if you have an image
blob.png
instead name itblob_0.png
. The numbering for an individual sprite must start at 0. If you had two different versions ofblob
you would name themblob_0.png
andblob_1.png
. If you have separate sprites they each start at 0, for exampleblob_0.png
andhead_0.png
. This is required for how the tool is currently written. - You absolutely must enable snapping for your project. The klei animation format expects your keyframes to be in a specific interval. So if you do not enforce that your Spriter project snaps all keyframes to this interval it will be unable to be converted. To turn on snapping you will need to click the triple dots in the timeline panel for opening the settings and then making sure that the
Enable Snapping
option is checked. Additionally you should make all your animations at 33 ms interval to fit within the game's animation style as that is the interval used by klei's own animations for Oxygen Not Included. - You absolutely cannot utilize Spriter's feature of setting a pivot point on individual sprites on individual keyframes. What is meant by this is: klei's animation format expects every sprite to have a specific consistent pivot point across the entire animation, i.e. the pivot point of a sprite never changes in a klei animation. As such if you were to change the pivot point of a sprite in your animation (do note that this ability is supported by Spriter which is why you must be so careful to avoid doing it) you simply cannot! This is because there is no way to convert a moving pivot point in Spriter to a consistent pivot in a klei animation. It is not mathematically possible to do so. What you want to do for setting the pivot properly is to set it once for every sprite by setting it in the palette window before dragging any of the sprites into your animation.
- Below is example of modifying the pivot on an individual sprite. This is an example of what you should not do. The red box shows the pivot location after manually moving it on an individual sprite. If you do not move the pivot on the sprite manually it will be a red circle instead of the grey circle.
- Install uTinyRipper from here.
- Extract uTinyRipper from the zip file
- Run uTinyRipper from the exe file
- With uTinyRipper running open your file system and navigate to your OxygenNotIncluded_Data folder. On Windows it should be located at "C:\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncludedData". You are looking for "sharedassets0.assets", "sharedassets1.assets", and "sharedassets2.assets"
- Now you will need to drag and drop "sharedassets0.assets" onto your uTinyRipper application window.
- Now your uTinyRipper should look like this with a large export button in the middle. When you click this button it will prompt you to find a location to put the exported files in. I would recommend putting it in a new folder called "ONI-Exports" under your user's "Documents" directory.
- After uTinyRipper has exported "sharedassets0.assets" you may go ahead and export the the other two "sharedassets" files or you can leave that for later and continue with the tutorial for now. You will need to bring up that directory in which your exported the ONI game files.
- In the "Assets" folder of one of the "sharedassets" directories you will find two folders. These are "TextAsset" and "Texture2D". A Klei animation is composed of three files - 1st an image file that contains the raw picture data for the animation (this is considered a Texture2D), 2nd and 3rd are two binary files called the build and animation files (both are considered a TextAsset).
- Now we can actually bring together all the files that make up a Klei animation. For this example we will look at the Klei animation called "airconditioner". In the game, this animation is used for the building called the "Thermo Regulator". The files you will need for the "airconditioner" animation are "Texture2D/airconditioner_0.png", "TextAsset/airconditioner_build.bytes", and "TextAsset/airconditioner_anim.bytes".
- All of the files for the "airconditioner" animation together looks like this.
- Now download the jar version of K-Parser from the releases section of this github repository. Click here to download it. Put the jar somewhere useful. I recommend putting it near your folder containing the animation files.
- For this next step you will need to be using at least java 9. Run the jar file with the animation files as the parameters to create the scml file. Note the order of the parameters. They must be in this order: image, build, anim.
- Now you will have the "scml" project file contained inside the new "scml" directory. Additional the original texture file will have been split into its component pieces.
- Next open the scml file in Spriter. You can now examine and edit the Klei animation as a spriter project.
- Assuming you have K-Parser installed already (if not see step 11 of the scml extraction section of this tutorial) it is simple to run the compiler on the single scml file.
- Now you will have created your three Klei animation files in the same directory as the scml project.
- The final step before you can use this new animation you have created in an ONI mod is to copy these three Klei animation files to the "anim/assets" folder of your mod. All animations in that folder will automatically be loaded as Klei animations in ONI that are. All animations have
_kanim
appended to the end of them when referenced in your mod code. For example if you copied your three Klei animation files to a directory called "anim/assets/mysupercoolanimation" then in game you will refer to that as "mysupercoolanimation_kanim".