Exemplo n.º 1
0
        public void DrawElement(Rect r, object obj, bool dragging)
        {
            MonoScript script = obj as MonoScript;

            if (Event.current.type == EventType.Repaint)
            {
                Styles.elementBackground.Draw(r, false, false, false, false);
                Styles.draggingHandle.Draw(GetDraggingHandleRect(r), false, false, false, false);
            }

            GUI.Label(GetButtonLabelRect(r), script.GetClass().FullName);

            int  oldNr    = GetExecutionOrder(script);
            Rect position = GetFieldRect(r);
            // associate control id with script so that removing an element when its text field is active will not potentially cause subsequent element to inherit value when list is reordered
            int    id     = GUIUtility.GetControlID(script.GetHashCode(), FocusType.Keyboard, position);
            string intStr = EditorGUI.DelayedTextFieldInternal(position, id, GUIContent.none, oldNr.ToString(), "0123456789-", EditorStyles.textField);
            int    newNr  = oldNr;

            if (System.Int32.TryParse(intStr, out newNr) && newNr != oldNr)
            {
                SetExecutionOrder(script, newNr);
                m_Edited = script;
            }

            if (GUI.Button(GetAddRemoveButtonRect(r), Content.iconToolbarMinus, Styles.removeButton))
            {
                SetExecutionOrder(script, 0);
                m_Edited = script;
            }
        }
        public void DrawElement(Rect r, object obj, bool dragging)
        {
            MonoScript monoScript = obj as MonoScript;

            if (Event.current.type == EventType.Repaint)
            {
                ScriptExecutionOrderInspector.m_Styles.elementBackground.Draw(r, false, false, false, false);
                ScriptExecutionOrderInspector.m_Styles.draggingHandle.Draw(this.GetDraggingHandleRect(r), false, false, false, false);
            }
            GUI.Label(this.GetButtonLabelRect(r), monoScript.GetClass().FullName);
            int    executionOrder = this.GetExecutionOrder(monoScript);
            Rect   fieldRect      = this.GetFieldRect(r);
            int    controlID      = GUIUtility.GetControlID(monoScript.GetHashCode(), FocusType.Keyboard, fieldRect);
            string s   = EditorGUI.DelayedTextFieldInternal(fieldRect, controlID, GUIContent.none, executionOrder.ToString(), "0123456789-", EditorStyles.textField);
            int    num = executionOrder;

            if (int.TryParse(s, out num) && num != executionOrder)
            {
                this.SetExecutionOrder(monoScript, num);
                this.m_Edited = monoScript;
            }
            if (GUI.Button(this.GetAddRemoveButtonRect(r), ScriptExecutionOrderInspector.m_Styles.iconToolbarMinus, ScriptExecutionOrderInspector.m_Styles.removeButton))
            {
                this.SetExecutionOrder(monoScript, 0);
                this.m_Edited = monoScript;
            }
        }