Exemplo n.º 1
0
        public static BindingTreeItem AddTo(TreeViewItem parent, SerializedProperty bindingProperty)
        {
            var item = new BindingTreeItem(bindingProperty);

            item.depth       = parent.depth + 1;
            item.displayName = item.displayPath;
            parent.AddChild(item);

            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add items for the bindings of just this action to the given parent tree item.
        /// </summary>
        public void AddBindingsTo(TreeViewItem parent)
        {
            var isSingleton           = actionMapProperty == null;
            var bindingsArrayProperty = isSingleton
                ? property.FindPropertyRelative("m_SingletonActionBindings")
                : actionMapProperty.FindPropertyRelative("m_Bindings");

            var bindingsCountInMap = bindingsArrayProperty.arraySize;
            var currentComposite   = (CompositeBindingTreeItem)null;

            for (var i = 0; i < bindingsCountInMap; ++i)
            {
                var bindingProperty = bindingsArrayProperty.GetArrayElementAtIndex(i);

                // Skip if binding is not for action.
                var actionProperty = bindingProperty.FindPropertyRelative("m_Action");
                Debug.Assert(actionProperty != null, $"Could not find m_Action in {bindingProperty}");
                if (!actionProperty.stringValue.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                // See what kind of binding we have.
                var flagsProperty = bindingProperty.FindPropertyRelative("m_Flags");
                Debug.Assert(actionProperty != null, $"Could not find m_Flags in {bindingProperty}");
                var flags = (InputBinding.Flags)flagsProperty.intValue;
                if ((flags & InputBinding.Flags.PartOfComposite) != 0 && currentComposite != null)
                {
                    // Composite part binding.
                    PartOfCompositeBindingTreeItem.AddTo(currentComposite, bindingProperty);
                }
                else if ((flags & InputBinding.Flags.Composite) != 0)
                {
                    // Composite binding.
                    currentComposite = CompositeBindingTreeItem.AddTo(parent, bindingProperty);
                }
                else
                {
                    // "Normal" binding.
                    BindingTreeItem.AddTo(parent, bindingProperty);
                    currentComposite = null;
                }
            }
        }