Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding OnSwitch event via Script
#1
Hello, I am struggling with adding an OnSwitch event to my Spline Controller via script.

what i tried :
Code:
  private void Init()
        {
        

            CurvySplineMoveEvent curvySplineMoveEvent = new CurvySplineMoveEvent();
            curvySplineMoveEvent.AddListener(OnSwitch);

            controller = gameObject.AddComponent<SplineController>();
            controller.OnSwitch = curvySplineMoveEvent;

        }

        private void OnSwitch(CurvySplineMoveEventArgs args)
        {
            Debug.Log("switch!");
        }
Reply
#2
Hi
Here is how to do it:
controller.OnSwitch.AddListener(EventHandler);
with EventHandler being a method with the following signature:
void EventHandler (CurvySplineMoveEventArgs argument)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Thank you.
I tried it that way and my method didn't get called, the OnEndReached method however gets called.

Did I missunderstood it? I thought if you have 2 Splines connected OnSwitch would get called.
Reply
#4
Sorry, that's not when that event is raised. Here is the corrected documentation that hopefully will avoid confusion.
"Event raised while switching splines. Splines switching is done via the SwitchTo method."
If you want to know if a controller reached a connection, use the OnCPReached, and check in it if the reached CP has a Connection (controlPoint.Connection)
Did this help?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CurvySpline Editor event ATHellboy 1 952 03-08-2020, 01:51 PM
Last Post: _Aka_
  Change default settings when adding a point UsernameHed 3 2,029 07-31-2019, 11:03 AM
Last Post: _Aka_
  Adding a Control point Not working as espected UsernameHed 1 1,679 05-19-2019, 01:43 PM
Last Post: _Aka_
  Script inheriting SplineController doesn't work the same as adding component? clearleaf 1 1,556 04-28-2019, 12:41 PM
Last Post: _Aka_

Forum Jump: