2017-04-08 20:05:35 +02:00
|
|
|
import bpy
|
2020-09-08 23:21:41 +02:00
|
|
|
|
2018-07-10 21:09:27 +02:00
|
|
|
import arm.utils
|
2020-09-08 23:21:41 +02:00
|
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
|
2017-04-08 20:05:35 +02:00
|
|
|
|
2020-09-08 21:16:20 +02:00
|
|
|
class MaterialNode(ArmLogicTreeNode):
|
2020-09-08 23:14:51 +02:00
|
|
|
"""Material node"""
|
2017-04-08 20:05:35 +02:00
|
|
|
bl_idname = 'LNMaterialNode'
|
|
|
|
bl_label = 'Material'
|
2020-08-07 19:07:51 +02:00
|
|
|
bl_icon = 'NONE'
|
2017-04-08 20:05:35 +02:00
|
|
|
|
2018-07-10 21:09:27 +02:00
|
|
|
@property
|
|
|
|
def property0_get(self):
|
2019-02-08 12:50:12 +01:00
|
|
|
if self.property0 == None:
|
|
|
|
return ''
|
|
|
|
if self.property0.name not in bpy.data.materials:
|
|
|
|
return self.property0.name
|
|
|
|
return arm.utils.asset_name(bpy.data.materials[self.property0.name])
|
2020-09-08 17:03:24 +02:00
|
|
|
|
2019-02-08 12:50:12 +01:00
|
|
|
property0: PointerProperty(name='', type=bpy.types.Material)
|
2020-09-08 17:03:24 +02:00
|
|
|
|
2017-04-08 20:05:35 +02:00
|
|
|
def init(self, context):
|
2020-09-08 22:08:29 +02:00
|
|
|
self.add_output('NodeSocketShader', 'Material', is_var=True)
|
2017-04-08 20:05:35 +02:00
|
|
|
|
|
|
|
def draw_buttons(self, context, layout):
|
|
|
|
layout.prop_search(self, 'property0', bpy.data, 'materials', icon='NONE', text='')
|
|
|
|
|
2020-09-08 17:03:24 +02:00
|
|
|
add_node(MaterialNode, category=MODULE_AS_CATEGORY)
|