Results 1 to 12 of 12

Thread: Vanilla Asset Bundle Loading Hooks

  1. #1
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,646
    Rep Power
    1

    Vanilla Asset Bundle Loading Hooks

    Alpha 17e has introduced native support in loading Unity's unity3d asset bundles. What this means to us, is that we can load in custom blocks and entities, as well as adding new sounds into the game, without using SDX.

    ** Note: Any modlets that use Asset Bundles must be installed on the Client and the Server **

    This is going to be a short tutorial just to get you started by showing you which hooks we have available to us. It's not meant to be a full tutorial on how to use unity.

    All of the hooks below use the following syntax:
    Code:
    #@modfolder:<ModSubFolder>/<Unity3DFile>?<UnityPrefabName>
    
    # 			is the hook that makes the code going down a different path to load.
    @modfolder:     	At run time, this gets resolved to Mods/MyMod/ path where the Unity3D file is found.
    <ModSubFolder> 		This is a subfolder in your MyMod folder, that will hold the resources. Typically it's called "Resources".
    <Unity3DFile>		This is the full unity3d file name, including extension, of your unity asset bundle.
    ?			Is a hook to tell the game to load the follow as a prefab
    <UnityPrefabName>	This is your unity prefab name.
    Example:

    I have a sound file called myBatteryBankSound, stored in the mysound.unity3d asset bundle. My Mod is called SphereII_Tutorial. It only contains an xpath to change the sound ClipName.
    Code:
    	
    Mods/SphereII_Tutorial/Config/sounds.xml
    Mods/SphereII_Tutorial/Resources/mysound.unity3d
    Mods/ModInfo.xml
    
    sounds.xml:
    	<configs>
    		<set xpath="/Sounds/SoundDataNode[@name='batterybank_idle']/AudioClip/@ClipName">#@modfolder:Resources/mysound.unity3d?myBatteryBankSound</set>
    	</configs>
    @modfolder: is updated at run time and replaced as Mods/SphereII_Tutorial/

    In the exported configs, you'd see

    <AudioClip ClipName="#@modfolder(SphereII_Tutorial):Resources/mysound.unity3d?myBatteryBankSound" Loop="true"/>

    he type of prefab and asset you make depends on the context in what you'll want to use it in. For example, in the above example, myBatteryBankSound must be a supported sound file, otherwise the game will not load it. Likewise, if you try to load up a Model on the block, it has to be a block prefab in Unity.

    Unity 2018.2.18
    For Alpha 17e, Unity 2018.2.0f is used by the game. You must use a unity version that matches that, although the last digit is less important. For example, you could probably use 2018.2.18.

    https://unity3d.com/get-unity/downlo...493.1525198827

    Export Asset Bundles:
    The ExportAssetBundles.ca has been hosted here: https://github.com/7D2D/Templates-and-Utilities

    In Unity, drag and drop the exportassetbundles.cs into Assets window. It'll compile and add itself to the right click, context menu.

    Tutorials
    The following tutorials are still mostly valid for creating unity blocks and entities. We'll be working on newer tutorials. The biggest difference is that the version of Unity that we are using is much newer, but the workflow should be the same.

    https://www.youtube.com/watch?v=pxzD...wYlryZBBbVT1fE

    https://7d2dsdx.github.io/Tutorials/

    The following post will include all currently known modfolder hooks.
    Last edited by sphereii; 11-30-2018 at 04:11 PM.

  2. #2
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,646
    Rep Power
    1
    The following hooks are known to exist, even if we do not yet know what kind of unity prefab they'll will take.

    AudioClips:
    ClipName
    AudioSourceName

    Items:
    DropMeshFile
    HandMeshFile
    Meshfile
    LightSource

    ItemActionZoom:
    Zoom_overlay

    EntityClasses:
    Mesh
    AddFurToMaterial
    Prefab
    MeshFP
    Model-Damage-*
    ParticleOnSpawn
    ReplaceMaterial[0-5]

    UMA Animal EntityClasses:
    Colliders

    Player and SupplyCrate EntityClasses:
    SkinTexture

    Blocks of "New" or "ModelEntity" shape:
    Model

    Biome/Weather particle effect:
    prefab

    MinEventActionAttachPrefabToHeldItem:
    prefab

    MinEventActionAttachParticleEffectToEntity:
    particle

  3. #3
    Zombie Hunter
    Join Date
    Sep 2014
    Posts
    453
    Rep Power
    1

    Colliders and activation text on multi blocks

    Here's a little info on how to get the colliders and activation text working correctly on blocks that are bigger than 1x1x1

    The first thing you will need is a blank MonoBehaviour script called RootTransformRefParent.cs see the bottom of this post for a example.

    Now add a tag to your unity project in tag number 4 called T_Block This MUST be in tag number 4!

    Select all the meshes that have colliders, tag them with the T_Block tag and add the RootTransformRefParent.cs script to them all.

    Now select the Prefab (root object) and tag it with T_Block as well, but don't add the script this time. Don't tag any of the other empty GameObject.



    Export it like normal and all your colliders and activation text should be working.

    Don't forget to add the required xml properties
    Code:
    <property name="DisplayType" value="blockMulti" />
    	<property name="MultiBlockDim" value="4,1,6"/>

    RootTransformRefParent.cs should look like this:
    Code:
    using UnityEngine;
    using System.Collections;
    
    public class RootTransformRefParent : MonoBehaviour {
    
    	void Start () {
    	
    	}
    	
    	void Update () {
    	
    	}
    }

  4. #4
    Hunter Russiandood's Avatar
    Join Date
    May 2018
    Posts
    106
    Rep Power
    0
    You sir, are amazing! Can this be stickied?!

  5. #5
    Guppycurian Forum Whore Guppycur's Avatar
    Join Date
    Apr 2014
    Location
    Enemy for life
    Posts
    20,975
    Rep Power
    1
    Yes, please sticky. Or just make Sphereii or Xyth a moderator.

  6. #6
    Community Moderator Crater Creator's Avatar
    Join Date
    Apr 2016
    Posts
    3,818
    Rep Power
    1
    Can do, but let's put tutorials in the tutorials section.

  7. #7
    Guppycurian Forum Whore Guppycur's Avatar
    Join Date
    Apr 2014
    Location
    Enemy for life
    Posts
    20,975
    Rep Power
    1
    Where it will go to die...

    This is a resource, not a tutorial.

  8. #8
    Colony Founder n2n1's Avatar
    Join Date
    Oct 2015
    Location
    MotherRussia
    Posts
    1,974
    Rep Power
    1
    I'll just come to everything ready!
    Thanks!

  9. #9
    Colony Founder TSBX's Avatar
    Join Date
    Nov 2014
    Location
    "Welcome to Costco, I love you."
    Posts
    2,055
    Rep Power
    1
    Mods killed n2n1. Never forget.

  10. #10
    Colony Founder n2n1's Avatar
    Join Date
    Oct 2015
    Location
    MotherRussia
    Posts
    1,974
    Rep Power
    1
    If I do not use it through the Xpatch, and make changes directly to the original configs - it does not work.

    Or i do need a different syntax? (the same resources work if the blocks are written through a Xpatch)


    (I use to check the modlet from Xyth)
    if i use this line directly in the original block.xml:
    <property name="Model" value="#@modfolder:Resources/PinupPosters.unity3d?PinupPoster01Prefab" />
    I get an error in the console:
    2018-12-02T20:58:01 11.906 INF StartAsServer
    Unable to open archive file: C:/Program Files (x86)/Steam/steamapps/common/7 Days To Die MOD/7DaysToDie_Data/../Data/Bundles/@modfolder:Resources/PinupPosters.unity3d

    (Filename: Line: 586)

    2018-12-02T20:58:04 14.914 ERR Loading AssetBundle "C:/Program Files (x86)/Steam/steamapps/common/7 Days To Die MOD/7DaysToDie_Data/../Data/Bundles/@modfolder:Resources/PinupPosters.unity3d" failed!
    2018-12-02T20:58:04 14.914 ERR Model '#@modfolder:Resources/PinupPosters.unity3d?PinupPoster01Prefab' not found on block with name zombiePinup01
    2018-12-02T20:58:04 14.914 ERR XML loader: Loading and parsing 'blocks.xml' failed
    2018-12-02T20:58:04 14.915 EXC Model '#@modfolder:Resources/PinupPosters.unity3d?PinupPoster01Prefab' not found on block with name zombiePinup01
    Exception: Model '#@modfolder:Resources/PinupPosters.unity3d?PinupPoster01Prefab' not found on block with name zombiePinup01
    at BlockShapeModelEntity.Init (.Block _block) [0x00000] in <filename unknown>:0
    at BlocksFromXml.CreateBlocks (.XmlFile _xmlFile, Boolean _fillLookupTable) [0x00000] in <filename unknown>:0
    at BlocksFromXml.CreateBlocks (.XmlFile _xmlFile) [0x00000] in <filename unknown>:0
    at WorldStaticData.LoadBlocks (.XmlFile _xmlFile) [0x00000] in <filename unknown>:0
    at WorldStaticData+<loadSingleXml>c__Iterator1.MoveNe xt () [0x00000] in <filename unknown>:0
    UnityEngine.DebugLogHandler:Internal_LogException( Exception, Object)
    UnityEngine.DebugLogHandler:LogException(Exception , Object)
    UnityEngine.Logger:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    Logger:masterLogException(Exception)
    Logger:Exception(Exception)
    Log:Exception(Exception)
    <loadSingleXml>c__Iterator1:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumera tor, IntPtr)
    Last edited by n2n1; 12-02-2018 at 06:01 PM.

  11. #11
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,646
    Rep Power
    1
    Quote Originally Posted by n2n1 View Post
    If I do not use it through the Xpatch, and make changes directly to the original configs - it does not work.

    Or i do need a different syntax? (the same resources work if the blocks are written through a Xpatch)


    (I use to check the modlet from Xyth)
    if i use this line directly in the original block.xml:
    <property name="Model" value="#@modfolder:Resources/PinupPosters.unity3d?PinupPoster01Prefab" />
    I get an error in the console:
    If you do not use the xpath hooks, you'll have to place your unity bundle under Data/Bundles, and just reference the last part:

    value="#pinupPosters.unity3d?PinupPoster01Prefab" />

  12. #12
    Colony Founder n2n1's Avatar
    Join Date
    Oct 2015
    Location
    MotherRussia
    Posts
    1,974
    Rep Power
    1
    Quote Originally Posted by sphereii View Post
    If you do not use the xpath hooks, you'll have to place your unity bundle under Data/Bundles, and just reference the last part:

    value="#pinupPosters.unity3d?PinupPoster01Prefab" />
    Yes it solved the problem!
    Thanks so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •