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()
|
2022-01-09 10:53:33 +00:00
|
|
|
#referenceCycleTest()
|
|
|
|
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()
|
|
|
|
|
|
|
|
func referenceUnreference2Test():
|
|
|
|
var a = A.new()
|
|
|
|
var b = B.new()
|
|
|
|
a.b = b
|
|
|
|
b.a = a
|
2022-01-09 10:53:33 +00:00
|
|
|
a.unreference()
|
|
|
|
b.unreference()
|