edited August 29 in Makinom Support

I purchased your product earlier this week and am wondering if you can help me on how to generate the combatant .asset file programmatically

I attempted this through script but I could not find a way to simulate the same actions that occur when the CombatantsTab class performs a Add/Copy (i believe this is GenericAssetListTab.CopyData()) - is GamingIsLove.Makinom.Editor even accessible from code?

I also tried to just work with the .asset files directly looking at their file data - i tried incrementing the ID in the m_Name field and generating a random guid in m_script but that does not work. I presume the file also stores some sort of bytearray which i presume is the values set inside the makinom combatent ui

Any advice to do this via script would be appreciated. My pipeline for creating assets will be originating in XML so deserializing and mapping to called editor functions would be the preferred method

Post edited by mixxit on
  • edited August 29
    i have found the Game -> Game Settings -> Data Settings which might help solve my problem if i can block create the objects and then set the data via xml
    Post edited by mixxit on
  • The used data format doesn't have an impact on this, so you can use byte array or xml.

    Combatant assets are just Unity assets, i.e. they're created like any Unity asset:
    CombatantAsset asset = ScriptableObject.CreateInstance<CombatantAsset>();
    You still need to actually save the asset via the AssetDatabase in Unity, though. If you don't know anything about it, I'd recommend to learn this via Unity's documentation - you shouldn't really mess around with this unless you know what you're doing :D

    Anyway, once you have the asset, you can access the settings via asset.Settings - you can change any of the settings of the combatant here. However, settings are pretty complex and if they're not viewed by the editor, some things might need to be initialized manually.

    After changing settings, you need to serialize those changes:
    asset.SaveData(null, encrypt, DataFile.SaveFormatType.ByteArray);
    encrypt defines if the data should be encrypted, so either pass on true or false. You can also use the XMLString data format.

    After saving, you also need to set the asset dirty and save the asset database changes again.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you so much!
Sign In or Register to comment.