Пример #1
0
        protected override void DrawCustomFooter()
        {
            ButtonTextProfile  textProfile = (ButtonTextProfile)target;
            CompoundButtonText textButton  = (CompoundButtonText)targetComponent;

            if (textButton == null || !textButton.OverrideOffset)
            {
                switch (textProfile.Anchor)
                {
                case TextAnchor.LowerCenter:
                    textProfile.AnchorLowerCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerCenterOffset);
                    break;

                case TextAnchor.LowerLeft:
                    textProfile.AnchorLowerLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerLeftOffset);
                    break;

                case TextAnchor.LowerRight:
                    textProfile.AnchorLowerRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerRightOffset);
                    break;

                case TextAnchor.MiddleCenter:
                    textProfile.AnchorMiddleCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleCenterOffset);
                    break;

                case TextAnchor.MiddleLeft:
                    textProfile.AnchorMiddleLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleLeftOffset);
                    break;

                case TextAnchor.MiddleRight:
                    textProfile.AnchorMiddleRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleRightOffset);
                    break;

                case TextAnchor.UpperCenter:
                    textProfile.AnchorUpperCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperCenterOffset);
                    break;

                case TextAnchor.UpperLeft:
                    textProfile.AnchorUpperLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperLeftOffset);
                    break;

                case TextAnchor.UpperRight:
                    textProfile.AnchorUpperRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperRightOffset);
                    break;
                }
            }
        }
        public override void OnInspectorGUI()
        {
            ButtonTextProfile  textProfile = (ButtonTextProfile)target;
            CompoundButtonText textButton  = (CompoundButtonText)targetComponent;

            HUXEditorUtils.BeginProfileBox();

            HUXEditorUtils.BeginSectionBox("Text properties");

            textProfile.Font      = (Font)EditorGUILayout.ObjectField("Font", textProfile.Font, typeof(Font), false);
            textProfile.Alignment = (TextAlignment)EditorGUILayout.EnumPopup("Alignment", textProfile.Alignment);
            if (textButton == null || !textButton.OverrideAnchor)
            {
                textProfile.Anchor = (TextAnchor)EditorGUILayout.EnumPopup("Anchor", textProfile.Anchor);
            }
            if (textButton == null || !textButton.OverrideFontStyle)
            {
                textProfile.Style = (FontStyle)EditorGUILayout.EnumPopup("Style", textProfile.Style);
            }
            if (textButton == null || !textButton.OverrideSize)
            {
                textProfile.Size = EditorGUILayout.IntField("Size", textProfile.Size);
            }
            textProfile.Color = EditorGUILayout.ColorField(textProfile.Color);

            HUXEditorUtils.EndSectionBox();


            HUXEditorUtils.BeginSectionBox("Text Offset (based on anchor setting)");
            if (textButton == null || !textButton.OverrideOffset)
            {
                switch (textProfile.Anchor)
                {
                case TextAnchor.LowerCenter:
                    textProfile.AnchorLowerCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerCenterOffset);
                    break;

                case TextAnchor.LowerLeft:
                    textProfile.AnchorLowerLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerLeftOffset);
                    break;

                case TextAnchor.LowerRight:
                    textProfile.AnchorLowerRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerRightOffset);
                    break;

                case TextAnchor.MiddleCenter:
                    textProfile.AnchorMiddleCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleCenterOffset);
                    break;

                case TextAnchor.MiddleLeft:
                    textProfile.AnchorMiddleLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleLeftOffset);
                    break;

                case TextAnchor.MiddleRight:
                    textProfile.AnchorMiddleRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleRightOffset);
                    break;

                case TextAnchor.UpperCenter:
                    textProfile.AnchorUpperCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperCenterOffset);
                    break;

                case TextAnchor.UpperLeft:
                    textProfile.AnchorUpperLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperLeftOffset);
                    break;

                case TextAnchor.UpperRight:
                    textProfile.AnchorUpperRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperRightOffset);
                    break;
                }
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.EndProfileBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }