Prefab Progress
This commit is contained in:
@ -11,14 +11,23 @@ namespace Dawn {
|
|||||||
template<class T>
|
template<class T>
|
||||||
class Prefab {
|
class Prefab {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Returns the list of assets required for this prefab.
|
||||||
|
*
|
||||||
|
* @return List of required assets this prefab.
|
||||||
|
*/
|
||||||
static std::vector<Asset*> getRequiredAssets() {
|
static std::vector<Asset*> getRequiredAssets() {
|
||||||
return T::prefabAssets();
|
return T::prefabAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
static T * create(Scene *scene) {
|
/**
|
||||||
T *item = scene->createSceneItemOfType<T>();
|
* Creates a new instance of this asset.
|
||||||
item->prefabInit();
|
*
|
||||||
return item;
|
* @param scene Scene this item belongs to.
|
||||||
|
* @return The instance of the created prefab.
|
||||||
|
*/
|
||||||
|
static T * create(Scene *scene, UICanvas *canvas) {
|
||||||
|
return T::prefabCreate(scene, canvas);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -16,12 +16,22 @@ namespace Dawn {
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static T * prefabCreate(Scene *scene, UICanvas *canvas) {
|
||||||
|
T *item = scene->createSceneItemOfType<T>();
|
||||||
|
item->prefabInit();
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
SceneItemPrefab(Scene *scene, sceneitemid_t id) :
|
SceneItemPrefab(Scene *scene, sceneitemid_t id) :
|
||||||
SceneItem(scene, id)
|
SceneItem(scene, id)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual method called by the subclass for initialization after the
|
||||||
|
* prefab has been created.
|
||||||
|
*/
|
||||||
virtual void prefabInit() = 0;
|
virtual void prefabInit() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
23
src/dawn/prefab/UIPrefab.hpp
Normal file
23
src/dawn/prefab/UIPrefab.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2023 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "Prefab.hpp"
|
||||||
|
|
||||||
|
namespace Dawn {
|
||||||
|
template<class T>
|
||||||
|
class UIPrefab :
|
||||||
|
public Prefab<T>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static T * prefabCreate(Scene *scene) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void apply(T *item) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -33,10 +33,6 @@ namespace Dawn {
|
|||||||
this->host->mesh.createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
|
this->host->mesh.createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
|
||||||
CubeMesh::buffer(&this->host->mesh, glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(1, 1, 1), 0, 0);
|
CubeMesh::buffer(&this->host->mesh, glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(1, 1, 1), 0, 0);
|
||||||
|
|
||||||
// auto param = material->getShader()->getParameterByName("u_Text");
|
|
||||||
// this->material->textureValues[param] = nullptr;
|
|
||||||
this->material->colorValues[material->getShader()->getParameterByName("u_Color")] = COLOR_RED;
|
|
||||||
|
|
||||||
std::cout << "Preab Init" << std::endl;
|
std::cout << "Preab Init" << std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user