コード例 #1
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);
        }
コード例 #2
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();
            }
        }
コード例 #3
0
        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>);
            }
        }