private void TriangleGUI()
        {
            Rect rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);

            MPEditorUtility.CornerRadiusModeGUI(rect, ref spTriangleUniformCornerRadius, new[] { "Free", "Uniform" });

            Vector3 vectorValue = spTriangleCornerRadius.vector3Value;
            float   floatVal    = vectorValue.x;

            EditorGUI.BeginChangeCheck();
            {
                EditorGUI.showMixedValue = spTriangleCornerRadius.hasMultipleDifferentValues;
                if (spTriangleUniformCornerRadius.boolValue)
                {
                    floatVal = EditorGUILayout.FloatField("Uniform Radius", floatVal);
                }
                else
                {
                    vectorValue = EditorGUILayout.Vector3Field("", vectorValue);
                }

                EditorGUI.showMixedValue = false;
            }
            if (EditorGUI.EndChangeCheck())
            {
                spTriangleCornerRadius.vector3Value = spTriangleUniformCornerRadius.boolValue
                    ? new Vector3(floatVal, floatVal, floatVal)
                    : vectorValue;
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            {
                Rect LabelRect        = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
                Rect RadiusVectorRect = new Rect(position.x,
                                                 position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing,
                                                 position.width, EditorGUIUtility.singleLineHeight);

                SerializedProperty uniform = property.FindPropertyRelative("m_UniformCornerRadius");
                SerializedProperty radius  = property.FindPropertyRelative("m_CornerRadius");

                MPEditorUtility.CornerRadiusModeGUI(LabelRect, ref uniform, new [] { "Free", "Uniform" });

                float   floatVal    = radius.vector3Value.x;
                Vector3 vectorValue = radius.vector3Value;

                EditorGUI.BeginChangeCheck();
                {
                    if (uniform.boolValue)
                    {
                        floatVal = EditorGUI.FloatField(RadiusVectorRect, "Uniform Radius", floatVal);
                    }
                    else
                    {
                        vectorValue = EditorGUI.Vector3Field(RadiusVectorRect, string.Empty, vectorValue);
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    radius.vector3Value = uniform.boolValue ? new Vector3(floatVal, floatVal, floatVal) : vectorValue;
                }
            }
            EditorGUI.EndProperty();
        }
        private void CircleGUI()
        {
            EditorGUI.BeginDisabledGroup(spCircleFitToRect.boolValue);
            EditorGUILayout.PropertyField(spCircleRadius, new GUIContent("Radius"));
            EditorGUI.EndDisabledGroup();
            Rect rect = EditorGUILayout.GetControlRect();

            MPEditorUtility.CornerRadiusModeGUI(rect, ref spCircleFitToRect, new[] { "Free", "Fit" }, String.Empty);
        }
Esempio n. 4
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            {
                SerializedProperty RectRadius = property.FindPropertyRelative("m_CornerRadius");
                SerializedProperty uniform    = property.FindPropertyRelative("m_UniformCornerRadius");
                SerializedProperty triSize    = property.FindPropertyRelative("m_TipSize");
                SerializedProperty triRadius  = property.FindPropertyRelative("m_TipRadius");

                Vector4 radiusVectorValue = RectRadius.vector4Value;
                float   radiusFloatValue  = radiusVectorValue.x;
                bool    boolVal           = uniform.boolValue;

                float[] zw = new[] { radiusVectorValue.w, radiusVectorValue.z };
                float[] xy = new[] { radiusVectorValue.x, radiusVectorValue.y };

                Rect line = position;
                line.height = EditorGUIUtility.singleLineHeight;
                MPEditorUtility.CornerRadiusModeGUI(line, ref uniform, new [] { "Free", "Uniform" });
                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = RectRadius.hasMultipleDifferentValues;
                    if (boolVal)
                    {
                        radiusFloatValue = EditorGUI.FloatField(line, "   Uniform Radius", radiusFloatValue);
                    }
                    else
                    {
                        line.x     += 10;
                        line.width -= 10;
                        EditorGUI.MultiFloatField(line, new [] { new GUIContent("W"), new GUIContent("Z"), }, zw);
                        line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                        EditorGUI.MultiFloatField(line, new [] { new GUIContent("X "), new GUIContent("Y"), }, xy);
                        line.x     -= 10;
                        line.width += 10;
                    }
                    EditorGUI.showMixedValue = false;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    RectRadius.vector4Value = boolVal ? new Vector4(radiusFloatValue, radiusFloatValue, radiusFloatValue, radiusFloatValue) : new Vector4(xy[0], xy[1], zw[1], zw[0]);
                }

                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(line, triSize, new GUIContent("Tip size"));
                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(line, triRadius, new GUIContent("Tip Radius"));
            }
            EditorGUI.EndProperty();
        }
