Jump to content

Custom graphics


Recommended Posts

Looking at the mod loading code, I think I figured out how to add custom graphics with mods.

The game looks for a folder called "anims" inside the mod folder (next to the modded DLL file). It assumes each file there to be graphics and tries to load it. (KMod.Mod.LoadAnimation)

For each file, it should contain two TextAssets, where the names end with _build and _anim. It can also contain any number of Texture2D (no restrictions on texture names). When used ingame, apparently the string you need to use is the filename. There is no obvious limit to how many asset files a mod can contain.

This sounds simple enough, except for the fact that I have no idea how to create such asset files. We need somebody with more unity asset knowledge than me to make a test to confirm precisely how this work.

Also it seems we would have problems if two mods decide to use the same filename. We should set up a naming convention to avoid that. I already do that with PrefabIDs where I start each ID with my name. I assume nobody else will do that, hence no nameclashes. Unlike PrefabID, it would appear that the name of anims aren't in savegames, meaning fixing a nameclash will not break savegames.

Link to comment
Share on other sites

Yeah unfortunately it's a bit more complicated to actually get it working as it is now. The build and anim files are just the klei animation file format stuff that is the same as for the other games (like don't starve) so converting between that and a more workable format (i.e. Spriter) already is doable. The file that their new mod loading utility tries to load is actually a Unity asset bundle rather than directly loading the files from disk so you would have to bundle those files together before you can actually use it. I've been messing around with it this evening but have been having trouble making a valid asset bundle. I'm thinking I'm using the wrong version of Unity to make the bundle so the game keeps erroring when trying to parse it.

This is the specific error I'm getting: ```The AssetBundle 'C:\Users\Davis\Documents\Klei\OxygenNotIncluded\mods\Local\magmafern\anims\magmafern' can't be loaded because it was not built with the right version or build target.
UnityEngine.AssetBundle:LoadFromFile_Internal(String, UInt32, UInt64)
UnityEngine.AssetBundle:LoadFromFile(String)
KMod.Mod:LoadAnimation() (at D:\JenkinsWorkspace\Preview_Simgame_Windows\game\Assets\scripts\Mods\Mods.cs:382)```

In terms of your question about creating those files, I wrote this tool (https://github.com/daviscook477/kparser) a few months ago to read and write the klei build and anim file format based off of the dont starve modding tools and some other member's work in this community. I just checked it again tonight and was able to get it working to generate a spriter project from the klei files. So if the Unity side of things worked it might now be actually possible to create those custom animations.

okay looks like I spoke too soon. Attached is an example of using a custom texture in game. I haven't tried modifying the anim or build files yet. But I was able to extra the sleet wheat texture, build, and anim file using a unity asset extractor. Then I went into gimp and did some color modifications to the texture. And finally I used Unity 2017.1.5f1 Personal edition to bundle the texture, build and anim file into a Unity assetbundle which the game was able to load and then use as a kanim string.

custom_anim.png

Link to comment
Share on other sites

4 hours ago, test447 said:

And finally I used Unity 2017.1.5f1 Personal edition to bundle the texture, build and anim file into a Unity assetbundle which the game was able to load and then use as a kanim string.

That's awesome. Would you please write a step by step guide on how to do it because I still have no idea how to make an assetbundle even after reading what you wrote. If we are to get mods to use custom graphics, then ideally we should end up with a step by step guide to extract existing graphics (AssetStudio has worked for me so far), get a png file and then move that png into a kanim in the mod.

Writing a request for a howto for modding made me write about the need for a modding wiki. It has been mentioned before, but nothing serious has happened so far.

 

Link to comment
Share on other sites

Yeah I'll make a write up later today. Right now I'm trying to investigate if there's any way to use the dont starve modding tools to compile a custom scml file into a build and anim. Because right now all this allows you to do is modify textures but reuse the actual animation on those textures.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...