Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

클래스 참조 입문

이 페이지에서는 클래스 참조를 작성하는 방법을 설명합니다. Godot의 내장 노드 유형에 대한 클래스, 메소드, 속성에 대한 새로운 설명을 어디에 작성하는지 배우게 됩니다.

더 보기

Git 버전 제어 시스템을 사용하여 Godot 프로젝트에 변경 사항을 제출하는 방법을 배우려면 `클래스 참조 기여 문서 <https://contributing.godotengine.org/en/latest/documentation/class_reference.html>`__를 참조하세요.

각 클래스에 대한 참조는 아래와 같은 XML 파일에 포함되어 있습니다.

<class name="Node2D" inherits="CanvasItem" version="4.0">
    <brief_description>
        A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
    </brief_description>
    <description>
        A 2D game object, with a transform (position, rotation, and scale). All 2D nodes, including physics objects and sprites, inherit from Node2D. Use Node2D as a parent node to move, scale and rotate children in a 2D project. Also gives control of the node's render order.
    </description>
    <tutorials>
        <link title="Custom drawing in 2D">https://docs.godotengine.org/en/latest/tutorials/2d/custom_drawing_in_2d.html</link>
        <link title="All 2D Demos">https://github.com/godotengine/godot-demo-projects/tree/master/2d</link>
    </tutorials>
    <methods>
        <method name="apply_scale">
            <return type="void">
            </return>
            <argument index="0" name="ratio" type="Vector2">
            </argument>
            <description>
                Multiplies the current scale by the [code]ratio[/code] vector.
            </description>
        </method>
        [...]
        <method name="translate">
            <return type="void">
            </return>
            <argument index="0" name="offset" type="Vector2">
            </argument>
            <description>
                Translates the node by the given [code]offset[/code] in local coordinates.
            </description>
        </method>
    </methods>
    <members>
        <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position">
            Global position.
        </member>
        [...]
        <member name="z_index" type="int" setter="set_z_index" getter="get_z_index" default="0">
            Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.
        </member>
    </members>
    <constants>
    </constants>
</class>

간단하고 긴 설명으로 시작됩니다. 생성된 문서에서 간략한 설명은 항상 페이지 상단에 표시되고 긴 설명은 메소드, 변수 및 상수 목록 아래에 표시됩니다. 별도의 XML 노드에서 메소드, 멤버 변수, 상수 및 시그널를 찾을 수 있습니다.

각각에 대해 Godot의 소스 코드에서 어떻게 작동하는지 배우고 싶습니다. 그런 다음 다음 태그의 텍스트를 완성하거나 개선하여 문서를 작성하세요.

  • 설명

  • 설명

  • PI 상수.

  • <method>`(`<description> 태그에 있음, 반환 유형 및 인수는 별도의 문서 문자열을 사용하지 않음)

  • <member>

  • <signal>`(`<description> 태그에 있음, 인수는 별도의 문서 문자열을 사용하지 않음)

  • PI 상수.

명확하고 간단한 언어로 작성하십시오. 설명을 짧고 읽기 쉽게 유지하려면 항상 `작성 지침 <https://contributing.godotengine.org/en/latest/documentation/guidelines/docs_writing_guidelines.html>`__을 따르십시오. 설명에 빈 줄을 두지 마십시오: XML 파일의 각 줄은 비어 있더라도 새 단락이 됩니다.

클래스 XML을 편집하는 방법

클래스 참조를 업데이트하려면 ``doc/classes/``에서 선택한 클래스에 대한 파일을 편집하세요. 폴더에는 각 클래스에 대한 XML 파일이 포함되어 있습니다. XML에는 클래스 참조에서 찾을 수 있는 상수와 메서드가 나열되어 있습니다. Godot는 자동으로 XML을 생성하고 업데이트합니다.

참고

엔진 소스 코드의 일부 모듈의 경우 대신 modules/<module_name>/doc_classes/ 디렉터리에서 XML 파일을 찾을 수 있습니다.

즐겨 사용하는 텍스트 편집기를 사용하여 편집하세요. 코드 편집기를 사용하는 경우 들여쓰기 스타일이 변경되지 않는지 확인하세요. XML에는 탭을 사용해야 하고 BBCode 스타일 블록 안에는 4개의 공백을 사용해야 합니다. 자세한 내용은 아래를 참조하세요.

