Hi,
is there someone here that have managed to get delegates to work in an editor extension
Thanx
Hi,
is there someone here that have managed to get delegates to work in an editor extension
Thanx
Can you be more specific?
i’m trying to use delegates to communicate between two editor extensions,
i have a spline draw update method, that gets called whenever i change the spline shape, i have put the delegate in that method and i subscribed to the delegate in the other extension,
problem is that delegate does not get called until i press play
How are you invoking the delegate? Are you using C# events, or just raw delegates?
Hi,
im using delegates and events
public class SplineCreationClass
{
public delegate void OnUpdate();
public static event OnUpdate Update_Spline;
public void Method_Get_Called_When_Spline_Edit()
{
if (Update_Spline != null) Update_Spline();
}
}
implementation in the other extension
private void OnEnable()
{
SplineCreationClass.Update_Spline += Update_Splines;
}
private void OnDisable()
{
SplineCreationClass.Update_Spline -= Update_Splines;
}
void Update_Splines()
{
Debug.Log("Delegate called");
}
Ok that looks alright - how are you invoking the method “Method_Get_Called_When_Spline_Edit”?
the method gets called whenever i edit a spline shape by moving the nodes in the editor,
i have even put a debug.log to make sure
public void Method_Get_Called_When_Spline_Edit()
{
Debug.Log("Method_Get_Called_When_Spline_Edit called");
if (Update_Spline != null) Update_Spline();
}
it is showed in the console but the delegate implementation debug.log does not show
void Update_Splines()
{
Debug.Log("Delegate called");
}
Have you ensured that OnEnable and OnDisable is getting called when you expect it to?
that was the issue, i did a stupid thing by adding the delegate implementation in the mono behaviour class,
the correct thing to do is to put it in the editor class instead, where on enable and on disable gets called in the editor
thanx alot