Skip to content

Conversation

@Szczyrk
Copy link
Collaborator

@Szczyrk Szczyrk commented Sep 26, 2024

No description provided.

// Initialize the component
private void Awake()
{
_rectTransform = GetComponent<RectTransform>();
Copy link
Contributor

Choose a reason for hiding this comment

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

What if RectTransform component cannot be found? There should be an error here if that happens, explaining exactly why it happened.

Copy link
Contributor

Choose a reason for hiding this comment

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

And if, the current component should be disabled to not print any more errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If RectTransform is not found, the script now:

  • Logs an error explaining the issue.
  • Disables itself (enabled = false) to prevent further errors and repeated logging.

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