생성된 문서에서 수정 사항이 올바른지 확인하려면 doc/ 폴더로 이동하여 make rst 명령을 실행하세요. 그러면 XML 파일이 온라인 문서의 형식으로 변환되고 문제가 있는 경우 오류가 출력됩니다.

또는 Godot를 빌드하고 내장 코드 참조에서 수정된 페이지를 열 수 있습니다. 엔진 컴파일 방법을 알아보려면 :ref:`컴파일 가이드 <toc-devel-compiling>`을 읽어보세요.

파일을 편안하게 편집하려면 Vim, Atom, Visual Studio Code, Notepad++ 등과 같은 XML 파일을 지원하는 코드 편집기를 사용하는 것이 좋습니다. 검색 기능을 사용하여 클래스와 속성을 빠르게 찾을 수도 있습니다.

Visual Studio Code를 사용하는 경우 `vscode-xml 확장 <https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml>`__을 설치하여 클래스 참조 XML 파일에 대한 Linting을 얻을 수 있습니다.

BBCode 스타일 태그로 서식 개선

Godot의 XML 클래스 참조는 텍스트와 코드의 서식 지정은 물론 연결을 위해 BBCode와 같은 태그를 지원합니다. 아래 표에서는 사용 가능한 태그, 사용 예 및 reStructuredText로 변환한 후의 결과를 확인할 수 있습니다.

라이트 베이킹

다른 클래스의 멤버에 연결할 때마다 클래스 이름을 지정해야 합니다. 동일한 클래스에 대한 링크의 경우 클래스 이름은 선택 사항이며 생략할 수 있습니다.

설명

예제

결과

클래스
라이선스에 대한 링크

Sprite

Sprite

[annotation Class.name]
벡터 연산

See [annotation @GDScript.@rpc].

Sprite

[constant Class.name]
상수를 정의합니다.

See [constant Color.RED].

Color

[enum Class.name]
라이선스에 대한 링크

See [enum Mesh.ArrayType].

:ref:`Mesh.ArrayType <enum_Mesh_ArrayType>`을 참조하세요.

[member Class.name]
멤버 편집

Get [member Node2D.scale].

NodePath

메서드
메서드 호출하기

Call [method Node3D.hide].

Sprite

메서드
내장 생성자로 연결

Use [constructor Color.Color].

Color

메서드
벡터 내장 타입

Use [operator Color.operator *].

Color

[signal Class.name]
바인딩 시그널

Emit [signal Node.renamed].

NodePath

[theme_item Class.name]
라이선스에 대한 링크

See [theme_item Label.font].

:ref:`Label.font <class_Label_theme_font_font>`을 참조하세요.

[param name]
매개변수 이름(코드로)

Takes [param size] for the size.

크기는 ``size``를 사용합니다.

참고

현재는 :ref:`class_@GDScript`에만 주석이 있습니다.

서식(Formatting)

설명

예제

결과

[br]
break
Line 1.[br]
Line 2.
1호선.
2호선.
<< >>
각각 []

[lb]b[rb]text[lb]/b[rb]

[b]텍스트[/b]

<< >>
굵게

Do [b]not[/b] call this method.

Do not call this method.

<< >>
기울임

Returns the [i]global[/i] position.

전역 위치를 반환합니다.

<< >>
밑줄

[u]Always[/u] use this method.

Always use this method.
<< >>
취소선

[s]Outdated information.[/s]

