Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Example or more thorough documentation regarding events anywhere? #81

Closed
snarlynarwhal opened this issue Jun 28, 2016 · 5 comments
Closed

Comments

@snarlynarwhal
Copy link

I'm using the Node Editor as tool to modify/move/add/remove components in the Editor (not in play mode). I'd imagine that I want to use the NodeEditorCallbacks class and not the NodeEditorCallbackReceiver one. I understand how to implement the second method, but not the prior. Any examples anywhere?

@Seneral
Copy link
Owner

Seneral commented Jun 29, 2016

You need to build a 3rd editor script anywhere that subscribes to these events. So you'd do NodeEditorFramework.NodeEditorCallbacks.OnNodeMove += MyCallbackMethod
Hope that helps!

@snarlynarwhal
Copy link
Author

snarlynarwhal commented Jun 29, 2016

I can't seem to get it working, here's my code:

image

I added a Debug.Log in the OnEnable function, but got nothing. o.0 I haven't dealt with subscribing or delegates before, and have dabbled very little in editor scripts so I'm a novice to this.

ps - I owe you for all the help. So I'll definitely be contributing a feature or two to the project soon. :)

@snarlynarwhal
Copy link
Author

snarlynarwhal commented Jun 29, 2016

Finally got it working but adding this line:

[CustomEditor(typeof(MachineNode))]

However, it keeps adding the connection OnEnable (duh). I added a static bool to track whether or not I've subscribed to the delegate. It appears to work fine! Or would there be a better place to subscribe?

@Seneral
Copy link
Owner

Seneral commented Jun 29, 2016

Sorry, was unavailable. Yes for it to execute you need to make it a custom editor (in this case).

For delegates, I tend to first unsubscribe (-=) and then subscribe (+=). If you haven't subsribed before it will do nothing but if you did you won't have duplicate subscribers:)

@snarlynarwhal
Copy link
Author

No worries! And ahh got it thanks! :D

@Seneral Seneral closed this as completed Jul 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants