예제 #1
0
        private void ColorGUI()
        {
            GUILayout.BeginHorizontal(FolderInspector.toolBarStyle);
            EditorGUILayout.LabelField(GUIHelper.ContentFromEditor("Background", "PreTextureMipMapHigh"), FolderInspector.toolBarLabelStyle);
            styleProperties.colorType = (ColorType)EditorGUILayout.EnumPopup("", styleProperties.colorType, FolderInspector.toolBarPopupStyle, GUILayout.ExpandWidth(false), GUILayout.Width(150.0f));
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical();
            GUILayout.Space(4);

            if (styleProperties.colorType == ColorType.SolidColor)
            {
                styleColor   = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), "Background color", styleColor);
                styleColor.a = 1.0F;
            }
            else
            {
                MethodInfo[] methods = typeof(EditorGUI).GetMethods(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public);
                MethodInfo   method  = methods.FirstOrDefault(t => t.Name == "GradientField" && t.GetParameters().Length == 3 && t.GetParameters()[1].ParameterType == typeof(string));
                if (method == null)
                {
                    methods = typeof(EditorGUILayout).GetMethods(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public);
                    method  = methods.FirstOrDefault(t => t.Name == "GradientField" && t.GetParameters().Length == 3 && t.GetParameters()[0].ParameterType == typeof(string) && t.GetParameters()[1].ParameterType == typeof(Gradient) && t.GetParameters()[2].ParameterType == typeof(GUILayoutOption[]));
                    styleProperties.gradient = (Gradient)method.Invoke(null, new object[] { "Gradient colors", styleProperties.gradient, null });
                }
                else
                {
                    styleProperties.gradient = (Gradient)method.Invoke(null, new object[] { EditorGUILayout.GetControlRect(), "Gradient colors", styleProperties.gradient });
                }

                styleProperties.offset = DisplayOffsetField("Background Offset", 140, styleProperties.offset);

                if (styleProperties.colorType == ColorType.AxialGradient)
                {
                    styleProperties.angle = EditorGUILayout.IntSlider("Gradient angle", styleProperties.angle, 0, 359);
                }
            }

            GUILayout.Space(2);
            EditorGUILayout.EndVertical();
        }
예제 #2
0
        public void OnGUI()
        {
            ResourceUtil.Refresh();
            InitEditorStyles();

            // Is sub window activated ?
            if (nfsi != null)
            {
                currentScrollPos = EditorGUILayout.BeginScrollView(currentScrollPos);
                nfsi.OnInspectorGUI(this);

                EditorGUILayout.EndScrollView();
                return;
            }

            if (!TitleBarGUI())
            {
                return;
            }

            // Custom style foldout
            currentScrollPos = EditorGUILayout.BeginScrollView(currentScrollPos);

            EditorGUILayout.BeginHorizontal(toolBarStyle);
            EditorGUILayout.LabelField("Project styles:", toolBarLabelStyle);
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(GUIHelper.ContentFromEditor("New", "Toolbar Plus"), toolBarButtonStyle))
            {
                nfsi = new NewFolderStyleInspector(null, false);
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.BeginVertical(styleListBackgroundStyle);
            GUILayout.Space(6);
            ButtonGrid.ButtonAction styleAction = customStyles.DrawGrid();
            if (styleAction != null)
            {
                if (styleAction.IsLeftClick)
                {
                    ApplyStyle((StyleGrid.StyleElement)styleAction.ClickedElement);
                }
                else
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Create variant"), false, CreateVariant, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.AddItem(new GUIContent("Edit"), false, EditStyle, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.AddItem(new GUIContent("Delete"), false, AskDeleteStyle, (StyleGrid.StyleElement)styleAction.ClickedElement);
                    menu.ShowAsContext();
                }
            }
            GUILayout.Space(2);
            GUILayout.EndVertical();

            EditorGUILayout.BeginHorizontal(toolBarStyle);
            GUILayout.FlexibleSpace();

            /*if (GUILayout.Button("Download Style packs", toolBarButtonStyle))
             * {
             *      //nfsi = new NewFolderStyleInspector();
             * }*/
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndScrollView();
        }