-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_Plugin.cpp
More file actions
58 lines (48 loc) · 1.65 KB
/
_Plugin.cpp
File metadata and controls
58 lines (48 loc) · 1.65 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
#include "_Plugin.h"
#include "EntityManager.h"
#include "EntityReference.h"
#include <Urho3D/Plugins/PluginApplication.h>
#include <Urho3D/SystemUI/SerializableInspectorWidget.h>
using namespace Urho3D;
namespace
{
void RegisterPluginObjects(PluginApplication& plugin)
{
plugin.RegisterObject<EntityManager>();
plugin.RegisterObject<EntityReference>();
SerializableInspectorWidget::RegisterAttributeHook<EntityManager>("Placeholder",
[](const AttributeHookContext& ctx, Variant& boxedValue)
{
if (ctx.objects_->size() == 1)
{
const auto entityManager = dynamic_cast<EntityManager*>(ctx.objects_->front().Get());
if (entityManager->RenderManagerInspector())
{
boxedValue = true;
return true;
}
}
return false;
});
SerializableInspectorWidget::RegisterAttributeHook<EntityReference>("Placeholder",
[](const AttributeHookContext& ctx, Variant& boxedValue)
{
if (ctx.objects_->size() == 1)
{
const auto entityReference = dynamic_cast<EntityReference*>(ctx.objects_->front().Get());
if (entityReference->RenderInspector())
{
boxedValue = true;
return true;
}
}
return false;
});
}
void UnregisterPluginObjects(PluginApplication& plugin)
{
SerializableInspectorWidget::UnregisterAttributeHook<EntityManager>("Placeholder");
SerializableInspectorWidget::UnregisterAttributeHook<EntityReference>("Placeholder");
}
} // namespace
URHO3D_DEFINE_PLUGIN_MAIN_SIMPLE(RegisterPluginObjects, UnregisterPluginObjects);