Skip to content

Commit

Permalink
Removed janky workaround for re-initializing a graph after playmode i…
Browse files Browse the repository at this point in the history
…n exchange for a better solution. Fixes: [#23](#23)
  • Loading branch information
Doppelkeks committed May 9, 2023
1 parent 8bdd51c commit 613453d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed StackOverflow errors for GroupCommentNodes when they are stacked into each other [#20](https://github.com/Gentlymad-Studios/NewGraph/issues/20)
- Fixed wrong positioning of Nodes that are part of a GroupCommentNode [#21](https://github.com/Gentlymad-Studios/NewGraph/issues/21)
### Added
- Nodes are now only included in a GroupCommentNode if they are fully contained and not just overlapping [#22](https://github.com/Gentlymad-Studios/NewGraph/issues/22)
- Nodes are now only included in a GroupCommentNode if they are fully contained and not just overlapping [#22](https://github.com/Gentlymad-Studios/NewGraph/issues/22)

## [0.3.8] - 2023-05-09
### Fixed
- Removed janky workaround for re-initializing a graph after playmode in exchange for a better solution. Fixes: [#23](https://github.com/Gentlymad-Studios/NewGraph/issues/23)
16 changes: 2 additions & 14 deletions Editor/Views/GraphWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,12 @@ public static void InitializeWindowBase(Type windowType) {
}

private void OnEnable() {
EditorApplication.update -= EditorUpdate;
EditorApplication.playModeStateChanged -= LogPlayModeState;
EditorApplication.playModeStateChanged += LogPlayModeState;
GlobalKeyEventHandler.OnKeyEvent -= HandleGlobalKeyPressEvents;
GlobalKeyEventHandler.OnKeyEvent += HandleGlobalKeyPressEvents;
}

private void EditorUpdate() {
LoadGraph();
EditorApplication.update -= EditorUpdate;
}

private void HandleGlobalKeyPressEvents(Event evt) {
if (evt.isKey && mouseOverWindow == this && hasFocus) {
if (lastKeyCode != evt.keyCode || lastModifiers != evt.modifiers) {
Expand All @@ -114,15 +108,9 @@ private void HandleGlobalKeyPressEvents(Event evt) {
public void LogPlayModeState(PlayModeStateChange state) {
if (state == PlayModeStateChange.ExitingPlayMode) {
graphController?.EnsureSerialization();

} else if (state == PlayModeStateChange.EnteredEditMode) {
EditorApplication.update -= EditorUpdate;
EditorApplication.update += EditorUpdate;
if (window != null) {
window.Close();
}

}else if (state == PlayModeStateChange.EnteredPlayMode) {
LoadGraph();
} else if (state == PlayModeStateChange.EnteredPlayMode) {
graphController?.Reload();
}
}
Expand Down
4 changes: 3 additions & 1 deletion Models/MonoGraphModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public void CreateSerializedObject() {
}

public void ForceSerializationUpdate() {
baseModel.ForceSerializationUpdate(this);
if (this != null) {
baseModel.ForceSerializationUpdate(this);
}
}

public SerializedProperty GetLastAddedNodeProperty(bool isUtilityNode) {
Expand Down
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.3.7",
"version": "0.3.8",
"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.2",
Expand Down

0 comments on commit 613453d

Please sign in to comment.