Skip to content

Commit

Permalink
- edit button is now a real button instead of an image due to unity 6…
Browse files Browse the repository at this point in the history
…000 issues

- edit button in inspector is now working correctly after open the inspector again (removed unregister in detach event)
  • Loading branch information
XxmArKxX94 committed Feb 7, 2025
1 parent 89a80cb commit d27ce06
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.4.9] - 2025-01-24
### Changed
- node SetPosition will now edit the variable instead of the property

## [0.5.0] - 2025-02-07
### Changed
- edit button is now a real button instead of an image due to unity 6000 issues
- edit button in inspector is now working correctly after open the inspector again (removed unregister in detach event)
14 changes: 10 additions & 4 deletions Editor/Views/Elements/EditableLabelElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace NewGraph {
/// This is a converter for PropertyField elements, to convert a default Text/ string field into an editable label
/// </summary>
public class EditableLabelElement {
private Image editButton;
private Button editButton;
private Image editButtonImg;
private VisualElement inputField;
private TextField textField;
private VisualElement textElement;
Expand All @@ -19,6 +20,7 @@ public class EditableLabelElement {
private System.Action<string> onValueChange;
private System.Action onEditModeLeft;
private const string inputFieldUSSClass = "unity-base-text-field__input";
private const string editButtonUSSClass = "editButton";
private const string editIcon = "d_editicon.sml";
private Texture editIconTexture;
#if UNITY_6000_0_OR_NEWER
Expand Down Expand Up @@ -76,12 +78,16 @@ void DetachFromPanelEventTxtFld(DetachFromPanelEvent evt) {
inputField = textField[1];

textElement = inputField[0];
editButton = new Image() { image = editIconTexture };
editButtonImg = new Image() { image = editIconTexture };
editButton = new Button();
editButton.AddToClassList(editButtonUSSClass);
editButton.Add(editButtonImg);

editButton.RegisterCallback<ClickEvent>(OnEditButtonClick);

void DetachFromPanelEventEditBtn(DetachFromPanelEvent evt) {
editButton.UnregisterCallback<ClickEvent>(OnEditButtonClick);
//removed this, because the editor button in inspector isnt called anymore after the second time opening it
//editButton.UnregisterCallback<ClickEvent>(OnEditButtonClick);
editButton.UnregisterCallback<DetachFromPanelEvent>(DetachFromPanelEventEditBtn);
}
editButton.RegisterCallback<DetachFromPanelEvent>(DetachFromPanelEventEditBtn);
Expand Down Expand Up @@ -123,7 +129,7 @@ public void EnableInput(bool enable = true) {
if (isInitialized) {
if (enable != isInEditMode) {
isInEditMode = enable;
editButton.image = isInEditMode ? closeIconTexture : editIconTexture;
editButtonImg.image = isInEditMode ? closeIconTexture : editIconTexture;
}

// prevent selection if the field is currently disabled
Expand Down
6 changes: 6 additions & 0 deletions Editor/Views/USS/NewGraph.uss
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,9 @@ NodeView.CommentNode VisualElement.GroupCommentNodeContainer *{
opacity: 0.5;
cursor: pan;
}

.editButton {
border-width: 0;
background-color: rgba(0,0,0,0);
align-self: Center;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.gentlymad.newgraph",
"version": "0.4.9",
"version": "0.5.0",
"displayName": "NewGraph",
"description": "A general data oriented node graph solution. This is build upon the idea to visualize complex data structures as graph networks without having to modify already established data classes, except adding [Node], [Port] and [SerializeReference] attributes to call classes that should show in the Graph View.",
"unity": "2022.3",
Expand Down

0 comments on commit d27ce06

Please sign in to comment.