C#으로 spine-godot 설정하기

October 2nd, 2023

이 블로그 게시물에서는 spine-godot을 통해 C#을 사용하는 단계와 GDScript를 사용하는 것과 어떻게 다른지 간략하게 설명합니다.


설치

spine-godot 런타임 설명서에서 사전 구축된 Godot 4.1 편집기를 다운로드하고 C#을 지원하는 템플릿 바이너리를 내보낼 수 있습니다. 기본 설치 지침은 해당 설명서를 참조하세요.


C# 프로젝트 설정

C#을 지원하는 Godot 편집기 바이너리를 사용하려면 새 Godot 프로젝트를 설정할 때 다음의 추가 단계를 수행해야 합니다.

1. Godot 프로젝트 만들기

먼저, C#을 지원하는 다운로드된 Godot 편집기 바이너리를 사용하여 새 Godot 프로젝트를 만듭니다.

.NET 런타임 로드 실패

Godot 편집기가 .NET 런타임을 로드하지 못하면 시작 시 다음과 같은 오류 메시지가 표시됩니다.

메시지에 설명된 대로 Microsoft 공식 다운로드 사이트에서 .NET SDK 6.0 이상을 설치한 후 Godot을 다시 시작하세요.


2. godot-nuget 폴더 만들기

Godot을 닫고 프로젝트 폴더를 엽니다. 루트 디렉터리에 godot-nuget이라는 새 폴더를 만듭니다.


3. C# 어셈블리 복사

Godot C# 어셈블리를 godot-nuget 폴더에 복사합니다. Windows 또는 Linux를 사용하는 경우 다운로드한 Godot 편집기 ZIP 파일에서 어셈블리를 찾을 수 있습니다.

  • Windows: godot-editor-windows-mono.zip\GodotSharp\Tools\
  • Linux: godot-editor-linux-mono.zip/GodotSharp/Tools/

macOS를 사용하는 경우:

  • macOS: Finder에서 Godot.app 파일을 마우스 오른쪽 버튼으로 클릭하여 Godot.app/Contents/Resources/GodotSharp/Tools/로 이동한 후 Show Package Contents를 선택한 다음 Contents/Resources/GodotSharp/Tools/로 이동합니다.

다음 파일을 godot-nuget 폴더에 복사합니다.

  • GodotSharpEditor.<version>.snupkg
  • Godot.NET.Sdk.<version>.nupkg
  • Godot.SourceGenerators.<version>.nupkg
  • GodotSharp.<version>.nupkg
  • GodotSharp.<version>.snupkg
  • GodotSharpEditor.<version>.nupkg

<version>부분은 다운로드한 Godot의 버전에 따라 다릅니다. 예:4.1.1.


4. nuget.config 파일 만들기

마지막으로 프로젝트의 루트 디렉터리에 다음 내용으로 'nuget.config'라는 새 파일을 만듭니다.

<configuration>
<packageSources>
    <!-- package source is additive -->
    <add key="godot-nuget" value="./godot-nuget" />
</packageSources>
</configuration>

이렇게 하면 godot-nuget 디렉터리가 NuGet 패키지의 패키지 소스가 되도록 구성됩니다. NuGet 패키지 레지스트리에서 공식 Godot C# 어셈블리를 가져오는 대신 godot-nuget 디렉터리의 어셈블리가 사용되며 여기에는 spine-godot 런타임에 대한 C# 바인딩도 포함됩니다.


이제 Godot에서 프로젝트를 열고 GDScript 대신 Godot 및 spine-godot C# API를 사용할 수 있습니다!


C#으로 스켈레톤 애니메이팅

다음은 SpineSprite 노드에 연결된 C# 스크립트를 사용하여 Spine 스켈레톤을 애니메이팅하는 간단한 예제 코드입니다.

C#:

using Godot;
using System;

public partial class SpineSprite : SpineSprite {
   public override void _Ready () {
      GetAnimationState().SetAnimation("run", true, 0);
   }
}

GDScript로 작성된 동일한 코드와 비교하면 API가 PascalCase를 사용하고 C# 코드 규칙에 따라 끝에 세미콜론이 필요하다는 점을 제외하면 거의 차이가 없습니다.

GDScript:

extends SpineSprite

func _ready():
   get_animation_state().set_animation("run", true, 0)

GDScript에서는 @onready 주석을 사용하여 함수 밖에서 스켈레톤을 가져올 수 있습니다. C#에서는 클래스 정의에서 API를 호출할 수 없으므로 함수 내에서 API를 가져와야 합니다. 다음은 스켈레톤 및 큐 애니메이션을 뒤집는 C#과 GDScript 코드를 비교한 것입니다.

