UI Hello World
This commit is contained in:
@ -71,6 +71,42 @@ namespace Dawn {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a (direct) child of this component that has a matching component.
|
||||
*
|
||||
* @tparam T Component to find child of.
|
||||
* @return Pointer to the child, or nullptr if not found.
|
||||
*/
|
||||
template<class T>
|
||||
std::shared_ptr<T> findChild() {
|
||||
auto it = this->transform.children.begin();
|
||||
while(it != this->transform.children.end()) {
|
||||
auto child = (*it)->item.getComponent<T>();
|
||||
if(child != nullptr) return child;
|
||||
++it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all (direct) children of this component that match the queried
|
||||
* component.
|
||||
*
|
||||
* @tparam T Component to find children for.
|
||||
* @return Array of pointers to matching children.
|
||||
*/
|
||||
template<class T>
|
||||
std::vector<std::shared_ptr<T>> findChildren() {
|
||||
auto it = this->transform.children.begin();
|
||||
std::vector<std::shared_ptr<T>> children;
|
||||
while(it != this->transform.children.end()) {
|
||||
auto child = (*it)->item.getComponent<T>();
|
||||
if(child != nullptr) children.push_back(child);
|
||||
++it;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this SceneItem.
|
||||
|
Reference in New Issue
Block a user