UnityEditor.LightEditor.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 = s_Styles.invisibleButton.CalcSize(s_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 (base.targets.Length == 1)
     {
         Light light = base.target as Light;
         if (!(light == null))
         {
             int commandBufferCount = light.commandBufferCount;
             if (commandBufferCount != 0)
             {
                 this.m_CommandBuffersShown = GUILayout.Toggle(this.m_CommandBuffersShown, GUIContent.Temp(commandBufferCount + " command buffers"), EditorStyles.foldout, new GUILayoutOption[0]);
                 if (this.m_CommandBuffersShown)
                 {
                     EditorGUI.indentLevel++;
                     LightEvent[] array = (LightEvent[])Enum.GetValues(typeof(LightEvent));
                     for (int i = 0; i < array.Length; i++)
                     {
                         LightEvent      lightEvent     = array[i];
                         CommandBuffer[] commandBuffers = light.GetCommandBuffers(lightEvent);
                         CommandBuffer[] array2         = commandBuffers;
                         for (int j = 0; j < array2.Length; j++)
                         {
                             CommandBuffer commandBuffer = array2[j];
                             using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
                             {
                                 Rect rect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel);
                                 rect.xMin += EditorGUI.indent;
                                 Rect removeButtonRect = LightEditor.GetRemoveButtonRect(rect);
                                 rect.xMax = removeButtonRect.x;
                                 GUI.Label(rect, string.Format("{0}: {1} ({2})", lightEvent, commandBuffer.name, EditorUtility.FormatBytes(commandBuffer.sizeInBytes)), EditorStyles.miniLabel);
                                 if (GUI.Button(removeButtonRect, LightEditor.s_Styles.iconRemove, LightEditor.s_Styles.invisibleButton))
                                 {
                                     light.RemoveCommandBuffer(lightEvent, 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]))
                         {
                             light.RemoveAllCommandBuffers();
                             SceneView.RepaintAll();
                             GameView.RepaintAll();
                         }
                     }
                     EditorGUI.indentLevel--;
                 }
             }
         }
     }
 }