C#:

using Godot;
using System;

public partial class SpineSprite : SpineSprite {
   private SpineSkeleton spineSkeleton;
   private SpineAnimationState spineSpriteAnimState;

   public override void _Ready () {
      spineSkeleton = GetSkeleton();
      spineSpriteAnimState = GetAnimationState();
      spineSkeleton.SetScaleX(-1);
      spineSpriteAnimState.SetAnimation("idle", true, 0);
      spineSpriteAnimState.AddAnimation("run", 2, true, 0);
   }
}

GDScript:

extends SpineSprite

@onready var spineSkeleton : SpineSkeleton = get_skeleton()
@onready var spineSpriteAnimState : SpineAnimationState = get_animation_state()

func _ready():
   spineSkeleton.set_scale_x(-1)
   spineSpriteAnimState.set_animation("idle", true, 0)
   spineSpriteAnimState.add_animation("run", 2, true, 0)

API가 GDScript에서 C#으로 매핑되는 방법에 대한 자세한 내용은 Godot C# 설명서를 참조하세요.


C# 예제

spine-godot의 C# 예제를 살펴보고 실험해 보려면:

  1. spine-runtimes Git 저장소를 복제하거나 최신 버전을 ZIP으로 다운로드한 후 압축을 풉니다.
  2. spine-runtimes/spine-godot/example-v4-csharp/ 폴더를 연 후 project.godot 파일을 클릭하여 엽니다.

FileSystem 독(dock)의 examples 폴더에서 C#을 사용하는 다양한 예제 장면과 스크립트를 찾을 수 있습니다.


C#을 지원하는 spine-godot을 사용하는 데 문제가 있는 경우, 주저하지 마시고 Spine 포럼에 질문을 올려주세요!

spine-godot C# support

September 5th, 2023

We're happy to announce that our spine-godot runtime now supports programming using the C# language! You are no longer limited to GDScript. C# support lets you use a feature rich IDE and can greatly increase productivity for complex games.

Please note that currently C# support in Godot 4.x is available only for desktop operating systems. As the Godot team expands platform support, our Godot binaries and export templates will be updated accordingly.

Start using C#

To get started, please visit our spine-godot documentation page and download the latest Godot + Spine binary with C# support for your operating system. Currently we provide binaries for the latest Godot stable release, which is 4.1.1.

Once you have successfully installed the Godot binary, follow the C# project setup guide to either initiate a new project or convert an existing one to utilize C# and Spine-Godot.

For more information on this topic, check out our new blog post about setting up a C# project.

Congratulations! You are now ready to develop your Godot games with Spine and C#!

Discuss this blog post on the Spine forum!

spine-ue4 시작하기

July 27th, 2023

언리얼 엔진으로 Spine을 사용하는 방법을 알아보세요! 이 영상에서는 spine-ue4를 설치하고, Spine 스켈레톤을 가져오고, 예제 프로젝트를 살펴보는 방법을 보여드립니다.

다음 영상에서는 예제를 자세히 살펴보고 각 컴포넌트에 대해 더 자세히 알아볼 예정이니 기대해 주세요.

이 영상이 도움이 되셨나요? Spine 포럼에서 이 게시물의 토론에 참여해 보세요!

spine-phaser Runtime released

June 30th, 2023

/img/blog/spine-flutter/spine-flutter.png

We're happy to announce the general availability of our brand new spine-phaser runtime.

Phaser has been one of the most beloved Web game engines for many years now. While Richard Davey and his team of OSS contributors created their own Phaser Spine Plugin, the Phaser team has many other duties. After discussion with Richard, we agreed that creating and maintaining an official Spine runtime for Phaser would be the most beneficial for both the Spine and Phaser communities -- that is what we are releasing today!

Here's a minimal example. Click the JS tab to see the code:

See the Pen Untitled by Mario Zechner (@badlogicgames) on CodePen.

If you are a seasoned Phaser developer who's used the Phaser Spine Plugin, you'll find a few differences with our official spine-phaser runtime. spine-phaser supports both JSON and binary skeleton data files. It also separates loading of skeleton and atlas data, allowing you to reuse the same atlas for multiple skeletons, improving performance.

Another benefit to using the official spine-phaser runtime is that we guarantee timely updates and bug fixes in lock step with our Spine Editor releases. And for Davey and team, we can take away some of their burden, which will free them up to spend more time on Phaser itself.

To learn more, check out our spine-phaser documentation and have a look at the example code. We've ported many of the original Phaser Spine Plugin samples to our official runtime, which should make switching to the official runtime an easy endeavor.

Discuss this blog post on the forums!