- Home /
Help needed: repairing the Spline Controller Script
This code seems outdated:
http://www.unifycommunity.com/wiki/index.php?title=Spline_Controller
Is there anybody skilled enough to fix it or is there a fix somewhere available?
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all UnityEngine.MonoBehaviour:.ctor() UnityEngine.MonoBehaviour:.ctor() SplineInterpolator:.ctor() (at Assets\AI\SplineController\SplineInterpolator.js:1) SplineController:OnDrawGizmos() (at Assets\AI\SplineController\SplineController.js:24) UnityEditor.Handles:Internal_DrawBuiltinGizmos() UnityEditor.Handles:Internal_DrawBuiltinGizmos() UnityEditor.Handles:DrawBuiltinGizmos() UnityEditor.SceneView:OnGUI() System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) UnityEditor.HostView:Invoke(String) UnityEditor.DockArea:OnGUI()
[....\Runtime\Export\Generated\BaseClass.cpp line 1029]
Answer by Eric5h5 · Mar 03, 2010 at 09:30 PM
Change the line in SplineController.js from
var interp = new SplineInterpolator();
to
var interp = gameObject.AddComponent(SplineInterpolator);
This gets rid of the warning, but then a ton of SplineInterpolators get added to the game object, so add
DestroyImmediate(interp);
to the end of the OnDrawGizmos function.