sbox-issues icon indicating copy to clipboard operation
sbox-issues copied to clipboard

Cloud.Asset<T>

Open badandbest opened this issue 1 year ago • 0 comments

For?

S&Box

What can't you do?

Cloud.Material and Cloud.Model are very convenient but not always what I want. Previously I asked for Cloud.Texture https://github.com/Facepunch/sbox-issues/issues/5420, but that was before every possible asset type became publishable.

So I tried to make my own cloud asset shorthand but I expectedly ran into the problem of Cloud.Asset only allowing string literals.

How would you like it to work?

  • Cloud.Asset<T> could be very powerful, but a lot of assets need to be converted to be useful (e.g PrefabFile into PrefabScene).
  • A way to make our own methods like Cloud.Prefab. Potentially make Cloud.CloudAssetProviderAttribute public?

What have you tried?

public static class CloudExtensions
{
	public static PrefabScene Prefab( [StringLiteralOnly] string ident )
	{
		var path = Cloud.Asset( ident );
		var file = ResourceLibrary.Get<PrefabFile>( path );
		
		return SceneUtility.GetPrefabScene( file );
	}
}

image

Additional context

No response

badandbest avatar Aug 16 '24 13:08 badandbest