Godot_bridge/addon/icons/__init__.py

29 lines
782 B
Python
Raw Normal View History

import bpy
import os
icons_collection = None
icons_directory = os.path.dirname(__file__)
def initialize_icons_collection():
import bpy.utils.previews
global icons_collection
print("icons_collection : {}".format(icons_collection))
icons_collection = bpy.utils.previews.new()
def unload_icons():
bpy.utils.previews.remove(icons_collection)
def get_icon_id(identifier):
# The initialize_icons_collection function needs to be called first.
return get_icon(identifier).icon_id
def get_icon(identifier):
if identifier in icons_collection:
return icons_collection[identifier]
return icons_collection.load(identifier, os.path.join(icons_directory, identifier + ".png"), "IMAGE")
def register_icons():
initialize_icons_collection()
def unregister_icons():
unload_icons()