public override float GetPropertyHeight()
 {
     return
         (ControlGUIUtility.GetControlHeight(m_Negative, s_NegativeContent) +
          ControlGUIUtility.GetControlHeight(m_Positive, s_PositiveContent) +
          EditorGUIUtility.standardVerticalSpacing);
 }
示例#2
0
 public override float GetPropertyHeight()
 {
     return
         (ControlGUIUtility.GetControlHeight(m_X, s_XContent) +
          ControlGUIUtility.GetControlHeight(m_Y, s_YContent) +
          EditorGUIUtility.standardVerticalSpacing);
 }
示例#3
0
        public override void OnGUI(Rect position, IControlDomainSource domainSource)
        {
            position.height = ControlGUIUtility.GetControlHeight(m_X, s_XContent);
            ControlGUIUtility.ControlField(position, m_X, s_XContent, domainSource, b => m_X = b);

            position.y += position.height + EditorGUIUtility.standardVerticalSpacing;

            position.height = ControlGUIUtility.GetControlHeight(m_Y, s_YContent);
            ControlGUIUtility.ControlField(position, m_Y, s_YContent, domainSource, b => m_Y = b);
        }
示例#4
0
        public override float GetPropertyHeight()
        {
            float height = EditorGUIUtility.singleLineHeight * 3 + Styles.k_Spacing * 2;

            for (int i = 0; i < sources.Count; i++)
            {
                height += ControlGUIUtility.GetControlHeight(sources[i], Styles.bindingContent);
            }
            height += EditorGUIUtility.standardVerticalSpacing * sources.Count;

            for (int i = 0; i < processors.Count; i++)
            {
                height += processors[i].GetPropertyHeight();
            }
            height += EditorGUIUtility.standardVerticalSpacing * processors.Count;

            return(height);
        }
        public override float GetPropertyHeight()
        {
            float height =
                ControlGUIUtility.GetControlHeight(m_Main, s_MainContent) +
                EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing * 2;

            for (int i = 0; i < modifiers.Count; i++)
            {
                var control = modifiers[i];
                height +=
                    ControlGUIUtility.GetControlHeight(control, s_ModifierContent) +
                    EditorGUIUtility.standardVerticalSpacing;
            }

            for (int i = 0; i < modifierSet.Count; i++)
            {
                var control = modifierSet[i];
                height +=
                    ControlGUIUtility.GetControlHeight(control, s_ModifierContent) +
                    EditorGUIUtility.standardVerticalSpacing;
            }

            return(height);
        }
