Esempio n. 1
0
        void SetShowNativeSize(bool instant)
        {
            IMCImage.Type type           = (IMCImage.Type)m_Type.enumValueIndex;
            bool          showNativeSize = (type == IMCImage.Type.Simple || type == IMCImage.Type.Filled);

            base.SetShowNativeSize(showNativeSize, instant);
        }
Esempio n. 2
0
        /// <summary>
        /// Draw the atlas and Image selection fields.
        /// </summary>

        protected void SpriteGUI()
        {
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_Sprite, m_SpriteContent);
            if (EditorGUI.EndChangeCheck())
            {
                var newSprite = m_Sprite.objectReferenceValue as Sprite;
                if (newSprite)
                {
                    IMCImage.Type oldType = (IMCImage.Type)m_Type.enumValueIndex;
                    if (newSprite.border.SqrMagnitude() > 0)
                    {
                        m_Type.enumValueIndex = (int)IMCImage.Type.Sliced;
                    }
                    else if (oldType == IMCImage.Type.Sliced)
                    {
                        m_Type.enumValueIndex = (int)IMCImage.Type.Simple;
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sprites's custom properties based on the type.
        /// </summary>

        protected void TypeGUI()
        {
            EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent);

            ++EditorGUI.indentLevel;
            {
                IMCImage.Type typeEnum = (IMCImage.Type)m_Type.enumValueIndex;

                bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == IMCImage.Type.Sliced || typeEnum == IMCImage.Type.Tiled));
                if (showSlicedOrTiled && targets.Length > 1)
                {
                    showSlicedOrTiled = targets.Select(obj => obj as IMCImage).All(img => img.hasBorder);
                }

                m_ShowSlicedOrTiled.target = showSlicedOrTiled;
                m_ShowSliced.target        = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == IMCImage.Type.Sliced);
                m_ShowFilled.target        = (!m_Type.hasMultipleDifferentValues && typeEnum == IMCImage.Type.Filled);

                IMCImage image = target as IMCImage;
                if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded))
                {
                    if (image.hasBorder)
                    {
                        EditorGUILayout.PropertyField(m_FillCenter);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded))
                {
                    if (image.sprite != null && !image.hasBorder)
                    {
                        EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded))
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(m_FillMethod);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_FillOrigin.intValue = 0;
                    }
                    switch ((IMCImage.FillMethod)m_FillMethod.enumValueIndex)
                    {
                    case IMCImage.FillMethod.Horizontal:
                        m_FillOrigin.intValue = (int)(IMCImage.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (IMCImage.OriginHorizontal)m_FillOrigin.intValue);
                        break;

                    case IMCImage.FillMethod.Vertical:
                        m_FillOrigin.intValue = (int)(IMCImage.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (IMCImage.OriginVertical)m_FillOrigin.intValue);
                        break;

                    case IMCImage.FillMethod.Radial90:
                        m_FillOrigin.intValue = (int)(IMCImage.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (IMCImage.Origin90)m_FillOrigin.intValue);
                        break;

                    case IMCImage.FillMethod.Radial180:
                        m_FillOrigin.intValue = (int)(IMCImage.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (IMCImage.Origin180)m_FillOrigin.intValue);
                        break;

                    case IMCImage.FillMethod.Radial360:
                        m_FillOrigin.intValue = (int)(IMCImage.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (IMCImage.Origin360)m_FillOrigin.intValue);
                        break;
                    }
                    EditorGUILayout.PropertyField(m_FillAmount);
                    if ((IMCImage.FillMethod)m_FillMethod.enumValueIndex > IMCImage.FillMethod.Vertical)
                    {
                        EditorGUILayout.PropertyField(m_FillClockwise, m_ClockwiseContent);
                    }
                }
                EditorGUILayout.EndFadeGroup();
            }
            --EditorGUI.indentLevel;
        }