Outdated information.
<< >>
하이퍼링크
[url]https://example.com[/url]
[url=https://example.com]Website[/url]
<< >>
가로 센터링

[center]2 + 2 = 4[/center]

2 + 2 = 4
[kbd] [/kbd]
키보드 단축키

Press [kbd]Ctrl + C[/kbd].

Ctrl + O

[code] [/code]
인라인 코드 조각

Returns [code]true[/code].

반환

참고

  1. [color]``[font]``와 같은 일부 지원되는 태그는 엔진 문서에서 권장되지 않기 때문에 여기에 나열되지 않습니다.

  2. [kbd] disables BBCode until the parser encounters [/kbd].

  3. [code] disables BBCode until the parser encounters [/code].

서식(Formatting)

타입을 등록하는 데는 두 가지 시스템이 있습니다:

  1. 특정 언어에 대한 예제를 추가하려면 ``[codeblock]``를 사용하세요.

  2. 두 언어, GDScript 및 C#에 동일한 예제를 추가하려면 [codeblocks], [gdscript]``[csharp]``를 사용하십시오.

기본적으로 [codeblock]``는 GDScript 구문을 강조 표시합니다. ``lang 속성을 사용하여 변경할 수 있습니다. 현재 지원되는 옵션은 다음과 같습니다.

  • ``[codeblock lang=text]``는 구문 강조 표시를 비활성화합니다.

  • ``[codeblock lang=gdscript]``는 GDScript 구문을 강조합니다.

  • ``[codeblock lang=csharp]``는 C# 구문을 강조 표시합니다(.NET 버전에만 해당).

참고

[codeblock] disables BBCode until the parser encounters [/codeblock].

경고

사전 형식화된 코드 블록에는 ``[codeblock]``를 사용하세요. Godot 4.5부터 들여쓰기에는 **탭**을 사용해야 합니다.

예를 들면:

[codeblock]
func _ready():
    var sprite = get_node("Sprite2D")
    print(sprite.get_pos())
[/codeblock]

다음과 같이 표시됩니다.

func _ready():
    var sprite = get_node("Sprite2D")
    print(sprite.get_pos())

GDScript와 C#에서 다른 코드 버전이 필요한 경우 대신 [codeblocks]``를 사용하세요. ``[codeblocks]``를 사용하는 경우 언어별 태그인 ``[gdscript][csharp] 중 하나 이상이 있어야 합니다.

항상 GDScript 코드 예제를 먼저 작성하세요! 이 `실험 코드 번역 도구 <https://github.com/HaSa1002/codetranslator>`_를 사용하면 작업 흐름 속도를 높일 수 있습니다.

[codeblocks]
[gdscript]
func _ready():
    var sprite = get_node("Sprite2D")
    print(sprite.get_pos())
[/gdscript]
[csharp]
public override void _Ready()
{
    var sprite = GetNode("Sprite2D");
    GD.Print(sprite.GetPos());
}
[/csharp]
[/codeblocks]

위와 같이 표시됩니다.

func _ready():
    var sprite = get_node("Sprite2D")
    print(sprite.get_pos())

서식 참고 및 경고

중요한 정보를 표시하려면 설명 끝에 "[b]Note:[/b]"로 시작하는 단락을 추가하세요.

[b]Note:[/b] Only available when using the Forward+ renderer.

주의 깊게 따르지 않을 경우 보안 문제나 데이터 손실을 일으킬 수 있는 중요한 정보를 표시하려면 설명 끝에 "[b]Warning:[/b]"로 시작하는 단락을 추가하십시오.

[b]Warning:[/b] If this property is set to [code]true[/code], it allows clients to execute arbitrary code on the server.

위에 설명된 모든 단락에서 일관성을 위해 문장 부호가 BBCode 태그의 일부인지 확인하세요.

API를 사용되지 않음/실험적으로 표시하기

API를 더 이상 사용되지 않거나 실험적인 것으로 표시하려면 해당 XML 속성을 추가해야 합니다. 속성 값은 API가 권장되지 않는 이유(BBCode 마크업 지원)를 설명하는 메시지이거나 빈 문자열(기본 메시지가 사용됨)이어야 합니다. API 요소가 더 이상 사용되지 않거나 실험적인 것으로 표시되면 설명이 비어 있어도 문서화된 것으로 간주됩니다.

<class name="Parallax2D" inherits="Node2D" experimental="This node is meant to replace [ParallaxBackground] and [ParallaxLayer]. The implementation may change in the future." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
    [...]
</class>

<constant name="RESPONSE_USE_PROXY" value="305" enum="ResponseCode" deprecated="Many clients ignore this response code for security reasons. It is also deprecated by the HTTP standard.">
    HTTP status code [code]305 Use Proxy[/code].
</constant>

<member name="auto_translate" type="bool" setter="set_auto_translate" getter="is_auto_translating" deprecated="Use [member Node.auto_translate_mode] instead.">
    Toggles if any text should automatically change to its translated version depending on the current locale.
</member>

<method name="get_method_call_mode" qualifiers="const" deprecated="Use [member AnimationMixer.callback_mode_method] instead.">
    <return type="int" enum="AnimationPlayer.AnimationMethodCallMode" />
    <description>
        Returns the call mode used for "Call Method" tracks.
    </description>
</method>