default parameters cause Editor error

Forums 💬 NodeCanvas ⚙️ Support default parameters cause Editor error

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18912
    michael_pm
    Participant

      Hi, I just bought and imported NodeCanvas, so latest version. I am not clear where I can check which version it is. This is a similar issue to what is reported with nullable float (http://nodecanvas.com/forums/topic/issue-with-nullable-float), but has to do with Action nodes calling script functions that take default parameters in C#. I have a function RequestPath(Vector2 target, float priority = 0). If I add an action node to call that the editor barfs in the reflection code. Call stack below. If I remove the default 0 for priority everything works fine.

      InvalidCastException: Cannot cast from source type to destination type.
      ParadoxNotion.Design.EditorUtils.GenericField (System.String name, System.Object value, System.Type t, System.Reflection.MemberInfo member, System.Object instance) (at Assets/NodeCanvas/Framework/_ParadoxNotion (shared)/Design/PartialEditor/EditorUtils/EditorUtils_GUI.cs:283)
      ParadoxNotion.Design.EditorUtils.BBParameterField (System.String prefix, NodeCanvas.Framework.BBParameter bbParam, Boolean blackboardOnly, System.Reflection.MemberInfo member) (at Assets/NodeCanvas/Framework/_ParadoxNotion (shared)/Design/PartialEditor/EditorUtils/EditorUtils_BBParameterEditor.cs:38)
      NodeCanvas.Tasks.Actions.ExecuteFunction_Multiplatform.OnTaskInspectorGUI () (at Assets/NodeCanvas/Tasks/Actions/ScriptControl/Multiplatform/ExecuteFunction_Multiplatform.cs:155)
      NodeCanvas.Framework.Task.ShowTaskInspectorGUI (NodeCanvas.Framework.Task task, System.Action1 callback, Boolean showTitlebar) (at Assets/NodeCanvas/Framework/Design/PartialEditor/EDITOR_Task.cs:63)
      ParadoxNotion.Design.EditorUtils.TaskField (NodeCanvas.Framework.Task task, ITaskSystem ownerSystem, System.Type baseType, System.Action
      1 callback) (at Assets/NodeCanvas/Framework/_ParadoxNotion (shared)/Design/PartialEditor/EditorUtils/EditorUtils_TaskFieldEditor.cs:31)
      NodeCanvas.Framework.Node.TaskAssignableGUI () (at Assets/NodeCanvas/Framework/Design/PartialEditor/EDITOR_Node.cs:623)
      NodeCanvas.Framework.Node.ShowNodeInspectorGUI () (at Assets/NodeCanvas/Framework/Design/PartialEditor/EDITOR_Node.cs:602)
      NodeCanvas.Editor.ExternalInspectorWindow.OnGUI () (at Assets/NodeCanvas/Framework/Design/Editor/Windows/ExternalInspectorWindow.cs:58)
      System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

      #18914
      michael_pm
      Participant

        I am using NodeCanvas 2.3.8. Sorry, its hard to see/read since its black relief on a dark background.

        #18913
        Gavalakis
        Keymaster

          Hello,

          Please specify that the default parameter is a float, by adding literal f at the end and it will work 🙂
          RequestPath(Vector2 target, float priority = 0f)

          Cheers!

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.