public static void Init(Font MaterialIconsRegular, string preSelect, System.Action <string> callback)
        {
            MaterialIconSelectionWindow window = EditorWindow.GetWindow <MaterialIconSelectionWindow>(true);

            window.selected           = preSelect;
            window.onSelectionChanged = callback;
            window.LoadDependencies(MaterialIconsRegular);
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (MaterialIconsRegular == null)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("Could not find \"MaterialIcons-Regular\" font data.", MessageType.Error);
            }

            EditorGUILayout.Space();

            EditorGUI.BeginDisabledGroup(MaterialIconsRegular == null);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Icon");

            Rect irect = GUILayoutUtility.GetRect(60f, 60f, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));

            if (GUI.Button(irect, iconTooltip))
            {
                MaterialIconSelectionWindow.Init(MaterialIconsRegular, icon.text, (selected) => {
                    Undo.RecordObject(icon, "Inspector");
                    icon.text = selected;
                    EditorUtility.SetDirty(icon);
                    iconTooltip = new GUIContent(string.Empty, icon.iconUnicode);
                    Repaint();
                });
            }
            GUI.Label(irect, icon.text, iconStyle);

            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Color"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RaycastTarget"));

            EditorGUILayout.Space();

            Rect alignmentRect = GUILayoutUtility.GetRect(EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));

            DoTextAligmentControl(alignmentRect, serializedObject.FindProperty("m_FontData.m_Alignment"));

            serializedObject.ApplyModifiedProperties();
        }