Skip to content

Commit 7bba07c

Browse files
authored
Merge pull request #474 from Unity-Technologies/UT-2049-UI-fixes
UT-2049 implement Gabriel's UI fixes
2 parents 6b5386b + 9d0a3e3 commit 7bba07c

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

com.unity.formats.fbx/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,18 @@ protected override void OnEnable()
104104
}
105105

106106
/// <summary>
107-
/// Get a list of all the export set objects that contain
108-
/// RectTransforms or have children with RectTransforms.
107+
/// Return the number of objects in the selection that contain RectTransforms.
109108
/// </summary>
110-
/// <param name="uiObjectNames">names of objects in set which contain RectTransforms</param>
111-
/// <returns>Whethere there are any UI elements in the export set</returns>
112-
protected bool GetUIElementsInExportSet(out List<string> uiObjectNames)
109+
protected int GetUIElementsInExportSetCount()
113110
{
114-
uiObjectNames = new List<string>();
111+
int count = 0;
115112
foreach (var obj in GetToExport())
116113
{
117114
var go = ModelExporter.GetGameObject(obj);
118-
if (go.GetComponentInChildren<RectTransform>())
119-
{
120-
uiObjectNames.Add(go.name);
121-
}
115+
var rectTransforms = go.GetComponentsInChildren<RectTransform>();
116+
count += rectTransforms.Length;
122117
}
123-
return uiObjectNames.Count > 0;
118+
return count;
124119
}
125120

126121
protected bool ExportSetContainsAnimation()
@@ -163,14 +158,14 @@ protected override bool Export()
163158
return false;
164159
}
165160

166-
List<string> hierarchiesWithUI;
167-
if (GetUIElementsInExportSet(out hierarchiesWithUI))
161+
int rectTransformCount = GetUIElementsInExportSetCount();
162+
if (rectTransformCount > 0)
168163
{
169164
// Warn that UI elements will break if converted
170-
string warning = string.Format("RectTransform and other UI components will be lost if the following GameObject hierarchies are converted:\n\n{0}\n",
171-
string.Join("\n", hierarchiesWithUI));
165+
string warning = string.Format("Warning: UI Components (ie, RectTransform) are not saved when converting to FBX.\n{0} item(s) in the selection will lose their UI components.",
166+
rectTransformCount);
172167
bool result = UnityEditor.EditorUtility.DisplayDialog(
173-
string.Format("{0} Warning", ModelExporter.PACKAGE_UI_NAME), warning, "Convert and lose UI", "Cancel");
168+
string.Format("{0} Warning", ModelExporter.PACKAGE_UI_NAME), warning, "Convert and Lose UI", "Cancel");
174169

175170
if (!result)
176171
{

0 commit comments

Comments
 (0)