This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

I have a project where I am attempting to click through tabs in my tab container node, and set the stylebox resource to something different for each corresponding tab.
I am able to callback from each tab click individually as needed, however, every source online i find, leads to me believe that in order to change
this property

in case image doesn't load
by using onready var panel = get_stylebox("custom_styles/panel")
or onready var panel = get_stylebox("panel")
as the variable, and yet when I attempt to set the new value to a stylebox resource:

onready var red = load("res://source/art/red_styleboxflat.tres")
func _some_func():
    panel = red

It throws no errors, and no warnings, so I am left to believe that it is accessing something but not actually altering it as the code is set to do.

Is there some other way of changing the TabContainer custom stylebox "panel" property that has not been listed, or am I simply setting this value the wrong way?

in Engine by (29 points)

1 Answer

+2 votes
Best answer

What you're looking for is:

var red = load("res://source/art/red_styleboxflat.tres")
set("custom_styles/panel", red)

What you did instead was:

  1. getting a copy of the stylebox
  2. saving it into a local variable panel
  3. then changing the value of that variable

That's a valid operation, thus does not yield any errors or warning. However, it also doesn't do what you want as it leaves the actual stylebox unchanged.

by (10,634 points)
selected by

HOLY CRAP THANK YOU! I've been trying to scratch my noodle over this one for days now! This fixed everything!

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 Frequently asked questions and 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 [email protected] with your username.