Skip to content

Release 0.6.7 #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Release 0.6.7 #14

merged 1 commit into from
Apr 7, 2025

Conversation

CoderGamester
Copy link
Owner

@CoderGamester CoderGamester commented Apr 7, 2025

New:

  • Added the UnityObjectExtensions to help add extra logic to Unity's GameObject type objects

Summary by CodeRabbit

  • New Features

    • Enhanced UI interactions by introducing new capabilities that improve the calculation of interface element boundaries and screen hit detection.
  • Chores

    • Updated the package release to version 0.6.7.

- Added the *UnityObjectExtensions* to help add extra logic to Unity's *GameObject* type objects
Copy link

coderabbitai bot commented Apr 7, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a new feature called UnityObjectExtensions by adding a new file that provides extension methods for Unity UI components. The changelog is updated for version 0.6.7 to document this addition. A metadata file for the newly added script is introduced, and the package version in package.json is incremented accordingly.

Changes

File(s) Change Summary
CHANGELOG.md Added a new section for version 0.6.7 dated 2025-04-07, introducing the UnityObjectExtensions feature.
Runtime/UnityObjectsExtensions.cs
Runtime/.../UnityObjectsExtensions.cs.meta
Introduced a new file implementing a static class UnityObjectsExtensions with extension methods: GetLocalCornersArray, GetWorldCornersArray, and RaycastPoint; accompanied by its metadata file.
package.json Updated the package version from "0.6.6" to "0.6.7".

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant RT as RectTransform
    participant Ext as UnityObjectsExtensions

    Dev->>RT: Call GetWorldCornersArray()
    RT->>Ext: Invoke GetLocalCornersArray() to compute local corners
    Ext-->>RT: Return local corners array
    Ext->>RT: Transform corners using localToWorldMatrix
    RT-->>Dev: Return world corners array
Loading
sequenceDiagram
    participant Dev as Developer
    participant GR as GraphicRaycaster
    participant Ext as UnityObjectsExtensions

    Dev->>GR: Call RaycastPoint(screenPoint)
    GR->>Ext: Create PointerEventData for the raycast
    Ext->>GR: Perform raycast and populate results list
    GR-->>Dev: Return raycast result (boolean) and results list
Loading

Poem

I'm a rabbit in the code field, hopping with glee,
New extensions bloom, as fresh as can be.
Corners align and raycasts take flight,
In version 0.6.7, everything feels just right.
With every leap, I cheer this new day,
A code-hopping joy in the most delightful way!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Apr 7, 2025

Image description CodeRabbit


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 740ad1a and 03acac6 commits.
Files selected (2)
  • CHANGELOG.md (1)
  • Runtime/UnityObjectsExtensions.cs (1)
Files ignored due to filter (2)
  • Runtime/UnityObjectsExtensions.cs.meta
  • package.json
Files not summarized due to errors (2)
  • Runtime/UnityObjectsExtensions.cs (nothing obtained from openai)
  • CHANGELOG.md (nothing obtained from openai)
Files not reviewed due to errors (2)
  • CHANGELOG.md (no response)
  • Runtime/UnityObjectsExtensions.cs (no response)
Review comments generated (0)
  • Review: 0
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 740ad1a and 03acac6.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • Runtime/UnityObjectsExtensions.cs (1 hunks)
  • Runtime/UnityObjectsExtensions.cs.meta (1 hunks)
  • package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: review
🔇 Additional comments (4)
Runtime/UnityObjectsExtensions.cs.meta (1)

1-11: LGTM!

The meta file is correctly formatted with all required fields for Unity to track this new asset.

Runtime/UnityObjectsExtensions.cs (1)

6-8: Good use of nullable reference types and suppression directive

Enabling nullable reference types enhances type safety, and the ReSharper directive appropriately addresses namespace organization.

package.json (1)

5-5: LGTM!

Version increment follows semantic versioning properly for a feature addition.

CHANGELOG.md (1)

7-11: LGTM!

The changelog entry follows the established format and properly documents the new feature.

Comment on lines +19 to +34
public static Vector3[] GetLocalCornersArray(this RectTransform transform)
{
var corners = new Vector3[4];
var rect = transform.rect;
var x = rect.x;
var y = rect.y;
var xMax = rect.xMax;
var yMax = rect.yMax;

corners[0] = new Vector3(x, y, 0f);
corners[1] = new Vector3(x, yMax, 0f);
corners[2] = new Vector3(xMax, yMax, 0f);
corners[3] = new Vector3(xMax, y, 0f);

return corners;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add null parameter validation

The extension method should validate the transform parameter to avoid NullReferenceException.

public static Vector3[] GetLocalCornersArray(this RectTransform transform)
{
+   if (transform == null)
+   {
+       throw new System.ArgumentNullException(nameof(transform));
+   }
    
    var corners =  new Vector3[4];
    var rect = transform.rect;
    var x = rect.x;
    var y = rect.y;
    var xMax = rect.xMax;
    var yMax = rect.yMax;

    corners[0] = new Vector3(x, y, 0f);
    corners[1] = new Vector3(x, yMax, 0f);
    corners[2] = new Vector3(xMax, yMax, 0f);
    corners[3] = new Vector3(xMax, y, 0f);

    return corners;
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static Vector3[] GetLocalCornersArray(this RectTransform transform)
{
var corners = new Vector3[4];
var rect = transform.rect;
var x = rect.x;
var y = rect.y;
var xMax = rect.xMax;
var yMax = rect.yMax;
corners[0] = new Vector3(x, y, 0f);
corners[1] = new Vector3(x, yMax, 0f);
corners[2] = new Vector3(xMax, yMax, 0f);
corners[3] = new Vector3(xMax, y, 0f);
return corners;
}
public static Vector3[] GetLocalCornersArray(this RectTransform transform)
{
if (transform == null)
{
throw new System.ArgumentNullException(nameof(transform));
}
var corners = new Vector3[4];
var rect = transform.rect;
var x = rect.x;
var y = rect.y;
var xMax = rect.xMax;
var yMax = rect.yMax;
corners[0] = new Vector3(x, y, 0f);
corners[1] = new Vector3(x, yMax, 0f);
corners[2] = new Vector3(xMax, yMax, 0f);
corners[3] = new Vector3(xMax, y, 0f);
return corners;
}

Comment on lines +39 to +49
public static Vector3[] GetWorldCornersArray(this RectTransform transform)
{
var corners = transform.GetLocalCornersArray();
var matrix4x = transform.localToWorldMatrix;
for (int i = 0; i < 4; i++)
{
corners[i] = matrix4x.MultiplyPoint(corners[i]);
}

return corners;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve variable naming and add null validation

The variable matrix4x could have a more descriptive name, and null validation should be added.

public static Vector3[] GetWorldCornersArray(this RectTransform transform)
{
+   if (transform == null)
+   {
+       throw new System.ArgumentNullException(nameof(transform));
+   }
    
    var corners = transform.GetLocalCornersArray();
-   var matrix4x = transform.localToWorldMatrix;
+   var worldMatrix = transform.localToWorldMatrix;
    for (int i = 0; i < 4; i++)
    {
-       corners[i] = matrix4x.MultiplyPoint(corners[i]);
+       corners[i] = worldMatrix.MultiplyPoint(corners[i]);
    }

    return corners;
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static Vector3[] GetWorldCornersArray(this RectTransform transform)
{
var corners = transform.GetLocalCornersArray();
var matrix4x = transform.localToWorldMatrix;
for (int i = 0; i < 4; i++)
{
corners[i] = matrix4x.MultiplyPoint(corners[i]);
}
return corners;
}
public static Vector3[] GetWorldCornersArray(this RectTransform transform)
{
if (transform == null)
{
throw new System.ArgumentNullException(nameof(transform));
}
var corners = transform.GetLocalCornersArray();
var worldMatrix = transform.localToWorldMatrix;
for (int i = 0; i < 4; i++)
{
corners[i] = worldMatrix.MultiplyPoint(corners[i]);
}
return corners;
}

Comment on lines +55 to +68
public static bool RaycastPoint(this GraphicRaycaster raycaster, Vector2 screenPoint, out List<RaycastResult> results)
{
var eventData = new PointerEventData(EventSystem.current)
{
position = screenPoint,
displayIndex = 0
};

results = new List<RaycastResult>();

raycaster.Raycast(eventData, results);

return results.Count > 0;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Check for null EventSystem.current

The method assumes EventSystem.current is not null, which might cause a NullReferenceException if no event system exists in the scene.

public static bool RaycastPoint(this GraphicRaycaster raycaster, Vector2 screenPoint, out List<RaycastResult> results)
{
+   if (raycaster == null)
+   {
+       throw new System.ArgumentNullException(nameof(raycaster));
+   }
+   
+   if (EventSystem.current == null)
+   {
+       results = new List<RaycastResult>();
+       return false;
+   }
    
    var eventData = new PointerEventData(EventSystem.current)
    {
        position = screenPoint,
        displayIndex = 0
    };

    results = new List<RaycastResult>();

    raycaster.Raycast(eventData, results);

    return results.Count > 0;
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static bool RaycastPoint(this GraphicRaycaster raycaster, Vector2 screenPoint, out List<RaycastResult> results)
{
var eventData = new PointerEventData(EventSystem.current)
{
position = screenPoint,
displayIndex = 0
};
results = new List<RaycastResult>();
raycaster.Raycast(eventData, results);
return results.Count > 0;
}
public static bool RaycastPoint(this GraphicRaycaster raycaster, Vector2 screenPoint, out List<RaycastResult> results)
{
if (raycaster == null)
{
throw new System.ArgumentNullException(nameof(raycaster));
}
if (EventSystem.current == null)
{
results = new List<RaycastResult>();
return false;
}
var eventData = new PointerEventData(EventSystem.current)
{
position = screenPoint,
displayIndex = 0
};
results = new List<RaycastResult>();
raycaster.Raycast(eventData, results);
return results.Count > 0;
}

@CoderGamester CoderGamester merged commit 4182bdc into master Apr 7, 2025
4 checks passed
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.

1 participant