Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A collection of tools for accelerating Godot + C# game development, including resource loading, feature tags, and high-DPI utilities.

License

NotificationsYou must be signed in to change notification settings

chickensoft-games/GameTools

Repository files navigation

Chickensoft BadgeDiscordRead the docsline coveragebranch coverage

A collection of tools for accelerating Godot + C# game development.


Chickensoft.GameTools

📦 Installation

# Install this templatedotnet add package  Chickensoft.GameTools --prerelease

⏳ Multithreaded Loading

Godot provides a wonderful mechanism calledResourceLoader that can load engine resources in the background, but leveraging it correctly to load more than one thing at once issurprisingly complicated.

You can leverage theLoader class provided by GameTools to simplify loading:

usingGodot;usingChickensoft.GameTools;publicpartialclassMyNode:Node{publicLoaderLoader{get;set;}=default!;publicMeshMyMesh{get;set;}=default!;publicPackedSceneMyScene{get;set;}=default!;publicoverridevoid_Ready(){Loader=new();// Add a job for everything you want to load. The callback will be// invoked with your loaded resource, allowing you to hang onto it.Loader.AddJob<Mesh>("res://my_mesh.tscn",(resource)=>MyMesh=resource);Loader.AddJob<PackedScene>("res://my_scene.tscn",(resource)=>MyScene=resource);// Subscribe to events to track progress and completion.Loader.Progress+=OnLoaderProgress;// There are other loading events you can subscribe to, if needed:// Loader.Started += () => GD.Print("Loader started!");// Loader.Completed += () => GD.Print("Loader completed!");// Start loading everything.Loader.Load();}publicoverridevoid_Process(doubledelta){// Call Update every frame to track progress and ensure events are invoked.if(!Loader.IsCompleted){Loader.Update();}}publicoverridevoid_ExitTree(){Loader.Progress-=OnLoaderProgress;}publicvoidOnLoaderProgress(floatprogress){GD.Print($"Total loading percent:{progress}");}}

Tip

To facilitate simple UI construction, the loader guarantees that you will receive progress updates for 0.0 and 1.0. The progress amount is the progress of all jobs as a percentage between 0 and 1.

🏝️ Godot Feature Tags & Application Environment

Godot providesFeature Tags which allow you to examine the runtime environment of the application. The game tools provides a way to easily access these tags through a strongly-typed interface for C#. It also enables the feature tags to be overridden for testing purposes.

if(Features.OperatingSystemisOSFamily.macOS orOSFamily.Linux){GD.Print("Unix-based system");}// Whenever you need to test a specific environment, you can override the// feature tags to simulate that environment.Features.FakeOperatingSystem(OSFamily.Linux);// Reset overridden features back to the system's actual environment.Features.Reset();
FeatureC# Enum TypeCode
Operating SystemOSFamilyFeatures.OperatingSystem
PlatformPlatformFeatures.Platform
Interactivity ModeInteractivityModeFeatures.InteractivityMode
Build TypeBuildTypeFeatures.BuildType
Tool EnvironmentToolEnvironmentFeatures.ToolEnvironment
PrecisionPrecisionFeatures.Precision
Bit LengthBitLengthFeatures.BitLength
ArchitectureArchitectureFeatures.Architecture
Texture CompressionTextureCompressionFeatures.TextureCompression

For all possible values, check each enum type.

🖥️ Display Scaling & DPI Awareness

GameTools can help you manage display scaling on desktop platforms by automatically guessing or computing the correct scale factor for the game window's screen. On macOS and Windows, it can determine the exact user-defined scale factor by leveragingChickensoft.Platform to invoke the relevant system API's natively.

Check out thedemo project which lets you select between both scaling behaviors and toggle fullscreen mode.

High-Level Scaling Behaviors

Two high-level scaling behaviors are provided by GameTools. Both work well when windowed or full-screen and automatically correct for the scale factor of the screen that the window is on.

✅ Proportional UI Scaling

Scales the UI (and your game) down as the window shrinks. Everything remains the same size relative to each other, enabling you to create games for a specific resolution or highly custom visual style.

Proportional UI Scaling

varinfo=GetWindow().LookGood(WindowScaleBehavior.UIProportional,BaseResolution,isFullscreen:false// or true);

✅ Fixed UI Scaling

Leaves the UI at a fixed size. You can easily configure your game to clip behind it or scale to fit the window using aSubViewport. For the demo, we've opted to configure the game to scale to fit the window while the UI remains unchanged.

Fixed UI Scaling

varinfo=GetWindow().LookGood(WindowScaleBehavior.UIFixed,BaseResolution,isFullscreen:true// or false);

Tip

For more on display scaling, check out Chickensoft's blog article titledDisplay Scaling in Godot 4.

Manual Scaling

You can use the information provided by GameTools in your own scaling computations.

usingChickensoft.GameTools;publicoverridevoid_Ready(){varwindow=GetWindow();varwindow=GetWindow();varscaleInfo=window.GetWindowScaleInfo(Display.UHD4k);varsizeInfo=Display.GetWindowSizeInfo(scaleInfo.LogicalResolution);window.ContentScaleFactor=scaleInfo.ContentScaleFactor;// There are many other properties on scaleInfo, such as// SystemScale, LogicalResolution, NativeResolution, DisplayScale, etc.// sizeInfo has a recommended size for the window and a recommended min and// max size for the window. In case you can't be bothered to do all that.}

🐣 Package generated from a 🐤 Chickensoft Template —https://chickensoft.games

About

A collection of tools for accelerating Godot + C# game development, including resource loading, feature tags, and high-DPI utilities.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp