godot-start/script/demo02_base/base3.gd

40 lines
625 B
GDScript
Raw Normal View History

2021-10-20 03:52:25 +00:00
extends Node2D
const A = preload("res://script/demo02_base/A.gd")
const B = preload("res://script/demo02_base/B.gd")
func _ready():
#referenceTest()
2021-10-22 09:08:18 +00:00
referenceCycleTest()
2021-10-20 03:52:25 +00:00
#referenceUnreference1Test()
2021-10-22 09:08:18 +00:00
#referenceUnreference2Test()
2021-10-20 03:52:25 +00:00
pass
func referenceTest():
var a = A.new()
var b = B.new()
func referenceCycleTest():
var a = A.new()
var b = B.new()
a.b = b
b.a = a
func referenceUnreference1Test():
var a = A.new()
var b = B.new()
a.b = b
b.a = a
a.unreference()
b.unreference()
func referenceUnreference2Test():
var a = A.new()
var b = B.new()
a.b = b
b.a = a
a.b.unreference()
b.a.unreference()