-
Notifications
You must be signed in to change notification settings - Fork 16
/
__init__.py
82 lines (60 loc) · 2.44 KB
/
__init__.py
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
71
72
73
74
75
76
77
78
79
80
81
82
from . import (behavior_graph, components, ui)
from bpy.app.handlers import persistent
import bpy
from bpy.types import PropertyGroup
from bpy.props import IntVectorProperty, PointerProperty
bl_info = {
"name": "Behavior Graph Editor",
"blender": (3, 2, 0),
"category": "Node",
"author": "netpro2k, keianhzo",
"version": (0, 0, 2),
"location": "Node Editor > Sidebar > Behavior Graph",
"description": "Create and export GLTF KHR_behavior graphs using Blender's node group editor"
}
glTF2ExportUserExtension = behavior_graph.glTF2ExportUserExtension
glTF2_pre_export_callback = behavior_graph.glTF2_pre_export_callback
glTF2_post_export_callback = behavior_graph.glTF2_post_export_callback
class BGGlobalProps(PropertyGroup):
version: IntVectorProperty(name="version",
description="The BGs add-on version last used by this file",
default=(0, 0, 0),
size=3)
@persistent
def load_post(dummy):
from .migrations import migrate
migrate()
@persistent
def save_post(dummy):
for scene in bpy.data.scenes:
scene.bg_global_props.version = bl_info["version"]
for object in bpy.data.objects:
object.bg_global_props.version = bl_info["version"]
for node_tree in bpy.data.node_groups:
node_tree.bg_global_props.version = bl_info["version"]
def register():
components.register()
ui.register()
behavior_graph.register()
bpy.utils.register_class(BGGlobalProps)
bpy.types.Scene.bg_global_props = PointerProperty(type=BGGlobalProps)
bpy.types.Object.bg_global_props = PointerProperty(type=BGGlobalProps)
bpy.types.NodeTree.bg_global_props = PointerProperty(type=BGGlobalProps)
if load_post not in bpy.app.handlers.load_post:
bpy.app.handlers.load_post.append(load_post)
if load_post not in bpy.app.handlers.save_post:
bpy.app.handlers.save_post.append(save_post)
def unregister():
behavior_graph.unregister()
ui.unregister()
components.unregister()
bpy.utils.unregister_class(BGGlobalProps)
del bpy.types.Scene.bg_global_props
del bpy.types.Object.bg_global_props
del bpy.types.NodeTree.bg_global_props
if load_post in bpy.app.handlers.load_post:
bpy.app.handlers.load_post.remove(load_post)
if load_post in bpy.app.handlers.save_post:
bpy.app.handlers.save_post.remove(save_post)
if __name__ == "__main__":
register()