-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestComponent.cpp
More file actions
70 lines (61 loc) · 1.45 KB
/
Copy pathTestComponent.cpp
File metadata and controls
70 lines (61 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "Component/TestComponent.h"
#include "Game/World.h"
#include "Game/Input.h"
#include "Game/GameObject.h"
#include "Game/Component/Render/MeshRenderer.h"
#include "Render/Mesh.h"
#include <random>
namespace sh::game
{
Test::Test(GameObject& owner) :
Component(owner)
{
}
SH_GAME_API void Test::Awake()
{
SH_INFO("Awake!");
}
SH_GAME_API void Test::Start()
{
SH_INFO("Start!");
}
SH_GAME_API void Test::OnEnable()
{
SH_INFO_FORMAT("Enable! {}", gameObject.GetName().ToString());
}
SH_GAME_API void Test::OnDisable()
{
SH_INFO_FORMAT("Disable... {}", gameObject.GetName().ToString());
}
SH_GAME_API void Test::OnTriggerEnter(Collider& other)
{
SH_INFO("enter!");
}
SH_GAME_API void Test::OnTriggerStay(Collider& other)
{
//SH_INFO("stay!");
}
SH_GAME_API void Test::OnTriggerExit(Collider& other)
{
SH_INFO("exit!");
}
SH_GAME_API void Test::Update()
{
if (Input::GetKeyPressed(Input::KeyCode::Space))
{
for (int i = 0; i < num; ++i)
{
auto obj = world.AddGameObject("test");
auto meshr = obj->AddComponent<MeshRenderer>();
auto modelPtr = static_cast<render::Model*>(core::SObjectManager::GetInstance()->GetSObject(core::UUID{ "bbc4ef7ec45dce223297a224f8093f15" }));
meshr->SetMesh(modelPtr->GetMeshes()[0]);
}
}
if (Input::GetKeyPressed(Input::KeyCode::K))
{
SH_INFO("Change constant");
bUseTexture = !bUseTexture;
mat->SetConstant("USE_TEXTURE", bUseTexture);
}
}
}//namespace