Godot
[Godot] Access Another Script 다른 스크립트에 접근하기
J-sean
2023. 9. 25. 11:09
반응형
다른 스크립트에 선언된 변수에 접근해 보자.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
using Godot;
public partial class Character1 : Sprite2D
{
public int a = 10;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
using Godot;
public partial class Character2 : Sprite2D
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
GD.Print(GetNode<Character1>("../../Character_1/Sprite2D").a);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}
|
반응형