31 lines
		
	
	
		
			989 B
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			31 lines
		
	
	
		
			989 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 
								 | 
							
								import bpy
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import lnx.utils
							 | 
						||
| 
								 | 
							
								from lnx.logicnode.lnx_nodes import *
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class MaterialNode(LnxLogicVariableNodeMixin, LnxLogicTreeNode):
							 | 
						||
| 
								 | 
							
								    """Stores the given material as a variable."""
							 | 
						||
| 
								 | 
							
								    bl_idname = 'LNMaterialNode'
							 | 
						||
| 
								 | 
							
								    bl_label = 'Material'
							 | 
						||
| 
								 | 
							
								    lnx_version = 1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @property
							 | 
						||
| 
								 | 
							
								    def property0_get(self):
							 | 
						||
| 
								 | 
							
								        if self.property0 == None:
							 | 
						||
| 
								 | 
							
								            return ''
							 | 
						||
| 
								 | 
							
								        if self.property0.name not in bpy.data.materials:
							 | 
						||
| 
								 | 
							
								            return self.property0.name
							 | 
						||
| 
								 | 
							
								        return lnx.utils.asset_name(bpy.data.materials[self.property0.name])
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    property0: HaxePointerProperty('property0', name='', type=bpy.types.Material)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def lnx_init(self, context):
							 | 
						||
| 
								 | 
							
								        self.add_output('LnxDynamicSocket', 'Material', is_var=True)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def draw_content(self, context, layout):
							 | 
						||
| 
								 | 
							
								        layout.prop_search(self, 'property0', bpy.data, 'materials', icon='NONE', text='')
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def synchronize_from_master(self, master_node: LnxLogicVariableNodeMixin):
							 | 
						||
| 
								 | 
							
								        self.property0 = master_node.property0
							 |