public static void Show(string preSelect, System.Action <string, string> callback) { selfW = GetWindow <IconPickerWindow>(true); selfW.title = "Pick an Icon"; selfW.minSize = new Vector2(410, 560); selfW.maxSize = new Vector2(1000, 960); iconStyle = new GUIStyle(); iconStyle.font = Definitions.Font; iconStyle.alignment = TextAnchor.MiddleCenter; iconStyle.normal.textColor = Color.gray; iconStyle.fontSize = ICON_SIZE; textStyle = new GUIStyle(); textStyle.fontStyle = FontStyle.Bold; textStyle.alignment = TextAnchor.MiddleCenter; textStyle.normal.textColor = Color.gray; textStyle.fontSize = 12; selfW.onSelectionChanged = callback; selfW.selected = preSelect; selfW.ShowUtility(); }
public override void OnInspectorGUI() { serializedObject.Update(); //MAIN GUILayout.BeginVertical(); { EditorGUILayout.PropertyField(m_Size, new GUIContent("Size")); if (_image.size < 0) { _image.size = 0; } if (_image.size > 300) { _image.size = 300; } iconStyle.fontSize = (int)_image.size; _image.UpdateScale(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_Color, new GUIContent("Color")); iconStyle.normal.textColor = _image.color; EditorGUILayout.EndHorizontal(); if (GUILayout.Button(_image.text, iconStyle)) { IconPickerWindow.Show(_image.iconName, (myname, unicode) => { _image.text = unicode; _image.iconName = myname; }); } EditorGUILayout.LabelField(_image.iconName, nameStyle); } GUILayout.EndVertical(); //EXTRA GUILayout.BeginHorizontal("Box"); { m_IsSwappable.boolValue = EditorGUILayout.Foldout(m_IsSwappable.boolValue, new GUIContent("Extra Icon", "Enable Extra Icon")); //EditorGUILayout.PropertyField(m_IsSwappable, new GUIContent("Extra Icon", "Enable Extra Icon")); if (m_IsSwappable.boolValue) { if (GUILayout.Button("Swap", GUILayout.Width(100))) { _image.SwapIcon(); } } serializedObject.ApplyModifiedProperties(); } GUILayout.EndHorizontal(); if (m_IsSwappable.boolValue) { if (string.IsNullOrEmpty(m_ExtraText.stringValue)) { InitExtraIcon(); } GUILayout.BeginVertical(); { EditorGUILayout.PropertyField(m_ExtraSize, new GUIContent("Size")); if (_image.size < 0) { _image.size = 0; } if (_image.size > 300) { _image.size = 300; } iconStyle.fontSize = (int)m_ExtraSize.floatValue; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_ExtraColor, new GUIContent("Color")); iconStyle.normal.textColor = m_ExtraColor.colorValue; EditorGUILayout.EndHorizontal(); if (GUILayout.Button(m_ExtraText.stringValue, iconStyle)) { IconPickerWindow.Show(m_ExtraName.stringValue, (newName, unicode) => { m_ExtraText.stringValue = unicode; m_ExtraName.stringValue = newName; serializedObject.ApplyModifiedProperties(); }); } EditorGUILayout.LabelField(m_ExtraName.stringValue, nameStyle); } GUILayout.EndVertical(); } EditorUtility.SetDirty(_image); serializedObject.ApplyModifiedProperties(); }