protected internal static void EditSprite(string label, dfFont font, string propertyName, int labelWidth) { var atlas = font.Atlas; if (atlas == null) { return; } dfSpriteSelectionDialog.SelectionCallback callback = delegate(string spriteName) { dfEditorUtil.MarkUndo(font, "Change Sprite"); font.Sprite = spriteName; }; var value = font.Sprite; EditorGUILayout.BeginHorizontal(); { GUILayout.Label(label, GUILayout.Width(labelWidth)); var displayText = string.IsNullOrEmpty(value) ? "[none]" : value; GUILayout.Label(displayText, "TextField", GUILayout.ExpandWidth(true)); var evt = Event.current; if (evt != null && evt.type == EventType.MouseDown && evt.clickCount == 2) { Rect rect = GUILayoutUtility.GetLastRect(); if (rect.Contains(evt.mousePosition)) { if (GUI.enabled && value != null) { dfTextureAtlasInspector.SelectedSprite = value; Selection.activeObject = atlas; EditorGUIUtility.PingObject(atlas); } } } if (GUILayout.Button(new GUIContent(" ", "Edit " + label), "IN ObjectField", GUILayout.Width(12))) { dfEditorUtil.DelayedInvoke((System.Action)(() => { dfSpriteSelectionDialog.Show("Select Sprite: " + label, atlas, value, callback); })); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(2); }
protected internal void EditSprite(string label, int labelWidth) { var atlas = target as dfAtlas; if (atlas == null) { return; } dfSpriteSelectionDialog.SelectionCallback callback = delegate(string spriteName) { EditorUtility.SetDirty(target); SelectedSprite = spriteName; }; var value = SelectedSprite; EditorGUILayout.BeginHorizontal(); { GUILayout.Label(label, GUILayout.Width(labelWidth)); var displayText = string.IsNullOrEmpty(value) ? "[none selected]" : value; GUILayout.Label(displayText, "TextField", GUILayout.ExpandWidth(true)); if (GUILayout.Button(new GUIContent(" ", "Edit " + label), "IN ObjectField", GUILayout.Width(12))) { dfEditorUtil.DelayedInvoke((System.Action)(() => { dfSpriteSelectionDialog.Show("Select Sprite: " + label, atlas, value, callback); })); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(2); }