0 votes

I have a scene where I need many progress bars of different colors.
I made a scene A consisting of a single progress bar and added it a script funciton to change color from a script. This works.
Then I made another scene B with three above bars A instanced and made fg/bg color styles for all of them unique. So far so good. I can change color of each of those and the colors change independently.
Now on the main scene level I instance several B scenes. The hierarchy looks like this:

Main
  B
     A
     A
     A
  B
     A
     A
     A
  B...

Once I change the color of first bar in the scene B, all instances of B change the color of this bar. How do I make them unique?

I tried clicking in the editor 'Make sub-resources unique' on all scenes but it didn't make any difference.

in Engine by (33 points)

2 Answers

+1 vote
Best answer

To make an instance unique, it basically means you have to not use instancing, by removing the link B instances have with the B scene.

To do this, right-click on the instance in the scene tree, and choose "Make local".

by (27,790 points)
selected by
+2 votes

Zylann's solution works, but I've also found another one based just on scripting, which is better for me as I don't need to make multiple instances local (still may benefit from modifying the instanced scene later):

This is in B, which is just the progress bar:

func set_colors(fg_color):
    # Set foreground color
    var fg = get("custom_styles/fg").duplicate()
    fg.set_bg_color(fg_color)
    set("custom_styles/fg", fg)
by (33 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.