Esempio n. 5
0
        private void AdditionalShaderChannelsCheck()
        {
            Canvas canvas = (target as MPImage)?.GetComponentInParent <Canvas>();

            if (canvas && MPEditorUtility.HasAdditionalShaderChannels(canvas))
            {
                return;
            }
            if (canvas)
            {
                MPEditorUtility.AddAdditionalShaderChannelsToCanvas(canvas);
                Debug.Log(
                    $"Additional shader channels ('Texcoord1', 'Texcoord2') added to canvas '{canvas.gameObject.name}'");
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            {
                Rect LabelRect        = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
                Rect RadiusVectorRect = new Rect(position.x,
                                                 position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing,
                                                 position.width, EditorGUIUtility.singleLineHeight);

                SerializedProperty uniform = property.FindPropertyRelative("m_UniformCornerRadius");
                SerializedProperty radius  = property.FindPropertyRelative("m_CornerRadius");

                MPEditorUtility.CornerRadiusModeGUI(LabelRect, ref uniform, new [] { "Free", "Uniform" });

                float   floatVal    = radius.vector4Value.x;
                Vector4 vectorValue = radius.vector4Value;
                float[] zw          = new[] { vectorValue.w, vectorValue.z };
                float[] xy          = new[] { vectorValue.x, vectorValue.y };

                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = radius.hasMultipleDifferentValues;
                    if (uniform.boolValue)
                    {
                        floatVal = EditorGUI.FloatField(RadiusVectorRect, "Uniform Radius", floatVal);
                    }
                    else
                    {
                        EditorGUI.MultiFloatField(RadiusVectorRect, new [] {
                            new GUIContent("W"), new GUIContent("Z")
                        }, zw);
                        RadiusVectorRect.y +=
                            EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                        EditorGUI.MultiFloatField(RadiusVectorRect, new [] {
                            new GUIContent("X "), new GUIContent("Y")
                        }, xy);
                    }
                    EditorGUI.showMixedValue = false;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    radius.vector4Value = uniform.boolValue
                        ? new Vector4(floatVal, floatVal, floatVal, floatVal)
                        : new Vector4(xy[0], xy[1], zw[1], zw[0]);
                }
            }
            EditorGUI.EndProperty();
        }
        private void RectangleGUI()
        {
            Rect rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);

            MPEditorUtility.CornerRadiusModeGUI(rect, ref spRectangleUniformCornerRadius, new[] { "Free", "Uniform" });

            Vector4 vectorValue = spRectangleCornerRadius.vector4Value;
            float   floatVal    = vectorValue.x;

            float[] zw = new[] { vectorValue.w, vectorValue.z };
            float[] xy = new[] { vectorValue.x, vectorValue.y };

            EditorGUI.BeginChangeCheck();
            {
                EditorGUI.showMixedValue = spRectangleCornerRadius.hasMultipleDifferentValues;
                if (spRectangleUniformCornerRadius.boolValue)
                {
                    floatVal = EditorGUILayout.FloatField("Uniform Radius", floatVal);
                }
                else
                {
                    rect = EditorGUILayout.GetControlRect(true,
                                                          EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.singleLineHeight * 2);
                    Rect RadiusVectorRect = new Rect(rect.x, rect.y,
                                                     rect.width, EditorGUIUtility.singleLineHeight);

                    EditorGUI.MultiFloatField(RadiusVectorRect, new[] {
                        new GUIContent("W"), new GUIContent("Z")
                    }, zw);
                    RadiusVectorRect.y +=
                        EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    EditorGUI.MultiFloatField(RadiusVectorRect, new[] {
                        new GUIContent("X "), new GUIContent("Y")
                    }, xy);
                }

                EditorGUI.showMixedValue = false;
            }
            if (EditorGUI.EndChangeCheck())
            {
                spRectangleCornerRadius.vector4Value = spRectangleUniformCornerRadius.boolValue
                    ? new Vector4(floatVal, floatVal, floatVal, floatVal)
                    : new Vector4(xy[0], xy[1], zw[1], zw[0]);
            }
        }
