UnityEditor.CameraEditor.GetRemoveButtonRect C# (CSharp) Method

GetRemoveButtonRect() private static method

private static GetRemoveButtonRect ( Rect r ) : Rect
r UnityEngine.Rect
return UnityEngine.Rect
        private static Rect GetRemoveButtonRect(Rect r)
        {
            Vector2 vector = Styles.invisibleButton.CalcSize(Styles.iconRemove);
            return new Rect(r.xMax - vector.x, r.y + ((int) ((r.height / 2f) - (vector.y / 2f))), vector.x, vector.y);
        }

Usage Example

示例#1
0
        private void CommandBufferGUI()
        {
            if (this.targets.Length != 1)
            {
                return;
            }
            Camera target = this.target as Camera;

            if ((UnityEngine.Object)target == (UnityEngine.Object)null)
            {
                return;
            }
            int commandBufferCount = target.commandBufferCount;

            if (commandBufferCount == 0)
            {
                return;
            }
            this.m_CommandBuffersShown = GUILayout.Toggle(this.m_CommandBuffersShown, GUIContent.Temp(commandBufferCount.ToString() + " command buffers"), EditorStyles.foldout, new GUILayoutOption[0]);
            if (!this.m_CommandBuffersShown)
            {
                return;
            }
            ++EditorGUI.indentLevel;
            foreach (CameraEvent evt in (CameraEvent[])Enum.GetValues(typeof(CameraEvent)))
            {
                foreach (CommandBuffer commandBuffer in target.GetCommandBuffers(evt))
                {
                    using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
                    {
                        Rect rect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel);
                        rect.xMin += EditorGUI.indent;
                        Rect removeButtonRect = CameraEditor.GetRemoveButtonRect(rect);
                        rect.xMax = removeButtonRect.x;
                        GUI.Label(rect, string.Format("{0}: {1} ({2})", (object)evt, (object)commandBuffer.name, (object)EditorUtility.FormatBytes(commandBuffer.sizeInBytes)), EditorStyles.miniLabel);
                        if (GUI.Button(removeButtonRect, CameraEditor.Styles.iconRemove, CameraEditor.Styles.invisibleButton))
                        {
                            target.RemoveCommandBuffer(evt, commandBuffer);
                            SceneView.RepaintAll();
                            GameView.RepaintAll();
                            GUIUtility.ExitGUI();
                        }
                    }
                }
            }
            using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Remove all", EditorStyles.miniButton, new GUILayoutOption[0]))
                {
                    target.RemoveAllCommandBuffers();
                    SceneView.RepaintAll();
                    GameView.RepaintAll();
                }
            }
            --EditorGUI.indentLevel;
        }
All Usage Examples Of UnityEditor.CameraEditor::GetRemoveButtonRect