armory/blender/arm/logicnode/material/LN_material.py

29 lines
862 B
Python
Raw Normal View History

2017-04-08 20:05:35 +02:00
import bpy
2020-09-08 23:21:41 +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
class MaterialNode(ArmLogicTreeNode):
2020-10-05 19:55:56 +02:00
"""Stores the given material as a variable."""
2017-04-08 20:05:35 +02:00
bl_idname = 'LNMaterialNode'
bl_label = 'Material'
arm_version = 1
2017-04-08 20:05:35 +02:00
@property
def property0_get(self):
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])
property0: PointerProperty(name='', type=bpy.types.Material)
2017-04-08 20:05:35 +02:00
def init(self, context):
super(MaterialNode, self).init(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='')