23 virtual auto get_asset_uuid(
const hpp::uuid& uid)
const -> hpp::uuid = 0;
24 virtual auto get_asset_uuid(
const std::string& key)
const -> hpp::uuid = 0;
28struct dotnet_asset_impl : dotnet_asset
30 auto get_asset_uuid(
const hpp::uuid& uid)
const -> hpp::uuid
override
33 auto& am = ctx.get_cached<asset_manager>();
35 auto asset = am.get_asset<T>(uid);
39 auto get_asset_uuid(
const std::string& key)
const -> hpp::uuid
override
42 auto& am = ctx.get_cached<asset_manager>();
44 auto asset = am.get_asset<T>(
key);
49auto get_dotnet_asset(
size_t type_hash) ->
const dotnet_asset*
52 static std::map<size_t, std::shared_ptr<dotnet_asset>> reg =
54 {dotnet::type::get_hash(
"Unravel.Core.Texture"), std::make_shared<dotnet_asset_impl<gfx::texture>>()},
55 {dotnet::type::get_hash(
"Unravel.Core.Material"), std::make_shared<dotnet_asset_impl<material>>()},
56 {dotnet::type::get_hash(
"Unravel.Core.Mesh"), std::make_shared<dotnet_asset_impl<mesh>>()},
57 {dotnet::type::get_hash(
"Unravel.Core.AnimationClip"), std::make_shared<dotnet_asset_impl<animation_clip>>()},
58 {dotnet::type::get_hash(
"Unravel.Core.Prefab"), std::make_shared<dotnet_asset_impl<prefab>>()},
59 {dotnet::type::get_hash(
"Unravel.Core.Scene"), std::make_shared<dotnet_asset_impl<scene_prefab>>()},
60 {dotnet::type::get_hash(
"Unravel.Core.PhysicsMaterial"), std::make_shared<dotnet_asset_impl<physics_material>>()},
61 {dotnet::type::get_hash(
"Unravel.Core.AudioClip"), std::make_shared<dotnet_asset_impl<audio_clip>>()},
62 {dotnet::type::get_hash(
"Unravel.Core.Font"), std::make_shared<dotnet_asset_impl<font>>()}
66 auto it = reg.find(type_hash);
69 return it->second.get();
71 static const dotnet_asset* empty{};
75auto internal_m2n_get_asset_by_uuid(
const hpp::uuid& uid,
const dotnet::type&
type) -> hpp::uuid
77 if(
auto asset = get_dotnet_asset(
type.get_hash()))
79 return asset->get_asset_uuid(uid);
85auto internal_m2n_get_asset_by_key(
const std::string& key,
const dotnet::type&
type) -> hpp::uuid
87 if(
auto asset = get_dotnet_asset(
type.get_hash()))
89 return asset->get_asset_uuid(key);
97 using converter = dotnet::managed_interface::converter;
100 auto& am = ctx.get_cached<asset_manager>();
103 auto asset = am.get_asset<
material>(uid);
113auto internal_m2n_audio_clip_get_length(
const hpp::uuid& uid) ->
float
116 auto& am = ctx.get_cached<asset_manager>();
118 auto asset = am.get_asset<audio_clip>(uid);
122 if(
auto clip = asset.get())
124 float secs = clip->get_info().duration.count();
132auto internal_m2n_animation_clip_get_length(
const hpp::uuid& uid) ->
float
135 auto& am = ctx.get_cached<asset_manager>();
137 auto asset = am.get_asset<animation_clip>(uid);
141 if(
auto clip = asset.get())
143 return clip->duration.count();
150auto internal_m2n_animation_clip_get_name(
const hpp::uuid& uid) -> std::string
153 auto& am = ctx.get_cached<asset_manager>();
155 auto asset = am.get_asset<animation_clip>(uid);
159 if(
auto clip = asset.get())
174 auto reg = dotnet::internal_call_registry(
"Unravel.Core.Assets");
175 reg.add_internal_call(
"internal_m2n_get_asset_by_uuid", dotnet_internal_call(internal_m2n_get_asset_by_uuid));
176 reg.add_internal_call(
"internal_m2n_get_asset_by_key", dotnet_internal_call(internal_m2n_get_asset_by_key));
177 reg.add_internal_call(
"internal_m2n_get_material_properties",
178 dotnet_internal_call(internal_m2n_get_material_properties));
182 auto reg = dotnet::internal_call_registry(
"Unravel.Core.AudioClip");
183 reg.add_internal_call(
"internal_m2n_audio_clip_get_length", dotnet_internal_call(internal_m2n_audio_clip_get_length));
187 auto reg = dotnet::internal_call_registry(
"Unravel.Core.AnimationClip");
188 reg.add_internal_call(
"internal_m2n_animation_clip_get_length", dotnet_internal_call(internal_m2n_animation_clip_get_length));
189 reg.add_internal_call(
"internal_m2n_animation_clip_get_name", dotnet_internal_call(internal_m2n_animation_clip_get_name));
#define APPLOG_TRACE(...)
void register_assets_script_bindings()
auto get_material_properties(const material::sptr &material) -> dotnetpp_backend::managed_interface::material_properties
static auto context() -> rtti::context &