2017-04-08 20:05:35 +02:00
|
|
|
import bpy
|
|
|
|
from bpy.props import *
|
|
|
|
from bpy.types import Node, NodeSocket
|
|
|
|
from arm.logicnode.arm_nodes import *
|
2018-07-10 21:09:27 +02:00
|
|
|
import arm.utils
|
2017-04-08 20:05:35 +02:00
|
|
|
|
|
|
|
class MaterialNode(Node, ArmLogicTreeNode):
|
|
|
|
'''Material node'''
|
|
|
|
bl_idname = 'LNMaterialNode'
|
|
|
|
bl_label = 'Material'
|
|
|
|
bl_icon = 'GAME'
|
|
|
|
|
2018-07-10 21:09:27 +02:00
|
|
|
@property
|
|
|
|
def property0_get(self):
|
|
|
|
if self.property0 not in bpy.data.materials:
|
|
|
|
return self.property0
|
|
|
|
return arm.utils.asset_name(bpy.data.materials[self.property0])
|
|
|
|
|
2017-04-08 20:05:35 +02:00
|
|
|
property0 = StringProperty(name='', default='')
|
|
|
|
|
|
|
|
def init(self, context):
|
|
|
|
self.outputs.new('NodeSocketShader', 'Material')
|
|
|
|
|
|
|
|
def draw_buttons(self, context, layout):
|
|
|
|
layout.prop_search(self, 'property0', bpy.data, 'materials', icon='NONE', text='')
|
|
|
|
|
2017-04-10 21:17:17 +02:00
|
|
|
add_node(MaterialNode, category='Variable')
|