Change game object on script C#

Hi, i have a game object called “SplineRootSlide”, and on a script i use it like it shows on image attached

What i want to know is how to change that gameobject “SplineRootSlide” to another trought c# code.
Lets suppouse other called SplineRootSlide2


Well, to change it to something else, that ‘something else’ must be of type SplineRootSlide or a children of it (inherits it)

Assuming SplineRootSlide2 is a SplineRootSlide, you could just:

target.splineRoot = new SplineRootSlide2();


target.splineRoot = mySplineRootSlide2Variable;

By is a I meant:

public class SplineRootSlide2 : SplineRootSlide { /* ... */ }

Let me know if I didn’t get you right.