I am following the “Contact Samples” pattern mission that comes with the “enter system” package deal.
In one of many pattern scene, there’s a script that defines a customized composite Binding (for instance the 2D vector composite).
I am virtually rewriting the identical scripts besides altering some inputs to be added to the composite, nevertheless it’s throwing me these errors, and since I am comparatively new to writing code do not know how you can start fixing the problem. The handbook and the scripting API aren’t any assist both.
that is the instance Script that provides a customized composite.
utilizing UnityEngine;
utilizing UnityEngine.InputSystem;
utilizing UnityEngine.InputSystem.Layouts;
utilizing UnityEngine.InputSystem.Utilities;
#if UNITY_EDITOR
utilizing UnityEditor;
#endif
namespace InputSamples.Drawing
{
///
/// Easy object to include data for drag inputs.
///
public struct PointerInput
{
public bool Contact;
///
/// ID of enter kind.
///
public int InputId;
///
/// Place of draw enter.
///
public Vector2 Place;
///
/// Orientation of draw enter pen.
///
public Vector2? Tilt;
///
/// Strain of draw enter.
///
public float? Strain;
///
/// Radius of draw enter.
///
public Vector2? Radius;
///
/// Twist of draw enter.
///
public float? Twist;
}
// What we do in PointerInputManager is to easily create a separate motion for every enter we'd like for PointerInput.
// This right here exhibits a potential various that sources all inputs as a single worth utilizing a composite. Has professionals
// and cons. Largest professional is that each one the controls actuate collectively and ship one enter worth.
//
// NOTE: In PointerControls, we're binding mouse and pen individually from contact. If we did not care about multitouch,
// we would not must to that however might somewhat simply bind `/place` and so on. Nevertheless, to supply every contact
// as its personal separate PointerInput supply, we have to have a number of PointerInputComposites.
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
public class PointerInputComposite : InputBindingComposite
{
[InputControl(layout = "Button")]
public int contact;
[InputControl(layout = "Vector2")]
public int place;
[InputControl(layout = "Vector2")]
public int tilt;
[InputControl(layout = "Vector2")]
public int radius;
[InputControl(layout = "Axis")]
public int strain;
[InputControl(layout = "Axis")]
public int twist;
[InputControl(layout = "Integer")]
public int inputId;
public override PointerInput ReadValue(ref InputBindingCompositeContext context)
{
var contact = context.ReadValueAsButton(this.contact);
var pointerId = context.ReadValue(inputId);
var strain = context.ReadValue(this.strain);
var radius = context.ReadValue(this.radius);
var tilt = context.ReadValue(this.tilt);
var place = context.ReadValue(this.place);
var twist = context.ReadValue(this.twist);
return new PointerInput
{
Contact = contact,
InputId = pointerId,
Place = place,
Tilt = tilt != default ? tilt : (Vector2?)null,
Strain = strain > 0 ? strain : (float?)null,
Radius = radius.sqrMagnitude > 0 ? radius : (Vector2?)null,
Twist = twist > 0 ? twist : (float?)null,
};
}
#if UNITY_EDITOR
static PointerInputComposite()
{
Register();
}
#endif
[RuntimeInitializeOnLoadMethod]
non-public static void Register()
{
InputSystem.RegisterBindingComposite();
}
}
}
and that is my code for my customized composite:
utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
utilizing UnityEngine.InputSystem;
utilizing UnityEngine.InputSystem.Controls;
utilizing UnityEngine.InputSystem.Utilities;
utilizing UnityEngine.InputSystem.Layouts;
#if UNITY_EDITOR
utilizing UnityEditor;
#endif
public struct myPointerInput
{
public bool Press;
public int PressCount;
public Vector2 Place;
public Vector2 Delta;
public Vector2? Radius;
//contact particular
public bool? Faucet;
//public UnityEngine.InputSystem.TouchPhase? section;
public Vector2? StartPosition;
public float? StartTime;
//mouse Particular
public Vector2? Scroll;
}
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
public class MyPointerInput : InputBindingComposite
{
[InputControl(layout = "Button")]
public int press;
[InputControl(layout = "Integer")]
public int pressCount;
[InputControl(layout = "Vector2")]
public int place;
[InputControl(layout = "Vector2")]
public int delta;
[InputControl(layout = "Vector2")]
public int radius;
//contact particular
[InputControl(layout = "Button")]
public int faucet;
//[InputControl(layout = "TouchPhase")]
//public UnityEngine.InputSystem.TouchPhase section;
[InputControl(layout = "Vector2")]
public int startPosition;
[InputControl(layout = "Double")]
public int startTime;
//mouse Particular
[InputControl(layout = "Vector2")]
public int scroll;
public override myPointerInput ReadValue(ref InputBindingCompositeContext context)
{
var press = context.ReadValueAsButton(this.press);
var pressCount = context.ReadValue(this.pressCount);
var place = context.ReadValue(this.place);
var delta = context.ReadValue(this.delta);
var radius = context.ReadValue(this.radius);
var faucet = context.ReadValueAsButton(this.faucet);
//var section = context.ReadValue(this.section);
var startPosition = context.ReadValue(this.startPosition);
var startTime = context.ReadValue(this.startTime);
var scroll = context.ReadValue(this.scroll);
return new myPointerInput
{
Press = press,
PressCount = pressCount,
Place = place,
Delta = delta,
Radius = radius.sqrMagnitude > 0 ? radius : (Vector2?)null,
//Faucet = faucet,
StartPosition = startPosition,
StartTime = startTime,
Scroll = scroll
};
}
#if UNITY_EDITOR
static MyPointerInput()
{
Register();
}
#endif
[RuntimeInitializeOnLoadMethod]
non-public static void Register()
{
InputSystem.RegisterBindingComposite();
}
}
these are the errors in Textual content type:
ArgumentException: Do not know how you can convert PrimitiveValue to 'Object'
Parameter title: kind
UnityEngine.InputSystem.Utilities.PrimitiveValue.ConvertTo (System.TypeCode kind) (at Library/PackageCache/[email protected]/InputSystem/Utilities/PrimitiveValue.cs:227)
UnityEngine.InputSystem.Utilities.NamedValue.ConvertTo (System.TypeCode kind) (at Library/PackageCache/[email protected]/InputSystem/Utilities/NamedValue.cs:28)
UnityEngine.InputSystem.Editor.Lists.ParameterListView.Initialize (System.Kind registeredType, UnityEngine.InputSystem.Utilities.ReadOnlyArray`1[TValue] existingParameters) (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/ParameterListView.cs:146)
UnityEngine.InputSystem.Editor.InputBindingPropertiesView.InitializeCompositeProperties () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs:194)
UnityEngine.InputSystem.Editor.InputBindingPropertiesView.DrawGeneralProperties () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs:69)
UnityEngine.InputSystem.Editor.PropertiesViewBase.DrawGeneralGroup () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/PropertiesViewBase.cs:59)
UnityEngine.InputSystem.Editor.PropertiesViewBase.OnGUI () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/PropertiesViewBase.cs:39)
UnityEngine.InputSystem.Editor.InputActionEditorWindow.DrawPropertiesColumn (System.Single width) (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs:699)
UnityEngine.InputSystem.Editor.InputActionEditorWindow.OnGUI () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs:637)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo tradition) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the goal of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo tradition) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.DockArea.OldOnGUI () (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Occasion evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Motion onGUIHandler, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
GUI Error: You're pushing extra GUIClips than you're popping. Be certain they're balanced.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
ArgumentException: Getting management 1's place in a bunch with just one controls when doing repaint
Aborting
UnityEngine.GUILayoutGroup.GetNext () (at <817eebdd70f8402280b9cb11fff8b976>:0)
UnityEngine.GUILayoutUtility.DoGetRect (System.Single minWidth, System.Single maxWidth, System.Single minHeight, System.Single maxHeight, UnityEngine.GUIStyle fashion, UnityEngine.GUILayoutOption[] choices) (at <817eebdd70f8402280b9cb11fff8b976>:0)
UnityEngine.GUILayoutUtility.GetRect (System.Single minWidth, System.Single maxWidth, System.Single minHeight, System.Single maxHeight, UnityEngine.GUIStyle fashion, UnityEngine.GUILayoutOption[] choices) (at <817eebdd70f8402280b9cb11fff8b976>:0)
UnityEditor.EditorGUILayout.GetControlRect (System.Boolean hasLabel, System.Single peak, UnityEngine.GUIStyle fashion, UnityEngine.GUILayoutOption[] choices) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.EditorGUILayout.Popup (UnityEngine.GUIContent label, System.Int32 selectedIndex, UnityEngine.GUIContent[] displayedOptions, UnityEngine.GUIStyle fashion, UnityEngine.GUILayoutOption[] choices) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.EditorGUILayout.Popup (UnityEngine.GUIContent label, System.Int32 selectedIndex, UnityEngine.GUIContent[] displayedOptions, UnityEngine.GUILayoutOption[] choices) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEngine.InputSystem.Editor.InputBindingPropertiesView.DrawGeneralProperties () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs:72)
UnityEngine.InputSystem.Editor.PropertiesViewBase.DrawGeneralGroup () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/PropertiesViewBase.cs:59)
UnityEngine.InputSystem.Editor.PropertiesViewBase.OnGUI () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/PropertiesViewBase.cs:39)
UnityEngine.InputSystem.Editor.InputActionEditorWindow.DrawPropertiesColumn (System.Single width) (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs:699)
UnityEngine.InputSystem.Editor.InputActionEditorWindow.OnGUI () (at Library/PackageCache/[email protected]/InputSystem/Editor/AssetEditor/InputActionEditorWindow.cs:637)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo tradition) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the goal of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo tradition) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.DockArea.OldOnGUI () (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Occasion evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Motion onGUIHandler, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Occasion e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Motion onGUIHandler, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.IMGUIContainer.DoIMGUIRepaint () (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.UIR.RenderChainCommand.ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams drawParams, System.Boolean straightY, System.Single pixelsPerPoint, System.Exception& immediateException) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
Rethrow as ImmediateModeException
UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect viewport, UnityEngine.Matrix4x4 projection, UnityEngine.UIElements.PanelClearFlags clearFlags) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect viewport, UnityEngine.Matrix4x4 projection) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.UIRRepaintUpdater.Replace () (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase section) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.Panel.UpdateForRepaint () (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Occasion e) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <817eebdd70f8402280b9cb11fff8b976>:0)
