Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engine/includes/components/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ENGINE_EXPORT Actor : public Object {
~Actor();

Transform *transform();
void setTransform(Transform *transform);

Scene *scene() const;

Expand Down
8 changes: 7 additions & 1 deletion engine/src/components/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,16 @@ void Actor::setLayers(const int layers) {
Transform *Actor::transform() {
PROFILE_FUNCTION();
if(m_transform == nullptr) {
m_transform = static_cast<Transform *>(component(gTransform));
setTransform(static_cast<Transform *>(component(gTransform)));
}
return m_transform;
}
/*!
Replaces an existant \a transform with new one.
*/
void Actor::setTransform(Transform *transform) {
m_transform = transform;
}
/*!
Returns the scene where actor attached to.
*/
Expand Down
14 changes: 13 additions & 1 deletion modules/uikit/src/components/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,19 @@ void Widget::actorParentChanged() {
Internal method to compose the widget component, creating and setting the RectTransform.
*/
void Widget::composeComponent() {
setRectTransform(Engine::objectCreate<RectTransform>("RectTransform", actor()));
Actor *a = actor();

if(a) {
Transform *transform = a->transform();
if(transform) {
delete transform;
}

RectTransform *rect = Engine::objectCreate<RectTransform>("RectTransform", a);
a->setTransform(rect);

setRectTransform(rect);
}
}
/*!
\internal
Expand Down