-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactored actions logic into it's own component #25
Conversation
private DebugMenuItemNode rootNode; | ||
private DebugMenuItemNode currentPageNode; | ||
|
||
private void Awake() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't get the awake call right away since this object is disabled to begin with, we must manually initialize it
Scripts/DebugMenu.cs
Outdated
@@ -59,19 +57,22 @@ public static DebugMenu Instance | |||
private Button actionButtonTemplate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be removed as it was moved to the other file
|
||
if (ButtonPathExists(path)) | ||
{ | ||
throw new Exception($"Cannot add button at {path}. A button/folder already exists!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent with previous two lines (one line throw).
|
||
if (!ButtonPathExists(path)) | ||
{ | ||
throw new Exception($"Cannot remove the button {path}. It does not exist."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. Inconsistent with the previous line (one line throw).
{ | ||
if (currentNode.ContainsChild(part)) | ||
{ | ||
currentNode = currentNode.GetChild(part); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it faster if you just GetChild
then do a null check, rather than check ContainsChild
first then GetChild
?
{ | ||
var backButton = Instantiate(actionButtonTemplate, actionButtonTemplate.transform.parent, false); | ||
backButton.GetComponentInChildren<Text>().text = $"{backCharacter} Back"; | ||
backButton.onClick.AddListener(() => { SetupPage(node.Parent); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor:
You can do backButton.onClick.AddListener(() => SetupPage(node.Parent));
} | ||
|
||
var label = actionButton.GetComponentInChildren<Text>(); | ||
label.text = button.Name + (button.IsFolder ? $" {folderArrowCharacter}" : ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer string.Empty
over ""
, for me it adds intent to it so I know its not a mistake.
label.text = button.Name + (button.IsFolder ? $" {folderArrowCharacter}" : ""); | ||
actionButton.gameObject.SetActive(true); | ||
|
||
firstChild = (firstChild != null) ? firstChild : actionButton.gameObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parenthesis are redundent
currentNode.AddFolder(part); | ||
} | ||
} | ||
actionsPage.AddButton(path, action,hideDebugMenuOnClick); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a space after the second comma
Resolves issue #22
Key points: