Skip to content

Commit ad4a91a

Browse files
committed
Merge branch 'hotfix/1.5.1'
2 parents e744800 + 7dccc0b commit ad4a91a

File tree

8 files changed

+41
-61
lines changed

8 files changed

+41
-61
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.5.1]
9+
10+
### Fixed
11+
12+
- It wasn't possible to create custom character properties in the first execution
13+
814
## [1.5.0]
915

1016
### Added

Editor/Scripts/Model/BitmapFontCreatorModel.cs

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,24 @@ internal class BitmapFontCreatorModel : ISerializationCallbackReceiver
1010
private const string IgnoreCharacter = "\n";
1111

1212
[SerializeField] private string _characters = string.Empty;
13-
public Orientation Orientation;
14-
public int Cols;
15-
public int Rows;
16-
public float AlphaThreshold;
17-
public bool Monospaced;
18-
public bool CaseInsentive;
19-
public float Ascent;
20-
public float Descent;
21-
public float FontSize;
22-
public bool AutoFontSize;
23-
public float LineSpacing;
24-
public bool AutoLineSpacing;
25-
public int DefaultCharacterSpacing;
26-
public List<CharacterProps> CustomCharacterProps;
13+
public Orientation Orientation = Orientation.Horizontal;
14+
public int Cols = 1;
15+
public int Rows = 1;
16+
public float AlphaThreshold = 0f;
17+
public bool Monospaced = false;
18+
public bool CaseInsentive = false;
19+
public int Ascent = 0;
20+
public int Descent = 0;
21+
public int FontSize = 0;
22+
public bool AutoFontSize = true;
23+
public int LineSpacing = 0;
24+
public bool AutoLineSpacing = true;
25+
public int DefaultCharacterSpacing = 0;
26+
public List<CharacterProps> CustomCharacterProps = new();
27+
28+
public BitmapFontCreatorModel() { }
29+
30+
public BitmapFontCreatorModel(BitmapFontCreatorModel from) { from?.CopyTo(this); }
2731

2832
public string Characters
2933
{
@@ -75,26 +79,5 @@ private void UpdateChacters()
7579

7680
public void OnBeforeSerialize() { }
7781
public void OnAfterDeserialize() { UpdateChacters(); }
78-
79-
public static BitmapFontCreatorModel Default => new()
80-
{
81-
Characters = string.Empty,
82-
Orientation = Orientation.Horizontal,
83-
Cols = 1,
84-
Rows = 1,
85-
AlphaThreshold = 0f,
86-
LineSpacing = 0f,
87-
AutoLineSpacing = true,
88-
FontSize = 0f,
89-
AutoFontSize = true,
90-
Monospaced = false,
91-
CaseInsentive = false,
92-
Ascent = 0f,
93-
Descent = 0f,
94-
DefaultCharacterSpacing = 0,
95-
CustomCharacterProps = new List<CharacterProps>(),
96-
ValidCharacters = string.Empty,
97-
ValidCharactersCount = 0
98-
};
9982
}
10083
}

Editor/Scripts/Model/ExecutionData.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ namespace dev.klebersilva.tools.bitmapfontcreator
66
[Serializable]
77
internal class ExecutionData : BitmapFontCreatorModel
88
{
9-
public Texture2D Texture;
9+
public Texture2D Texture = null;
1010

11-
public static new ExecutionData Default
11+
public ExecutionData() : base() { }
12+
public ExecutionData(BitmapFontCreatorModel from) : base(from) { }
13+
14+
public override void CopyTo(BitmapFontCreatorModel to)
1215
{
13-
get
14-
{
15-
var data = new ExecutionData { Texture = null };
16-
BitmapFontCreatorModel.Default.CopyTo(data);
17-
return data;
18-
}
16+
base.CopyTo(to);
17+
if (to is ExecutionData t) t.Texture = Texture;
1918
}
2019
}
2120
}

Editor/Scripts/Model/RuntimeData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal class RuntimeData : ScriptableObject
1111
public static RuntimeData Load()
1212
{
1313
var data = Resources.Load<RuntimeData>(DataPath);
14-
data.Data ??= ExecutionData.Default;
14+
data.Data ??= new ExecutionData();
1515
return data;
1616
}
1717
}

Editor/Scripts/UI/Partials/BottomMenu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ private void DrawBottomMenu()
3131

3232
private void RollbackSettings()
3333
{
34-
var profile = (BitmapFontCreatorModel)_settings.Profiles.Selected ?? ExecutionData.Default;
34+
var profile = (BitmapFontCreatorModel)_settings.Profiles.Selected ?? new ExecutionData();
3535
profile.CopyTo(_data);
3636
}
3737

3838
private void ClearSettings()
3939
{
40-
ExecutionData.Default.CopyTo(_data);
40+
new ExecutionData().CopyTo(_data);
4141
}
4242
}
4343
}

Editor/Scripts/UI/Partials/FontGroup.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ private void DrawFontInfoGroup()
88
{
99
EditorGUILayout.BeginVertical(Styles.Group);
1010

11-
_data.FontSize = UIUtils.FloatFieldWithAuto(UIContent.FontSize, _data.FontSize, UIContent.AutoFontSize, ref _data.AutoFontSize);
12-
_data.LineSpacing = UIUtils.FloatFieldWithAuto(UIContent.LineSpacing, _data.LineSpacing, UIContent.AutoLineSpacing, ref _data.AutoLineSpacing);
13-
_data.Ascent = UIUtils.FloatFieldMin(UIContent.Ascent, _data.Ascent, 0f);
14-
_data.Descent = UIUtils.FloatFieldMin(UIContent.Descent, _data.Descent, 0f);
11+
_data.FontSize = UIUtils.IntFieldWithAuto(UIContent.FontSize, _data.FontSize, UIContent.AutoFontSize, ref _data.AutoFontSize);
12+
_data.LineSpacing = UIUtils.IntFieldWithAuto(UIContent.LineSpacing, _data.LineSpacing, UIContent.AutoLineSpacing, ref _data.AutoLineSpacing);
13+
_data.Ascent = UIUtils.IntFieldMin(UIContent.Ascent, _data.Ascent, 0);
14+
_data.Descent = UIUtils.IntFieldMin(UIContent.Descent, _data.Descent, 0);
1515
_data.Monospaced = EditorGUILayout.Toggle(UIContent.Monospaced, _data.Monospaced);
1616

1717
EditorGUILayout.EndVertical();

Editor/Scripts/UI/Util/UIUtils.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ namespace dev.klebersilva.tools.bitmapfontcreator
55
{
66
internal static class UIUtils
77
{
8-
public static float FloatFieldMin(GUIContent label, float value, float min)
9-
{
10-
EditorGUI.BeginChangeCheck();
11-
value = EditorGUILayout.FloatField(label, value);
12-
if (EditorGUI.EndChangeCheck() && value < min) value = min;
13-
return value;
14-
}
15-
168
public static int IntFieldMin(GUIContent label, int value, int min)
179
{
1810
EditorGUI.BeginChangeCheck();
@@ -21,11 +13,11 @@ public static int IntFieldMin(GUIContent label, int value, int min)
2113
return value;
2214
}
2315

24-
public static float FloatFieldWithAuto(GUIContent label, float value, GUIContent autoLabel, ref bool auto)
16+
public static int IntFieldWithAuto(GUIContent label, int value, GUIContent autoLabel, ref bool auto)
2517
{
2618
GUILayout.BeginHorizontal();
2719
GUI.enabled = !auto;
28-
value = EditorGUILayout.FloatField(label, value);
20+
value = EditorGUILayout.IntField(label, value);
2921
GUI.enabled = true;
3022

3123
auto = EditorGUILayout.ToggleLeft(autoLabel, auto, GUILayout.Width(Styles.AutoToggleWidth));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dev.klebersilva.tools.bitmapfontcreator",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "Create bitmap fonts from sprite sheets in Unity.",
55
"displayName": "Bitmap Font Creator",
66
"unity": "2018.3",

0 commit comments

Comments
 (0)