Imposible to create custom Resource via register_component_with_descriptor
Author: lain-donoCreated Sep 9, 2026Updated Sep 17, 2026
LabelsC-BugA-ECSS-Ready-For-ImplementationX-UncontroversialD-Straightforward
Bevy version and features
0.19.x, 0.20.0-rc.1
What you did
I'm trying to create a resource manually using register_component_with_descriptor.
What went wrong
Starting with version 0.19, resources have become components. They require the IsResource component.
There is no way to add the required components to custom components. Consequently, it is not possible to create custom resources.
Additional information
Related to #19731
Steps to reproduce:
use bevy_ecs::change_detection::MaybeLocation;
use bevy_ecs::component::{ComponentCloneBehavior, ComponentDescriptor, StorageType};
use bevy_ecs::prelude::*;
use bevy_ptr::OwningPtr;
use std::alloc::Layout;
struct MyResource;
let mut world = World::new();
let resource_component_id = world.register_component_with_descriptor(unsafe {
ComponentDescriptor::new_with_layout(
"MyResource",
StorageType::Table,
Layout::new::<MyResource>(),
None,
true,
// false, // for 0.20.0-rc.1
ComponentCloneBehavior::Default,
None,
)
});
let caller = MaybeLocation::caller();
OwningPtr::make(MyResource, |value| unsafe {
world.insert_resource_by_id(resource_component_id, value, caller)
});
let option_ptr = world.get_resource_by_id(resource_component_id);
assert!(option_ptr.is_some()); // You cannot obtain a resource for which there is no IsResource.
Source: bevyengine/bevy