Setting that material index of a character in a bpy text object

ezgif.com-video-to-gif (7)

UI_W_TEXT_Demo2.blend (585.4 KB)
UI_W_TEXT_Demo.blend (584.8 KB)

import bge,bpy


def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner
    if cont.sensors['Always'].positive:
        if 'index' not in own:
            own['index']=0
        
        char = own['index']
        own['index']+=1
        
        if own['index']>len(own.text)-1:
            own['index']=0
        
        curves =  bpy.data.curves[own.name]
        character_format = curves.body_format[char]
        if character_format.material_index==0:
             character_format.material_index=1
        else:
             character_format.material_index=0     
                
    
        
            
        
main()
1 Like