static void CreateNotification(UnityEditor.MenuCommand menuCommand)
        {
            UICanvas   targetCanvas = null;
            GameObject selectedGO   = menuCommand.context as GameObject;

            if (selectedGO != null)                                  //check that a gameObject is selected
            {
                targetCanvas = selectedGO.GetComponent <UICanvas>(); //check if the selected gameObject is an UICanvas, otherwise get the root and check
                if (targetCanvas == null)
                {
                    targetCanvas = selectedGO.transform.root.GetComponent <UICanvas>(); //check if there is an UICanvas on the root of the selected gameOhject
                }
            }
            if (targetCanvas == null) //because we did not find any UICanvas on the selected gameObject (or on it's root transform), we get the MasterCanvas; if the MasterCanvas does not exist, it will be created automatically by the system
            {
                targetCanvas = UIManager.GetMasterCanvas();
            }

            GameObject notification = new GameObject("UINotification", typeof(RectTransform), typeof(UINotification));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notification, targetCanvas.gameObject);
            notification.GetComponent <UINotification>().Reset();

            UnityEditor.Undo.RegisterCreatedObjectUndo(notification, "Create " + notification.name);

            GameObject overlay = new GameObject("UIE - Background Overlay", typeof(RectTransform), typeof(UIElement));

            UnityEditor.GameObjectUtility.SetParentAndAlign(overlay, notification);
            overlay.GetComponent <UIElement>().Reset();
            overlay.GetComponent <UIElement>().startHidden = true;
            overlay.GetComponent <UIElement>().inAnimationsPresetCategoryName   = "Fade";
            overlay.GetComponent <UIElement>().inAnimationsPresetName           = "InFast";
            overlay.GetComponent <UIElement>().loadInAnimationsPresetAtRuntime  = true;
            overlay.GetComponent <UIElement>().outAnimationsPresetCategoryName  = "Fade";
            overlay.GetComponent <UIElement>().outAnimationsPresetName          = "OutFast";
            overlay.GetComponent <UIElement>().loadOutAnimationsPresetAtRuntime = true;
            overlay.GetComponent <UIElement>().Canvas.sortingOrder = 0;
            GameObject overlayBackground = new GameObject("Background", typeof(RectTransform), typeof(Image));

            UnityEditor.GameObjectUtility.SetParentAndAlign(overlayBackground, overlay);
            overlayBackground.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            overlayBackground.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            overlayBackground.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            overlayBackground.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            overlayBackground.GetComponent <RectTransform>().sizeDelta        = new Vector2(0, 0);
            overlayBackground.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            overlayBackground.GetComponent <Image>().color = ColorExtensions.ColorFrom256(11, 50, 74, 200);

            GameObject notificationContainer = new GameObject("UIE - Notification Container", typeof(RectTransform), typeof(UIElement), typeof(Button));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationContainer, notification);
            notificationContainer.GetComponent <Button>().transition = Selectable.Transition.None;
            notificationContainer.GetComponent <UIElement>().Reset();
            notificationContainer.GetComponent <UIElement>().startHidden = true;
            notificationContainer.GetComponent <UIElement>().inAnimationsPresetCategoryName   = "Basic";
            notificationContainer.GetComponent <UIElement>().inAnimationsPresetName           = "Punch";
            notificationContainer.GetComponent <UIElement>().loadInAnimationsPresetAtRuntime  = true;
            notificationContainer.GetComponent <UIElement>().outAnimationsPresetCategoryName  = "Basic";
            notificationContainer.GetComponent <UIElement>().outAnimationsPresetName          = "Punch";
            notificationContainer.GetComponent <UIElement>().loadOutAnimationsPresetAtRuntime = true;
            notificationContainer.GetComponent <UIElement>().Canvas.sortingOrder  = 1;
            notificationContainer.GetComponent <RectTransform>().localScale       = Vector3.one;
            notificationContainer.GetComponent <RectTransform>().anchorMin        = new Vector2(0.5f, 0.5f);
            notificationContainer.GetComponent <RectTransform>().anchorMax        = new Vector2(0.5f, 0.5f);
            notificationContainer.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            notificationContainer.GetComponent <RectTransform>().sizeDelta        = new Vector2(300f, 200f);
            notificationContainer.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            GameObject notificationContainerBackground = new GameObject("Background", typeof(RectTransform), typeof(Image));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationContainerBackground, notificationContainer);
            notificationContainerBackground.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationContainerBackground.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            notificationContainerBackground.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationContainerBackground.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            notificationContainerBackground.GetComponent <RectTransform>().sizeDelta        = new Vector2(0, 0);
            notificationContainerBackground.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            notificationContainerBackground.GetComponent <Image>().sprite     = DUI.Background;
            notificationContainerBackground.GetComponent <Image>().type       = Image.Type.Sliced;
            notificationContainerBackground.GetComponent <Image>().fillCenter = true;
            notificationContainerBackground.GetComponent <Image>().color      = ColorExtensions.ColorFrom256(11, 50, 74, 255);

            GameObject notificationTitleContainer = new GameObject("Notification Title Container", typeof(RectTransform), typeof(Image));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationTitleContainer, notificationContainer);
            notificationTitleContainer.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationTitleContainer.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 1);
            notificationTitleContainer.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationTitleContainer.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -16);
            notificationTitleContainer.GetComponent <RectTransform>().sizeDelta        = new Vector2(16, 32);
            notificationTitleContainer.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 1f);
            notificationTitleContainer.GetComponent <Image>().sprite     = DUI.Background;
            notificationTitleContainer.GetComponent <Image>().type       = Image.Type.Sliced;
            notificationTitleContainer.GetComponent <Image>().fillCenter = true;
            notificationTitleContainer.GetComponent <Image>().color      = ColorExtensions.ColorFrom256(31, 136, 201, 255);

#if dUI_TextMeshPro
            GameObject notificationTitle = new GameObject("Notification Title TMPro", typeof(RectTransform), typeof(TMPro.TextMeshProUGUI));
            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationTitle, notificationTitleContainer);
            notificationTitle.GetComponent <RectTransform>().localScale        = new Vector3(1, 1, 1);
            notificationTitle.GetComponent <RectTransform>().anchorMin         = new Vector2(0, 0);
            notificationTitle.GetComponent <RectTransform>().anchorMax         = new Vector2(1, 1);
            notificationTitle.GetComponent <RectTransform>().anchoredPosition  = new Vector2(0, 0);
            notificationTitle.GetComponent <RectTransform>().sizeDelta         = new Vector2(-32, -8);
            notificationTitle.GetComponent <RectTransform>().pivot             = new Vector2(0.5f, 0.5f);
            notificationTitle.GetComponent <TMPro.TextMeshProUGUI>().color     = ColorExtensions.ColorFrom256(11, 50, 74, 255);
            notificationTitle.GetComponent <TMPro.TextMeshProUGUI>().fontSize  = 18;
            notificationTitle.GetComponent <TMPro.TextMeshProUGUI>().fontStyle = TMPro.FontStyles.Bold;
            notificationTitle.GetComponent <TMPro.TextMeshProUGUI>().alignment = TMPro.TextAlignmentOptions.Center;
            notificationTitle.GetComponent <TMPro.TextMeshProUGUI>().text      = "notification title";
#else
            GameObject notificationTitle = new GameObject("Notification Title", typeof(RectTransform), typeof(Text));
            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationTitle, notificationTitleContainer);
            notificationTitle.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationTitle.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            notificationTitle.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationTitle.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            notificationTitle.GetComponent <RectTransform>().sizeDelta        = new Vector2(-32, -4);
            notificationTitle.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            notificationTitle.GetComponent <Text>().color                = ColorExtensions.ColorFrom256(11, 50, 74, 255);
            notificationTitle.GetComponent <Text>().fontSize             = 14;
            notificationTitle.GetComponent <Text>().fontStyle            = FontStyle.Bold;
            notificationTitle.GetComponent <Text>().resizeTextForBestFit = true;
            notificationTitle.GetComponent <Text>().resizeTextMinSize    = 14;
            notificationTitle.GetComponent <Text>().resizeTextMaxSize    = 40;
            notificationTitle.GetComponent <Text>().alignment            = TextAnchor.MiddleCenter;
            notificationTitle.GetComponent <Text>().alignByGeometry      = true;
            notificationTitle.GetComponent <Text>().supportRichText      = true;
            notificationTitle.GetComponent <Text>().text = "notification title";
