UnityEditor.ShaderVariantCollectionInspector.GetAddRemoveButtonRect C# (CSharp) Method

GetAddRemoveButtonRect() private static method

private static GetAddRemoveButtonRect ( Rect r ) : Rect
r UnityEngine.Rect
return UnityEngine.Rect
        private static Rect GetAddRemoveButtonRect(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 DrawShaderEntry(int shaderIndex)
        {
            SerializedProperty arrayElementAtIndex = this.m_Shaders.GetArrayElementAtIndex(shaderIndex);
            Shader             shader             = (Shader)arrayElementAtIndex.FindPropertyRelative("first").objectReferenceValue;
            SerializedProperty serializedProperty = arrayElementAtIndex.FindPropertyRelative("second.variants");

            using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
            {
                Rect rect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.boldLabel);
                Rect addRemoveButtonRect = ShaderVariantCollectionInspector.GetAddRemoveButtonRect(rect);
                rect.xMax = addRemoveButtonRect.x;
                GUI.Label(rect, shader.name, EditorStyles.boldLabel);
                if (GUI.Button(addRemoveButtonRect, ShaderVariantCollectionInspector.Styles.iconRemove, ShaderVariantCollectionInspector.Styles.invisibleButton))
                {
                    this.m_Shaders.DeleteArrayElementAtIndex(shaderIndex);
                    return;
                }
            }
            for (int i = 0; i < serializedProperty.arraySize; i++)
            {
                SerializedProperty arrayElementAtIndex2 = serializedProperty.GetArrayElementAtIndex(i);
                string             text = arrayElementAtIndex2.FindPropertyRelative("keywords").stringValue;
                if (string.IsNullOrEmpty(text))
                {
                    text = "<no keywords>";
                }
                PassType intValue             = (PassType)arrayElementAtIndex2.FindPropertyRelative("passType").intValue;
                Rect     rect2                = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel);
                Rect     addRemoveButtonRect2 = ShaderVariantCollectionInspector.GetAddRemoveButtonRect(rect2);
                rect2.xMax = addRemoveButtonRect2.x;
                GUI.Label(rect2, intValue + " " + text, EditorStyles.miniLabel);
                if (GUI.Button(addRemoveButtonRect2, ShaderVariantCollectionInspector.Styles.iconRemove, ShaderVariantCollectionInspector.Styles.invisibleButton))
                {
                    serializedProperty.DeleteArrayElementAtIndex(i);
                }
            }
            Rect rect3 = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel);
            Rect addRemoveButtonRect3 = ShaderVariantCollectionInspector.GetAddRemoveButtonRect(rect3);

            if (GUI.Button(addRemoveButtonRect3, ShaderVariantCollectionInspector.Styles.iconAdd, ShaderVariantCollectionInspector.Styles.invisibleButton))
            {
                this.DisplayAddVariantsWindow(shader, base.target as ShaderVariantCollection);
            }
        }
All Usage Examples Of UnityEditor.ShaderVariantCollectionInspector::GetAddRemoveButtonRect