public override void OnInspectorGUI()
        {
            UiLayoutSettings layoutSettings = target as UiLayoutSettings;

            GUIStyle style = new GUIStyle(GUI.skin.GetStyle("HelpBox"));

            style.padding = new RectOffset(7, 7, 7, 7);

            GUILayout.BeginVertical(style);
            layoutSettings.DefaultContainer = (RectTransform)EditorGUILayout.ObjectField("Default Container", layoutSettings.DefaultContainer, typeof(RectTransform), allowSceneObjects: true);
            GUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Screens Presets");
            _dynamicItemSelected = RenderList(layoutSettings.Screens, _dynamicItemSelected, ItemType.Screen);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Panels Presets");
            _staticItemSelected = RenderList(layoutSettings.Panels, _staticItemSelected, ItemType.Panel);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Popups Presets");
            _popupItemSelected = RenderList(layoutSettings.Popups, _popupItemSelected, ItemType.Popup);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Custom Signals");
            RenderSignals();

            EditorGUILayout.Space();
        }
Exemplo n.º 2
0
 // Resets UnityExpansion component to default state.
 private void Reset()
 {
     if (LayoutSettings == null)
     {
         LayoutSettings           = gameObject.GetOrAddComponent <UiLayoutSettings>();
         LayoutSettings.hideFlags = HideFlags.HideInInspector;
     }
 }
Exemplo n.º 3
0
        public static List <UiLayoutSettings.Signal> GetSignals()
        {
            UiLayoutSettings[] components = GameObject.FindObjectsOfType(typeof(UiLayoutSettings)) as UiLayoutSettings[];

            if (components != null && components.Length > 0)
            {
                UiLayoutSettings layoutSettings = components[0];
                return(layoutSettings.Signals);
            }

            return(new List <UiLayoutSettings.Signal>());
        }
        private void OnItemSetActiveByDefault(List <UiLayoutPreset> list, UiLayoutPreset item, bool value)
        {
            UiLayoutSettings layout = target as UiLayoutSettings;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] != item)
                {
                    list[i].ActiveByDefault = false;
                }
            }

            item.ActiveByDefault = value;
        }
        private UiLayoutPreset RenderList(List <UiLayoutPreset> list, UiLayoutPreset listItemSelected, ItemType type)
        {
            UiLayoutSettings layoutSettings = target as UiLayoutSettings;

            GUILayout.BeginVertical(new GUIStyle(GUI.skin.GetStyle("HelpBox")));

            if (list.Count == 0)
            {
                switch (type)
                {
                case ItemType.Screen:
                    EditorGUILayout.HelpBox("\nScreens is a basic layout elements like Main Menu, Choosing of level, Settings, etc. Only one slide can be active at the same time so if new slide shown then the old one will be automatically hidden. \n", MessageType.Info);
                    break;

                case ItemType.Panel:
                    EditorGUILayout.HelpBox("\nPanels is an additional layout elements like header, footer, etc. Panels can be shown and hided separatelly at any time. \n", MessageType.Info);
                    break;

                case ItemType.Popup:
                    EditorGUILayout.HelpBox("\nPopups is a overlaing layout elements like alerts, confirms and etc. Unlimited amount of same popups can be shown at the same time. After popup is hidden it's instance will be destroyed. \n", MessageType.Info);
                    break;
                }
            }

            // Items
            for (int i = 0; i < list.Count; i++)
            {
                listItemSelected = RenderListItem(list, list[i], i, listItemSelected, type);
            }

            // Buttons
            GUIStyle buttonsStyle = new GUIStyle();

            buttonsStyle.margin.left = -5;

            GUIStyle buttonStyle = new GUIStyle(GUI.skin.GetStyle("HelpBox"));

            buttonStyle.alignment    = TextAnchor.MiddleCenter;
            buttonStyle.stretchWidth = false;
            buttonStyle.fixedWidth   = 100;
            buttonStyle.fixedHeight  = 26;

            GUILayout.BeginHorizontal(buttonsStyle);

            EditorGUI.BeginChangeCheck();
            GUILayout.Button("ADD", buttonStyle);

            if (EditorGUI.EndChangeCheck())
            {
                InternalUtilities.SetDirty(target);

                UiLayoutPreset itemNew = new UiLayoutPreset();

                itemNew.Container = layoutSettings.DefaultContainer;

                list.Add(itemNew);
                listItemSelected = itemNew;
            }

            if (listItemSelected != null)
            {
                EditorGUI.BeginChangeCheck();
                GUILayout.Button("REMOVE", buttonStyle);
                if (EditorGUI.EndChangeCheck())
                {
                    InternalUtilities.SetDirty(target);

                    list.Remove(listItemSelected);
                    listItemSelected = null;
                }
            }

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            return(listItemSelected);
        }