#endif


#if dUI_TextMeshPro
            GameObject notificationMessage = new GameObject("Notification Message TMPro", typeof(RectTransform), typeof(TMPro.TextMeshProUGUI));
            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationMessage, notificationContainer);
            notificationMessage.GetComponent <RectTransform>().localScale        = new Vector3(1, 1, 1);
            notificationMessage.GetComponent <RectTransform>().anchorMin         = new Vector2(0, 0);
            notificationMessage.GetComponent <RectTransform>().anchorMax         = new Vector2(1, 1);
            notificationMessage.GetComponent <RectTransform>().anchoredPosition  = new Vector2(0, -24);
            notificationMessage.GetComponent <RectTransform>().sizeDelta         = new Vector2(-32, -80);
            notificationMessage.GetComponent <RectTransform>().pivot             = new Vector2(0.5f, 0.5f);
            notificationMessage.GetComponent <TMPro.TextMeshProUGUI>().color     = ColorExtensions.ColorFrom256(31, 136, 201, 255);
            notificationMessage.GetComponent <TMPro.TextMeshProUGUI>().fontSize  = 14;
            notificationMessage.GetComponent <TMPro.TextMeshProUGUI>().fontStyle = TMPro.FontStyles.Italic;
            notificationMessage.GetComponent <TMPro.TextMeshProUGUI>().alignment = TMPro.TextAlignmentOptions.Center;
            notificationMessage.GetComponent <TMPro.TextMeshProUGUI>().text      = "notification message example";
#else
            GameObject notificationMessage = new GameObject("Notification Message", typeof(RectTransform), typeof(Text));
            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationMessage, notificationContainer);
            notificationMessage.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationMessage.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            notificationMessage.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationMessage.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -24);
            notificationMessage.GetComponent <RectTransform>().sizeDelta        = new Vector2(-48, -80);
            notificationMessage.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            notificationMessage.GetComponent <Text>().color                = ColorExtensions.ColorFrom256(31, 136, 201, 255);
            notificationMessage.GetComponent <Text>().fontSize             = 14;
            notificationMessage.GetComponent <Text>().fontStyle            = FontStyle.Italic;
            notificationMessage.GetComponent <Text>().resizeTextForBestFit = true;
            notificationMessage.GetComponent <Text>().resizeTextMinSize    = 12;
            notificationMessage.GetComponent <Text>().resizeTextMaxSize    = 18;
            notificationMessage.GetComponent <Text>().alignment            = TextAnchor.MiddleCenter;
            notificationMessage.GetComponent <Text>().alignByGeometry      = true;
            notificationMessage.GetComponent <Text>().supportRichText      = true;
            notificationMessage.GetComponent <Text>().text = "notification message example";
#endif

            notification.GetComponent <UINotification>().notificationContainer = notificationContainer.GetComponent <UIElement>();
            notification.GetComponent <UINotification>().overlay     = overlay.GetComponent <UIElement>();
            notification.GetComponent <UINotification>().title       = notificationTitle;
            notification.GetComponent <UINotification>().message     = notificationMessage;
            notification.GetComponent <UINotification>().closeButton = notificationContainer.GetComponent <Button>();

            UnityEditor.Selection.activeObject = notification;
        }
Exemple #2
0
        static void CreateNotification(UnityEditor.MenuCommand menuCommand)
        {
            UICanvas   targetCanvas = null;
            GameObject selectedGO   = menuCommand.context as GameObject;

            if (selectedGO != null)                                  //check that a gameObject is selected
            {
                targetCanvas = selectedGO.GetComponent <UICanvas>(); //check if the selected gameObject is an UICanvas, otherwise get the root and check
                if (targetCanvas == null)
                {
                    targetCanvas = selectedGO.transform.root.GetComponent <UICanvas>(); //check if there is an UICanvas on the root of the selected gameOhject
                }
            }
            if (targetCanvas == null) //because we did not find any UICanvas on the selected gameObject (or on it's root transform), we get the MasterCanvas; if the MasterCanvas does not exist, it will be created automatically by the system
            {
                targetCanvas = UIManager.GetMasterCanvas();
            }

            GameObject notification = new GameObject("New UINotification", typeof(RectTransform), typeof(UINotification));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notification, targetCanvas.gameObject);
            notification.GetComponent <UINotification>().Reset();

            UnityEditor.Undo.RegisterCreatedObjectUndo(notification, "Create " + notification.name);

            GameObject overlay = new GameObject("UIE - Background Overlay", typeof(RectTransform), typeof(UIElement));

            UnityEditor.GameObjectUtility.SetParentAndAlign(overlay, notification);
            overlay.GetComponent <UIElement>().Reset();
            overlay.GetComponent <UIElement>().inAnimationsPresetCategoryName   = "Basic";
            overlay.GetComponent <UIElement>().inAnimationsPresetName           = "QuickFadeIn";
            overlay.GetComponent <UIElement>().loadInAnimationsPresetAtRuntime  = true;
            overlay.GetComponent <UIElement>().outAnimationsPresetCategoryName  = "Basic";
            overlay.GetComponent <UIElement>().outAnimationsPresetName          = "QuickFadeOut";
            overlay.GetComponent <UIElement>().loadOutAnimationsPresetAtRuntime = true;
            overlay.GetComponent <UIElement>().Canvas.sortingOrder = 0;
            GameObject overlayBackground = new GameObject("Background", typeof(RectTransform), typeof(Image));

            UnityEditor.GameObjectUtility.SetParentAndAlign(overlayBackground, overlay);
            overlayBackground.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            overlayBackground.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            overlayBackground.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            overlayBackground.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            overlayBackground.GetComponent <RectTransform>().sizeDelta        = new Vector2(0, 0);
            overlayBackground.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            overlayBackground.GetComponent <Image>().color = new Color(0f, 0f, 0f, 0.6f);

            GameObject notificationContainer = new GameObject("UIE - Notification Container", typeof(RectTransform), typeof(UIElement), typeof(Button));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationContainer, notification);
            notificationContainer.GetComponent <Button>().transition = Selectable.Transition.None;
            notificationContainer.GetComponent <UIElement>().Reset();
            notificationContainer.GetComponent <UIElement>().inAnimationsPresetCategoryName   = "Basic";
            notificationContainer.GetComponent <UIElement>().inAnimationsPresetName           = "PunchIn";
            notificationContainer.GetComponent <UIElement>().loadInAnimationsPresetAtRuntime  = true;
            notificationContainer.GetComponent <UIElement>().outAnimationsPresetCategoryName  = "Basic";
            notificationContainer.GetComponent <UIElement>().outAnimationsPresetName          = "PunchOut";
            notificationContainer.GetComponent <UIElement>().loadOutAnimationsPresetAtRuntime = true;
            notificationContainer.GetComponent <UIElement>().Canvas.sortingOrder  = 1;
            notificationContainer.GetComponent <RectTransform>().localScale       = Vector3.one;
            notificationContainer.GetComponent <RectTransform>().anchorMin        = new Vector2(0.5f, 0.5f);
            notificationContainer.GetComponent <RectTransform>().anchorMax        = new Vector2(0.5f, 0.5f);
            notificationContainer.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            notificationContainer.GetComponent <RectTransform>().sizeDelta        = new Vector2(512f, 256f);
            notificationContainer.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            GameObject notificationContainerBackground = new GameObject("Background", typeof(RectTransform), typeof(Image));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationContainerBackground, notificationContainer);
            notificationContainerBackground.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationContainerBackground.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            notificationContainerBackground.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationContainerBackground.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            notificationContainerBackground.GetComponent <RectTransform>().sizeDelta        = new Vector2(0, 0);
            notificationContainerBackground.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);

            notificationContainerBackground.GetComponent <Image>().color = ColorExtensions.ColorFrom256(15, 73, 108, 256);
            GameObject notificationTitleContainer = new GameObject("Notification Title Container", typeof(RectTransform), typeof(Image), typeof(Shadow));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationTitleContainer, notificationContainer);
            notificationTitleContainer.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationTitleContainer.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 1);
            notificationTitleContainer.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationTitleContainer.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -28);
            notificationTitleContainer.GetComponent <RectTransform>().sizeDelta        = new Vector2(16, 56);
            notificationTitleContainer.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 1f);
            GameObject notificationTitle = new GameObject("Notification Title", typeof(RectTransform), typeof(Text));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationTitle, notificationTitleContainer);
            notificationTitle.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationTitle.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            notificationTitle.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationTitle.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
            notificationTitle.GetComponent <RectTransform>().sizeDelta        = new Vector2(-32, -16);
            notificationTitle.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            notificationTitle.GetComponent <Text>().color                = ColorExtensions.ColorFrom256(15, 70, 105, 256);
            notificationTitle.GetComponent <Text>().fontSize             = 14;
            notificationTitle.GetComponent <Text>().fontStyle            = FontStyle.Bold;
            notificationTitle.GetComponent <Text>().resizeTextForBestFit = true;
            notificationTitle.GetComponent <Text>().resizeTextMinSize    = 14;
            notificationTitle.GetComponent <Text>().resizeTextMaxSize    = 40;
            notificationTitle.GetComponent <Text>().alignment            = TextAnchor.MiddleCenter;
            notificationTitle.GetComponent <Text>().alignByGeometry      = true;
            notificationTitle.GetComponent <Text>().supportRichText      = true;
            notificationTitle.GetComponent <Text>().text = "notification title";

            GameObject notificationMessage = new GameObject("Notification Message", typeof(RectTransform), typeof(Text));

            UnityEditor.GameObjectUtility.SetParentAndAlign(notificationMessage, notificationContainer);
            notificationMessage.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);
            notificationMessage.GetComponent <RectTransform>().anchorMin        = new Vector2(0, 0);
            notificationMessage.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
            notificationMessage.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -48);
            notificationMessage.GetComponent <RectTransform>().sizeDelta        = new Vector2(-48, -128);
            notificationMessage.GetComponent <RectTransform>().pivot            = new Vector2(0.5f, 0.5f);
            notificationMessage.GetComponent <Text>().fontSize             = 14;
            notificationMessage.GetComponent <Text>().fontStyle            = FontStyle.Italic;
            notificationMessage.GetComponent <Text>().resizeTextForBestFit = true;
            notificationMessage.GetComponent <Text>().resizeTextMinSize    = 24;
            notificationMessage.GetComponent <Text>().resizeTextMaxSize    = 28;
            notificationMessage.GetComponent <Text>().alignment            = TextAnchor.MiddleCenter;
            notificationMessage.GetComponent <Text>().alignByGeometry      = true;
            notificationMessage.GetComponent <Text>().supportRichText      = true;
            notificationMessage.GetComponent <Text>().text = "notification message example";

            notification.GetComponent <UINotification>().notificationContainer = notificationContainer.GetComponent <UIElement>();
            notification.GetComponent <UINotification>().overlay     = overlay.GetComponent <UIElement>();
            notification.GetComponent <UINotification>().title       = notificationTitle;
            notification.GetComponent <UINotification>().message     = notificationMessage;
            notification.GetComponent <UINotification>().closeButton = notificationContainer.GetComponent <Button>();

            UnityEditor.Selection.activeObject = notification;
        }
 public QColor(float rDark, float gDark, float bDark, float aDark, float rLight, float gLight, float bLight, float aLight, bool from256 = true)
 {
     _dark  = from256 ? ColorExtensions.ColorFrom256(rDark, gDark, bDark, aDark) : new Color(rDark, gDark, bDark, aDark);
     _light = from256 ? ColorExtensions.ColorFrom256(rLight, gLight, bLight, aLight) : new Color(rLight, gLight, bLight, aLight);
 }
 public QColor(float r, float g, float b, float a, bool from256 = true)
 {
     _dark  = from256 ? ColorExtensions.ColorFrom256(r, g, b, a) : new Color(r, g, b, a);
     _light = from256 ? ColorExtensions.ColorFrom256(r, g, b, a) : new Color(r, g, b, a);
 }
        private static List <GUIStyle> GeneralStyles()
        {
            List <GUIStyle> styles = new List <GUIStyle>
            {
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonCollapseSideBar), EZResources.sideButtonCollapseSideBar, QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(2, 28, 2, 2), new RectOffset(2, 32, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonExpandSideBar), EZResources.sideButtonExpandSideBar, QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(2, 28, 2, 2), new RectOffset(2, 32, 2, 4)),

                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonControlPanel), EZResources.sideButtonControlPanel, QUI.IsProSkin ? QColors.BlueLight.Color : QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonDefineSymbols), EZResources.sideButtonDefineSymbols, QUI.IsProSkin ? QColors.BlueLight.Color :QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonDataManager), EZResources.sideButtonDataManager, QUI.IsProSkin ? QColors.BlueLight.Color :QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonDataBind), EZResources.sideButtonDataBind, QUI.IsProSkin ? QColors.BlueLight.Color :QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonPooly), EZResources.sideButtonPooly, QUI.IsProSkin ? QColors.BlueLight.Color :QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonAdsManager), EZResources.sideButtonAdsManager, QUI.IsProSkin ? QColors.BlueLight.Color :QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonHelpBtnHelp), EZResources.sideButtonHelp, QUI.IsProSkin ? QColors.BlueLight.Color :QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonAbout), EZResources.sideButtonAbout, QUI.IsProSkin ? QColors.BlueLight.Color :QColors.BlueDark.Color, QColors.BlueDark.Color, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),

                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonTwitter), EZResources.sideButtonTwitter, ColorExtensions.ColorFrom256(128, 128, 128), ColorExtensions.ColorFrom256(242, 242, 242), ColorExtensions.ColorFrom256(0, 153, 209), new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4), 14),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonFacebook), EZResources.sideButtonFacebook, ColorExtensions.ColorFrom256(128, 128, 128), ColorExtensions.ColorFrom256(242, 242, 242), ColorExtensions.ColorFrom256(74, 112, 186), new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4), 14),
                GetSideButtonStyle(QStyles.GetStyleName(General.SideButtonYoutube), EZResources.sideButtonYoutube, ColorExtensions.ColorFrom256(128, 128, 128), ColorExtensions.ColorFrom256(242, 242, 242), ColorExtensions.ColorFrom256(255, 102, 102), new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4), 14),

                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedControlPanel), EZResources.sideButtonControlPanelSelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedDefineSymbols), EZResources.sideButtonDefineSymbolsSelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedDataManager), EZResources.sideButtonDataManagerSelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedDataBind), EZResources.sideButtonDataBindSelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedPooly), EZResources.sideButtonPoolySelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedAdsManager), EZResources.sideButtonAdsManagerSelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedHelpBtnHelp), EZResources.sideButtonHelpSelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
                GetSideButtonSelectedStyle(QStyles.GetStyleName(General.SideButtonSelectedAbout), EZResources.sideButtonAboutSelected, QColors.GreenLight.Color, new RectOffset(28, 2, 2, 2), new RectOffset(32, 2, 2, 4)),
            };

            return(styles);
        }
        private static List <GUIStyle> SideButtonStyles()
        {
            RectOffset expandCollapseBorder  = new RectOffset(2, 28, 2, 2);
            RectOffset expandCollapsePadding = new RectOffset(2, 32, 2, 4);

            RectOffset border   = new RectOffset(28, 2, 2, 2);
            RectOffset padding  = new RectOffset(32, 2, 2, 2);
            int        fontSize = 16;

            RectOffset socialButtonBorder   = new RectOffset(28, 2, 2, 2);
            RectOffset socialButtonPadding  = new RectOffset(28, 2, 2, 2);
            int        socialButtonFontSize = 12;

            Color normalGray   = QUI.IsProSkin ? QColors.UnityMild.Color : QColors.UnityMild.Color;
            Color activeBlue   = QUI.IsProSkin ? QColors.Blue.Color : QColors.BlueDark.Color;
            Color hoverBlue    = QUI.IsProSkin ? QColors.BlueDark.Color : QColors.BlueDark.Color;
            Color selectedBlue = QUI.IsProSkin ? QColors.BlueLight.Color : QColors.BlueDark.Color;


            return(new List <GUIStyle>()
            {
                SideButtonStyle(QStyles.GetStyleName(SideButton.CollapseSideBar), DUIResources.sideButtonCollapseSideBar, normalGray, activeBlue, hoverBlue, expandCollapseBorder, expandCollapsePadding),
                SideButtonStyle(QStyles.GetStyleName(SideButton.ExpandSideBar), DUIResources.sideButtonExpandSideBar, normalGray, activeBlue, hoverBlue, expandCollapseBorder, expandCollapsePadding),

                SideButtonStyle(QStyles.GetStyleName(SideButton.ControlPanel), DUIResources.sideButtonControlPanel, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.ControlPanelSelected), DUIResources.sideButtonControlPanelSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.UIElements), DUIResources.sideButtonUIElements, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.UIElementsSelected), DUIResources.sideButtonUIElementsSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.UIButtons), DUIResources.sideButtonUIButtons, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.UIButtonsSelected), DUIResources.sideButtonUIButtonsSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.UISounds), DUIResources.sideButtonUISounds, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.UISoundsSelected), DUIResources.sideButtonUISoundsSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.UICanvases), DUIResources.sideButtonUICanvases, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.UICanvasesSelected), DUIResources.sideButtonUICanvasesSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.AnimatorPresets), DUIResources.sideButtonAnimatorPresets, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.AnimatorPresetsSelected), DUIResources.sideButtonAnimatorPresetsSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.EditorSettings), DUIResources.sideButtonEditorSettings, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.EditorSettingsSelected), DUIResources.sideButtonEditorSettingsSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.Help), DUIResources.sideButtonHelp, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.HelpSelected), DUIResources.sideButtonHelpSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.About), DUIResources.sideButtonAbout, normalGray, activeBlue, hoverBlue, border, padding, fontSize),
                SideButtonSelectedStyle(QStyles.GetStyleName(SideButton.AboutSelected), DUIResources.sideButtonAboutSelected, selectedBlue, border, padding, fontSize),

                SideButtonStyle(QStyles.GetStyleName(SideButton.Twitter), DUIResources.sideButtonTwitter, ColorExtensions.ColorFrom256(128, 128, 128), ColorExtensions.ColorFrom256(242, 242, 242), ColorExtensions.ColorFrom256(0, 153, 209), socialButtonBorder, socialButtonPadding, socialButtonFontSize),
                SideButtonStyle(QStyles.GetStyleName(SideButton.Facebook), DUIResources.sideButtonFacebook, ColorExtensions.ColorFrom256(128, 128, 128), ColorExtensions.ColorFrom256(242, 242, 242), ColorExtensions.ColorFrom256(74, 112, 186), socialButtonBorder, socialButtonPadding, socialButtonFontSize),
                SideButtonStyle(QStyles.GetStyleName(SideButton.Youtube), DUIResources.sideButtonYoutube, ColorExtensions.ColorFrom256(128, 128, 128), ColorExtensions.ColorFrom256(242, 242, 242), ColorExtensions.ColorFrom256(255, 102, 102), socialButtonBorder, socialButtonPadding, socialButtonFontSize),
            });
        }
Exemple #7
0
 public QColor(float r, float g, float b, float a, bool from256 = true)
 {
     SetColor(from256 ? ColorExtensions.ColorFrom256(r, g, b, a) : new Color(r, g, b, a));
 }