Esempio n. 8
0
        private static void LoadSettings()
        {
            if (_settings)
            {
                return;
            }
            string path =
                $"{MPEditorUtility.FindMPUIKitRootDirectory()}Editor{Path.DirectorySeparatorChar}MPUIKitSettings.asset";

            _settings = AssetDatabase.LoadAssetAtPath <MPUIKitSettings>(path);
            if (_settings == null)
            {
                _settings = CreateInstance <MPUIKitSettings>();
                AssetDatabase.CreateAsset(_settings, path);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
Esempio n. 9
0
 private void FixShaderChannelGUI()
 {
     if (!shaderChannelsNeedUpdate)
     {
         return;
     }
     EditorGUILayout.HelpBox(
         "Parent Canvas needs to have these additional shader channels : Texcoord1, Texcoord2",
         MessageType.Error);
     EditorGUILayout.BeginHorizontal();
     {
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("Fix", GUILayout.Width(100)))
         {
             Canvas canvas = (target as MPImage)?.GetComponentInParent <Canvas>();
             if (canvas != null)
             {
                 MPEditorUtility.AddAdditionalShaderChannelsToCanvas(canvas);
                 shaderChannelsNeedUpdate = false;
             }
         }
     }
     EditorGUILayout.EndHorizontal();
 }
Esempio n. 10
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            {
                SerializedProperty rectRadius  = property.FindPropertyRelative("m_CornerRadius");
                SerializedProperty uniformRect = property.FindPropertyRelative("m_UniformCornerRadius");
                SerializedProperty triSizes    = property.FindPropertyRelative("m_TipSize");
                SerializedProperty uniformTriS = property.FindPropertyRelative("m_UniformTipSize");
                SerializedProperty triRadius   = property.FindPropertyRelative("m_TipRadius");
                SerializedProperty uniformTriR = property.FindPropertyRelative("m_UniformTipRadius");

                Vector4 radiusVectorValue = rectRadius.vector4Value;
                float   radiusFloatValue  = radiusVectorValue.x;
                bool    rectBoolVal       = uniformRect.boolValue;
                float[] zw = new[] { radiusVectorValue.w, radiusVectorValue.z };
                float[] xy = new[] { radiusVectorValue.x, radiusVectorValue.y };
                Vector2 triSizesVectorValue  = triSizes.vector2Value;
                float   triSizesFloatValue   = triSizesVectorValue.x;
                Vector2 triRadiusVectorValue = triRadius.vector2Value;
                float   triRadiusFloatValue  = triRadiusVectorValue.x;

                Rect line = position;
                line.height = EditorGUIUtility.singleLineHeight;
                string[] toolbarLabel = new[] { "Free", "Uniform" };
                MPEditorUtility.CornerRadiusModeGUI(line, ref uniformRect, toolbarLabel);
                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = rectRadius.hasMultipleDifferentValues;
                    if (rectBoolVal)
                    {
                        radiusFloatValue = EditorGUI.FloatField(line, "Uniform Radius", radiusFloatValue);
                    }
                    else
                    {
                        EditorGUI.MultiFloatField(line, new [] { new GUIContent("W"), new GUIContent("Z") }, zw);
                        line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                        EditorGUI.MultiFloatField(line, new [] { new GUIContent("X"), new GUIContent("Y") }, xy);
                    }
                    EditorGUI.showMixedValue = false;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    rectRadius.vector4Value = rectBoolVal
                        ? new Vector4(radiusFloatValue, radiusFloatValue, radiusFloatValue, radiusFloatValue)
                        : new Vector4(xy[0], xy[1], zw[1], zw[0]);
                }


                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                MPEditorUtility.CornerRadiusModeGUI(line, ref uniformTriS, toolbarLabel, "Tip Size");
                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = triSizes.hasMultipleDifferentValues;
                    if (uniformTriS.boolValue)
                    {
                        triSizesFloatValue = EditorGUI.FloatField(line, "Uniform Size", triSizesFloatValue);
                    }
                    else
                    {
                        triSizesVectorValue = EditorGUI.Vector2Field(line, string.Empty, triSizesVectorValue);
                    }

                    EditorGUI.showMixedValue = false;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    triSizes.vector2Value = uniformTriS.boolValue
                        ? new Vector2(triSizesFloatValue, triSizesFloatValue)
                        : triSizesVectorValue;
                }


                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                MPEditorUtility.CornerRadiusModeGUI(line, ref uniformTriR, toolbarLabel, "Tip Radius");
                line.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = triRadius.hasMultipleDifferentValues;
                    if (uniformTriR.boolValue)
                    {
                        triRadiusFloatValue = EditorGUI.FloatField(line, "Uniform Radius", triRadiusFloatValue);
                    }
                    else
                    {
                        triRadiusVectorValue = EditorGUI.Vector2Field(line, string.Empty, triRadiusVectorValue);
                    }

                    EditorGUI.showMixedValue = false;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    triRadius.vector2Value = uniformTriR.boolValue
                        ? new Vector2(triRadiusFloatValue, triRadiusFloatValue)
                        : triRadiusVectorValue;
                }
            }
            EditorGUI.EndProperty();
        }
        private static void FindMpuiKitIconsDirectory()
        {
            string rootDir = MPEditorUtility.FindMPUIKitRootDirectory();

            _mpuiKitImagesDirectory = string.IsNullOrEmpty(rootDir) ? string.Empty : Path.Combine(rootDir, "Editor", "Images");
        }