| 1 |
@static_unload |
| 2 |
|
| 3 |
static var perm := 0 |
| 4 |
|
| 5 |
static var prop := "Hello!": |
| 6 |
get: return prop + " suffix" |
| 7 |
set(value): prop = "prefix " + str(value) |
| 8 |
|
| 9 |
static func get_data(): |
| 10 |
return "data" |
| 11 |
|
| 12 |
static var data = get_data() |
| 13 |
|
| 14 |
class Inner: |
| 15 |
static var prop := "inner" |
| 16 |
static func _static_init() -> void: |
| 17 |
prints("Inner._static_init", prop) |
| 18 |
|
| 19 |
class InnerInner: |
| 20 |
static var prop := "inner inner" |
| 21 |
static func _static_init() -> void: |
| 22 |
prints("InnerInner._static_init", prop) |
| 23 |
|
| 24 |
func test(): |
| 25 |
prints("data:", data) |
| 26 |
|
| 27 |
prints("perm:", perm) |
| 28 |
prints("prop:", prop) |
| 29 |
|
| 30 |
perm = 1 |
| 31 |
prop = "World!" |
| 32 |
|
| 33 |
prints("perm:", perm) |
| 34 |
prints("prop:", prop) |
| 35 |
|
| 36 |
prints("other.perm:", StaticVariablesOther.perm) |
| 37 |
prints("other.prop:", StaticVariablesOther.prop) |
| 38 |
|
| 39 |
StaticVariablesOther.perm = 2 |
| 40 |
StaticVariablesOther.prop = "foo" |
| 41 |
|
| 42 |
prints("other.perm:", StaticVariablesOther.perm) |
| 43 |
prints("other.prop:", StaticVariablesOther.prop) |
| 44 |
|
| 45 |
@warning_ignore("unsafe_method_access") |
| 46 |
var path = get_script().get_path().get_base_dir() |
| 47 |
@warning_ignore("unsafe_call_argument") |
| 48 |
var other = load(path + "/static_variables_load.gd") |
| 49 |
|
| 50 |
prints("load.perm:", other.perm) |
| 51 |
prints("load.prop:", other.prop) |
| 52 |
|
| 53 |
other.perm = 3 |
| 54 |
other.prop = "bar" |
| 55 |
|
| 56 |
prints("load.perm:", other.perm) |
| 57 |
prints("load.prop:", other.prop) |