S&box Wiki

Revision Difference

Cloud_Assets_from_code#550134

<cat>Code.Misc</cat>⤶ <title>Cloud Assets in code</title>⤶ ⤶ # Cloud Code Assets⤶ ⤶ You might want to use an asset from Asset Party, but you need to reference it from code, rather than from another asset.. so you have no way to suck it into your project.⤶ ⤶ With the `Cloud` class you can do this.⤶ ⤶ # Example⤶ ⤶ This will set the model to the cloud pistol model. It will be available immediately.⤶ ⤶ ```⤶ pistol.Model = Cloud.Model( "facepunch.w_usp" );⤶ ```⤶ ⤶ # Under The Hood⤶ ⤶ Behind the scenes the assets are installed on the developer's computer, during code compilation. From there we inject some magic into the code so the package ident is translated to the asset path.. and then everything just works.⤶ ⤶ The assets will be shipped as part of your package. What this means is that even if the model is changed later on, it won't update until you re-publish your package.⤶ ⤶ # Ident Formats⤶ ⤶ The ident format can take any form that Package.TryParseIdent can read.⤶ ⤶ ```⤶ pistol.Model = Cloud.Model( "facepunch.w_usp" );⤶ pistol.Model = Cloud.Model( "facepunch/w_usp" );⤶ pistol.Model = Cloud.Model( "https://asset.party/facepunch/w_usp" );⤶ ```⤶ ⤶ ⤶ # Warnings⤶ ⤶ This relies on the editor being present to work, from a development point of view. If you're playing a local game in non-editor mode then it will not work.