Skip to content

feat: Unity client SDK (continuation of #1105)#1516

Open
ChiragAgg5k wants to merge 165 commits intomasterfrom
unity-client-sdk-continued
Open

feat: Unity client SDK (continuation of #1105)#1516
ChiragAgg5k wants to merge 165 commits intomasterfrom
unity-client-sdk-continued

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

Summary

This PR continues the work started by @Fellmonkey in #1105 to add comprehensive Unity SDK support to the SDK generator.

What was done

  • Rebased/fetched the original unity-client-sdk branch from Unity client sdk #1105
  • Created a new branch unity-client-sdk-continued preserving all original commits from the community PR
  • Merged latest master and resolved conflicts (notably in templates/dotnet/Package/Models/Model.cs.twig)

Original PR content (from #1105)

  • Unity Language Implementation: Introduces a new Unity language class (src/SDK/Language/Unity.php) that extends the base Language class, providing Unity-specific type mappings, keywords, and code generation logic for C# in Unity environment.
  • Unity Template System: Adds a complete set of Unity-specific templates under templates/unity/Assets/ including:
    • Runtime components (Client, Services, Models, Enums, etc.)
    • Editor tools (Setup Assistant, Setup Window)
    • Unity project files (assembly definitions, project settings)
    • Required .NET libraries for Unity compatibility
  • Automated Testing Integration: Introduces Unity2021 test support with:
    • Unity2021Test.php test class that integrates with the existing test framework
    • Unity test source files (Tests.cs, Tests.asmdef) for comprehensive SDK testing
    • Docker-based Unity CI testing using unityci/editor:ubuntu-2021.3.45f1-base-3.1.0
  • CI/CD Integration: Updates the GitHub Actions workflow to:
    • Include Unity2021 in the test matrix alongside other SDK platforms
    • Set up the UNITY_LICENSE environment variable for Unity Editor automation
    • Enable automated testing of the Unity SDK in the CI pipeline
  • Unity Project Structure: Implements proper Unity package structure with:
    • Assets organized under Assets/Runtime/ and Assets/Editor/
    • Required Unity project settings and manifest files

Changes from original PR

  • Resolved merge conflicts with current master
  • Preserved all original author commits and attribution

Closes #1105

Moved Unity SDK template files from 'templates/unity/Runtime' and 'templates/unity/Editor' to 'templates/unity/Assets/Runtime' and 'templates/unity/Assets/Editor' for better alignment with Unity project conventions. Updated getFiles() in Unity.php to reflect new paths and added support for copying plugin DLLs and project settings. Improved file upload logic in Client.cs.twig to handle streams and byte arrays more robustly, and removed Unity-specific logging from Exception.cs.twig. Minor fixes in Realtime.cs.twig and Role.cs.twig for namespace and async handling.
Introduces Unity2021 test support by adding a Unity2021Test.php, Unity test source files, and updating the GitHub Actions workflow to include Unity2021 in the test matrix and set the UNITY_LICENSE environment variable. This enables automated testing for the Unity SDK within the CI pipeline.
Comment thread templates/unity/Assets/Runtime/Core/Client.cs.twig Outdated
Comment thread tests/languages/unity/Tests.cs
Comment thread templates/unity/Assets/Runtime/Core/Client.cs.twig Outdated
Comment thread templates/unity/Assets/Runtime/Core/Client.cs.twig
Comment thread tests/languages/unity/Tests.cs Outdated
Comment thread tests/Unity2021Test.php
Comment on lines +290 to +298
if (inputFile.Data is Stream stream)
{
using (var memoryStream = new MemoryStream())
{
stream.CopyTo(memoryStream);
fileData = memoryStream.ToArray();
}
}
break;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Silent zero-byte upload when stream data is null

In PrepareRequest's multipart path, the "stream" branch wraps everything in if (inputFile.Data is Stream stream). If inputFile.Data is null or not a Stream, the block is silently skipped and fileData stays as the empty array {} declared on line 279. The zero-byte array is then passed to MultipartFormFileSection, uploading an empty file with no error or warning. The "path" case correctly throws FileNotFoundException and the "bytes" case falls back with Array.Empty<byte>(), but neither notifies the caller — the stream case should throw here too.

Comment thread src/SDK/Language/DotNet.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants