Пример #1
0
        static public void Show(Color preSelect, System.Action <Color> callback)
        {
            selfW = (ColorPickerWindow)EditorWindow.GetWindow <ColorPickerWindow>(true);

            selfW.title   = "Pick an Icon";
            selfW.minSize = new Vector2(410, 529);
            selfW.maxSize = new Vector2(410, 529);

            labelStyle = new GUIStyle();
            var fontGUID = AssetDatabase.FindAssets("Roboto-Light")[0];

            labelStyle.font = AssetDatabase.LoadAssetAtPath <Font>(AssetDatabase.GUIDToAssetPath(fontGUID));

            iconTextStyle                  = new GUIStyle();
            fontGUID                       = AssetDatabase.FindAssets("Roboto-Medium")[0];
            iconTextStyle.font             = AssetDatabase.LoadAssetAtPath <Font>(AssetDatabase.GUIDToAssetPath(fontGUID));
            iconTextStyle.alignment        = TextAnchor.LowerCenter;
            iconTextStyle.normal.textColor = MaterialDesignColorset.grey600;
            iconTextStyle.fontSize         = 12;

            buttonStyle = new GUIStyle();

            selfW.onSelectionChanged = callback;
            List <Color> tempList = MaterialDesignColorset.colorSets;

            if (tempList.Contains(preSelect))
            {
                selfW.selected   = preSelect;
                selfW.selectedID = tempList.IndexOf(selfW.selected);
                int lineOfSelection = selfW.selectedID / itemPerLine - 1;
                selfW.scrollPosition = new Vector2(0f, lineOfSelection * (iconSize + spacing));
            }

            selfW.ShowUtility();
        }
Пример #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_Size);
            EditorGUILayout.PropertyField(m_Color);
            icon.UpdateScale();
            if (GUILayout.Button("Pick an Icon"))
            {
                IconPickerWindow.Show(icon.text, (t) => icon.text = t);
            }
            if (GUILayout.Button("Pick Material Design Color"))
            {
                ColorPickerWindow.Show(icon.color, (t) => icon.color = t);
            }

            serializedObject.ApplyModifiedProperties();
        }