public void AppendBindingFromObject(InputBinding binding) { InputActionSerializationHelpers.AppendBindingFromObject(binding, elementProperty, m_ActionMapProperty); }
public void AppendBindingFromObject(Dictionary <string, string> values) { InputActionSerializationHelpers.AppendBindingFromObject(values, elementProperty, m_ActionMapProperty); }
public void HandlePasteEvent() { var json = EditorGUIUtility.systemCopyBuffer; var elements = json.Split(new[] { kInputAssetMarker }, StringSplitOptions.RemoveEmptyEntries); if (!json.StartsWith(kInputAssetMarker)) { return; } for (var i = 0; i < elements.Length; i++) { var row = elements[i]; if (IsRowOfType <ActionMapTreeItem>(ref row)) { var map = JsonUtility.FromJson <InputActionMap>(row); InputActionSerializationHelpers.AddActionMapFromObject(m_Window.m_SerializedObject, map); m_Window.Apply(); continue; } if (IsRowOfType <ActionTreeItem>(ref row)) { var action = JsonUtility.FromJson <InputAction>(row); var actionMap = m_TreeView.GetSelectedActionMap(); var newActionProperty = InputActionSerializationHelpers.AddActionFromObject(action, actionMap.elementProperty); m_Window.Apply(); while (i + 1 < elements.Length) { try { var nextRow = elements[i + 1]; if (!nextRow.StartsWith(typeof(BindingTreeItem).Name)) { break; } nextRow = nextRow.Substring(typeof(BindingTreeItem).Name.Length); var binding = JsonUtility.FromJson <InputBinding>(nextRow); InputActionSerializationHelpers.AppendBindingFromObject(binding, newActionProperty, actionMap.elementProperty); m_Window.Apply(); i++; } catch (ArgumentException e) { Debug.LogException(e); break; } } continue; } if (IsRowOfType <BindingTreeItem>(ref row) || IsRowOfType <CompositeGroupTreeItem>(ref row) || IsRowOfType <CompositeTreeItem>(ref row)) { var binding = JsonUtility.FromJson <InputBinding>(row); var selectedRow = m_TreeView.GetSelectedAction(); if (selectedRow == null) { EditorApplication.Beep(); continue; } var actionMap = m_TreeView.GetSelectedActionMap(); InputActionSerializationHelpers.AppendBindingFromObject(binding, selectedRow.elementProperty, actionMap.elementProperty); m_Window.Apply(); continue; } } }
private void HandlePasteEvent() { var copyBufferString = EditorGUIUtility.systemCopyBuffer; var elements = copyBufferString.Split(new[] { k_InputAssetMarker }, StringSplitOptions.RemoveEmptyEntries); if (!copyBufferString.StartsWith(k_InputAssetMarker)) { return; } SerializedProperty currentActionMapProperty = null; var selectedActionMap = m_TreeView.GetSelectedActionMap(); if (selectedActionMap != null) { currentActionMapProperty = selectedActionMap.elementProperty; } for (var i = 0; i < elements.Length; i++) { var row = elements[i]; if (IsRowOfType <ActionMapTreeItem>(ref row)) { if (m_SerializedObject == null) { throw new InvalidOperationException("Pasting action map is not a valid operation"); } currentActionMapProperty = InputActionSerializationHelpers.AddActionMapFromObject(m_SerializedObject, GetParameterDictionary(row)); m_Apply(); continue; } if (IsRowOfType <ActionTreeItem>(ref row)) { var newActionProperty = InputActionSerializationHelpers.AddActionFromObject(GetParameterDictionary(row), currentActionMapProperty); while (i + 1 < elements.Length) { try { var nextRow = elements[i + 1]; if (nextRow.StartsWith(typeof(BindingTreeItem).Name)) { nextRow = nextRow.Substring(typeof(BindingTreeItem).Name.Length); } else if (nextRow.StartsWith(typeof(CompositeGroupTreeItem).Name)) { nextRow = nextRow.Substring(typeof(CompositeGroupTreeItem).Name.Length); } else if (nextRow.StartsWith(typeof(CompositeTreeItem).Name)) { nextRow = nextRow.Substring(typeof(CompositeTreeItem).Name.Length); } else { break; } InputActionSerializationHelpers.AppendBindingFromObject(GetParameterDictionary(nextRow), newActionProperty, currentActionMapProperty); i++; } catch (ArgumentException e) { Debug.LogException(e); break; } } m_Apply(); continue; } if (IsRowOfType <BindingTreeItem>(ref row) || IsRowOfType <CompositeGroupTreeItem>(ref row) || IsRowOfType <CompositeTreeItem>(ref row)) { var selectedRow = m_TreeView.GetSelectedAction(); if (selectedRow == null) { EditorApplication.Beep(); continue; } selectedRow.AppendBindingFromObject(GetParameterDictionary(row)); m_Apply(); continue; } } }