示例#6
0
        void DrawSourceSettings(Rect position, int bindingIndex, IControlDomainSource domainSource)
        {
            InputBinding <C, T> source = sources[bindingIndex];

            bool used = false;

            if (Event.current.type == EventType.MouseDown && position.Contains(Event.current.mousePosition))
            {
                m_Selected = source;
                used       = true;
            }
            if (m_Selected == source)
            {
                GUI.DrawTexture(position, EditorGUIUtility.whiteTexture);
            }

            ControlGUIUtility.ControlField(position, source, Styles.bindingContent, domainSource,
                                           b => sources[bindingIndex] = b);

            if (used)
            {
                Event.current.Use();
            }
        }
        public override void OnGUI(Rect position, IControlDomainSource domainSource)
        {
            position.height = ControlGUIUtility.GetControlHeight(m_Main, s_MainContent);
            ControlGUIUtility.ControlField(position, m_Main, s_MainContent, domainSource, b => m_Main = b as ControlReferenceBinding <ButtonControl, float>);

            position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
            position.height = EditorGUIUtility.singleLineHeight;
            EditorGUI.BeginChangeCheck();
            int count = EditorGUI.IntField(position, s_CountContent, modifiers.Count);

            if (EditorGUI.EndChangeCheck())
            {
                if (count > modifiers.Count)
                {
                    while (modifiers.Count < count)
                    {
                        modifiers.Add(null);
                    }
                }
                else
                {
                    modifiers.RemoveRange(count, modifiers.Count - count);
                }
            }

            for (int i = 0; i < modifiers.Count; i++)
            {
                int index   = i; // See "close over the loop variable".
                var control = modifiers[i];
                position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
                position.height = ControlGUIUtility.GetControlHeight(control, s_ModifierContent);
                ControlGUIUtility.ControlField(position, control, s_ModifierContent, domainSource,
                                               b => modifiers[index] = b as ControlReferenceBinding <ButtonControl, float>);
            }

            position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
            position.height = EditorGUIUtility.singleLineHeight;
            EditorGUI.BeginChangeCheck();
            count = EditorGUI.IntField(position, s_CountContent, modifierSet.Count);
            if (EditorGUI.EndChangeCheck())
            {
                if (count > modifierSet.Count)
                {
                    while (modifierSet.Count < count)
                    {
                        modifierSet.Add(null);
                    }
                }
                else
                {
                    modifierSet.RemoveRange(count, modifierSet.Count - count);
                }
            }

            for (int i = 0; i < modifierSet.Count; i++)
            {
                int index   = i; // See "close over the loop variable".
                var control = modifierSet[i];
                position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
                position.height = ControlGUIUtility.GetControlHeight(control, s_ModifierContent);
                ControlGUIUtility.ControlField(position, control, s_ModifierContent, domainSource,
                                               b => modifierSet[index] = b as ControlReferenceBinding <ButtonControl, float>);
            }
        }
示例#8
0
        public override void OnGUI(Rect position, IControlDomainSource domainSource)
        {
            // Bindings
            for (int i = 0; i < sources.Count; i++)
            {
                InputBinding <C, T> source = sources[i];
                position.height = ControlGUIUtility.GetControlHeight(source, Styles.bindingContent);
                DrawSourceSettings(position, i, domainSource);
                position.y += position.height + EditorGUIUtility.standardVerticalSpacing;
            }

            // Bindings remove and add buttons
            position.height = EditorGUIUtility.singleLineHeight;
            Rect buttonPosition = position;

            buttonPosition.width = Styles.iconToolbarMinus.image.width;
            if (GUI.Button(buttonPosition, Styles.iconToolbarMinus, GUIStyle.none))
            {
                var selected = m_Selected as InputBinding <C, T>;
                if (sources.Contains(selected))
                {
                    sources.Remove(selected);
                }
            }
            buttonPosition.x += buttonPosition.width;
            if (GUI.Button(buttonPosition, Styles.iconToolbarPlus, GUIStyle.none))
            {
                var source = new ControlReferenceBinding <C, T>();
                sources.Add(source);
                m_Selected = source;
            }
            position.y += position.height + Styles.k_Spacing;

            position.height = EditorGUIUtility.singleLineHeight;
            GUI.Label(position, "Processors");
            position.y += position.height + Styles.k_Spacing;

            // Processors
            for (int i = 0; i < processors.Count; i++)
            {
                InputBindingProcessor <C, T> processor = processors[i];
                position.height = processor.GetPropertyHeight();
                DrawProcessorSettings(position, i);
                position.y += position.height + EditorGUIUtility.standardVerticalSpacing;
            }

            // Processors remove and add buttons
            position.height      = EditorGUIUtility.singleLineHeight;
            buttonPosition       = position;
            buttonPosition.width = Styles.iconToolbarMinus.image.width;
            if (GUI.Button(buttonPosition, Styles.iconToolbarMinus, GUIStyle.none))
            {
                var selected = m_Selected as InputBindingProcessor <C, T>;
                if (selected != null && processors.Contains(selected))
                {
                    processors.Remove(selected);
                }
            }
            buttonPosition.x += buttonPosition.width;
            if (GUI.Button(buttonPosition, Styles.iconToolbarPlus, GUIStyle.none))
            {
                InputBindingProcessor <C, T> .ShowAddProcessorDropdown(buttonPosition, p => processors.Add(p));
            }
        }