Skip to content

Commit

Permalink
made duplicate() also copy shader_input.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokepetter committed Nov 22, 2024
1 parent 717bada commit c596d90
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ursina/duplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ def duplicate(entity, copy_children=True, *args, **kwargs): # use a for loop ins
for name in entity.attributes:
if name == 'model':
continue
elif name == 'collider' and entity.collider and entity.collider.name:
if name == 'collider' and entity.collider and entity.collider.name:
# TODO: currently only copies colliders set with strings, not custom colliders.
e.collider = entity.collider.name

elif name == 'scripts':
continue
if name == 'scripts':
for script in entity.scripts:
e.add_script(copy(script))
continue

else:
if hasattr(entity, name):
setattr(e, name, getattr(entity, name))

e.shader_input = entity.shader_input

for c in entity.children:
clone = duplicate(c, copy_children=False)
clone.world_parent = e
Expand Down Expand Up @@ -72,7 +75,7 @@ def duplicate(entity, copy_children=True, *args, **kwargs): # use a for loop ins
# e2 = duplicate(e)
# e2.y += 1.5

e = Button(parent=scene, scale=1, text='yolo')
e = Button(parent=scene, scale=1, text='yolo', texture='shore', texture_scale=Vec2(2), color=color.gray)
# e.c = Entity(parent=e, model='cube', scale=.5, y=.5, color=color.azure)
e2 = duplicate(e, x=1.25)
# print(e.text_entity.z, e2.text_entity.z)
Expand Down

0 comments on commit c596d90

Please sign in to comment.