Skip to content

gameguild-gg/godot-mono-webgl-ghpages

Repository files navigation

Godot 3.6 WebGL Project with .NET Support

This is a Godot 3.6 project configured for WebGL deployment with C#/.NET support and OpenGL ES 2.0 rendering.

Project Features

  • Godot 3.6 game engine
  • OpenGL ES 2.0 renderer for maximum compatibility
  • WebGL export support for web deployment
  • C#/.NET Framework 4.7.2 support for scripting
  • GitHub Pages ready for deployment with automated CI/CD

Project Structure

├── project.godot              # Main project configuration
├── GodotWebGLProject.csproj   # .NET project file
├── GodotWebGLProject.sln      # Visual Studio solution
├── export_presets.cfg         # Export configuration for WebGL
├── Main.tscn                  # Main scene
├── icon.png                   # Project icon
├── scenes/                    # Scene files
│   └── TestScene.tscn        # Test scene with interactive elements
├── scripts/                   # C# scripts
│   ├── Main.cs               # Main scene script
│   └── TestScene.cs          # Test scene script
├── assets/                    # Game assets
├── textures/                  # Texture files
├── sounds/                    # Audio files
└── build/                     # WebGL build output

Getting Started

Prerequisites

  1. Godot 3.6 with Mono/.NET support
  2. .NET Framework 4.7.2 or higher
  3. Visual Studio or Visual Studio Code (optional, for C# development)

Opening the Project

  1. Open Godot 3.6 - This exct version, in order to be able to have dotnet on webgl build target.
  2. Click "Import" and select this folder
  3. The project should automatically detect the project.godot file
  4. Click "Import & Edit"

Building the Project

  1. In Godot, go to Project > Project Settings
  2. Ensure the Mono tab shows the correct assembly name
  3. Go to Build > Build Project to compile C# scripts
  4. Run the project with F5 or the play button

Exporting to WebGL

  1. Go to Project > Export
  2. Select the HTML5 preset (already configured, if not, install the template)
  3. Click Export Project
  4. Choose the build/ directory as the export location
  5. The exported files will be ready for web deployment

Project Configuration

Rendering Settings

  • Driver: OpenGL ES 2.0 (GLES2)
  • VRAM Compression: ETC for mobile compatibility
  • Canvas Resize Policy: Adaptive for responsive design

.NET Configuration

  • Target Framework: .NET Framework 4.7.2
  • Language Version: C# 7.3
  • Assembly Name: GodotWebGLProject

Scenes and Scripts

Main Scene (Main.tscn)

  • Simple welcome screen with interactive button
  • Click the button 5 times or press 'T' to navigate to test scene
  • Demonstrates basic C# scripting and UI interaction

Test Scene (scenes/TestScene.tscn)

  • Interactive color-changing demonstration
  • Shows runtime information (renderer, platform, framework)
  • Keyboard controls:
    • Space: Change color randomly
    • R: Reset to original color
    • Escape: Return to main scene

Deployment

GitHub Pages

  1. Build the project for WebGL
  2. Copy the contents of the build/ folder to your repository
  3. Enable GitHub Pages in repository settings
  4. Your game will be available at https://username.github.io/repository-name

Local Testing

  1. After exporting, you can test locally using a simple HTTP server:
    cd build
    python -m http.server 8000
  2. Open http://localhost:8000 in your browser

GitHub Pages Deployment

This project includes automated GitHub Actions workflow for deploying to GitHub Pages.

Prerequisites

  1. Your repository must be public (or you need GitHub Pro for private repos)
  2. The repository should be pushed to GitHub
  3. You need admin access to the repository

Automatic Deployment

The project will automatically build and deploy to GitHub Pages when you:

  • Push to the main or master branch
  • Create a pull request to main or master

Setup Instructions

1. Enable GitHub Pages

  1. Go to your repository on GitHub
  2. Click on Settings tab
  3. Scroll down to Pages section in the left sidebar
  4. Under Source, select GitHub Actions

2. Configure Repository Permissions

  1. In the repository Settings
  2. Go to ActionsGeneral
  3. Under Workflow permissions, select:
    • Read and write permissions
    • Allow GitHub Actions to create and approve pull requests

3. Trigger the Workflow

The workflow will automatically run when you:

  • Push to the main or master branch
  • Create a pull request to main or master
  • Manually trigger it from the Actions tab

4. Push to GitHub

git add .
git commit -m "Add Godot WebGL project with GitHub Pages deployment"
git push origin main

5. Access Your Game

After successful deployment, your game will be available at:

https://[username].github.io/[repository-name]/

Manual Deployment

You can also trigger deployment manually:

  1. Go to Actions tab in your repository
  2. Select Deploy Godot WebGL to GitHub Pages workflow
  3. Click Run workflow button
  4. Select the branch and click Run workflow

Workflow Process

The GitHub Actions workflow will:

  1. Setup Environment: Install .NET, Godot 3.6, and dependencies
  2. Import Assets: Import all project assets in headless mode
  3. Build C# Project: Compile the C# scripts using Godot
  4. Export WebGL: Export the project to WebGL format in the build/ directory
  5. Deploy: Upload the build artifacts to GitHub Pages

Build Artifacts

The workflow creates these files in the build/ directory:

  • index.html - Main HTML file
  • *.js - JavaScript runtime files
  • *.wasm - WebAssembly binary
  • *.pck - Godot data package

GitHub Pages Troubleshooting

Common Issues

  1. Workflow fails on export: Check that export_presets.cfg is committed to the repository
  2. Pages not updating: Ensure GitHub Pages source is set to "GitHub Actions"
  3. Permission errors: Verify workflow permissions are set correctly

Checking Workflow Status

  1. Go to Actions tab in your repository
  2. Click on the latest workflow run
  3. Check each step for detailed logs and error messages

Security Notes

  • The workflow only deploys from the main/master branch
  • Build artifacts are temporary and cleaned up automatically
  • No sensitive information should be included in the exported game

Troubleshooting

Common Issues

  1. C# Scripts Not Compiling

    • Ensure Godot 3.6 with Mono support is installed
    • Check that .NET Framework 4.7.2 is installed
    • Try Build > Rebuild Project
  2. WebGL Export Issues

    • Ensure you have the HTML5 export templates installed
    • Check that the export path is correct
    • Verify browser supports WebGL
  3. Performance Issues

    • The project uses OpenGL ES 2.0 for maximum compatibility
    • Consider optimizing textures and reducing draw calls
    • Test on different devices and browsers

Development Notes

  • This project is configured for Godot 3.6 specifically
  • C# scripts use .NET Framework 4.7.2 for WebGL compatibility
  • The project uses OpenGL ES 2.0 renderer for broad device support
  • Export presets are pre-configured for optimal WebGL deployment

License

This project template is provided as-is for educational and development purposes.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages