public override void OnInspectorGUI() { serializedObject.Update(); if (!serializedObject.isEditingMultipleObjects) { VJGamepadDataSource src = target as VJGamepadDataSource; if (src.sourceName == null || src.sourceName.Length == 0) { src.sourceName = VJGamePadButtonUtility.GetButtonNameOf(src.button); EditorUtility.SetDirty(src); } } else { foreach (UnityEngine.Object o in targets) { VJGamepadDataSource src = o as VJGamepadDataSource; if (src.sourceName == null || src.sourceName.Length == 0) { src.sourceName = VJGamePadButtonUtility.GetButtonNameOf(src.button); EditorUtility.SetDirty(src); } } } base.OnInspectorGUI(); if (GUI.changed) { sourceNameProperty.stringValue = VJGamePadButtonUtility.GetButtonNameOf((VJGamepadButton)buttonProperty.enumValueIndex); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { VJGamepadDataSource src = target as VJGamepadDataSource; if (src.sourceName == null || src.sourceName.Length == 0) { src.sourceName = VJGamePadButtonUtility.GetButtonNameOf(src.button); EditorUtility.SetDirty(target); } base.OnInspectorGUI(); if (GUI.changed) { src.sourceName = VJGamePadButtonUtility.GetButtonNameOf(src.button); EditorUtility.SetDirty(target); } }
// Update is called once per frame public void Update() { float raw_current = 0.0f; switch (VJGamePadButtonUtility.GetButtonTypeOf(button)) { case VJGamePadButtonType.Type_Analog: float analogInput = Input.GetAxis(VJGamePadButtonUtility.GetSemanticOf(button)); // trigger goes to -1.0f when released after press. if (button == VJGamepadButton.Trigger_L || button == VJGamepadButton.Trigger_R) { analogInput = Mathf.Max(0.0f, analogInput); } raw_current = value * boost * analogInput; break; case VJGamePadButtonType.Type_Digital: if (Input.GetKey(VJGamePadButtonUtility.GetKeyCodeOf(button))) { // if( Input.GetButton(VJGamePadButtonUtility.GetSemanticOf(button)) ) { raw_current = value * boost; } break; } // if( Input.GetKey(VJGamePadButtonUtility.GetKeyCodeOf(button)) ) { // raw_current = value * boost; // } // if( Input.GetKey(VJGamePadButtonUtility.GetKeyCodeOf(button)) ) { // raw_current = value * boost; // } previous = current; current = raw_current; diff = current - previous; }