Skip to content

Commit 910b755

Browse files
committed
Merge branch 'master' into convert-to-prefab-variant-UI-fixes
2 parents 3007cd2 + 5c72390 commit 910b755

File tree

147 files changed

+167
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+167
-166
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,3 @@ TestProjects/FbxTests/Logs/*
7979
com.unity.formats.fbx/Editor/Integrations~/**
8080
com.unity.formats.fbx/CHANGELOG.md
8181
com.unity.formats.fbx/LICENSE.md
82-
com.unity.formats.fbx/package.json
83-

.yamato/upm-ci.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
editors:
2+
- version: 2018.3
3+
- version: 2019.1
4+
- version: 2019.2
5+
platforms:
6+
- name: win
7+
type: Unity::VM
8+
image: package-ci/win10:stable
9+
flavor: m1.large
10+
- name: mac
11+
type: Unity::VM::osx
12+
image: buildfarm/mac:stable
13+
flavor: m1.mac
14+
---
15+
pack:
16+
name: Pack
17+
agent:
18+
type: Unity::VM
19+
image: package-ci/ubuntu:latest
20+
flavor: m1.large
21+
commands:
22+
- ./build.sh
23+
- npm install -g upm-ci-utils@latest --registry https://api.bintray.com/npm/unity/unity-npm
24+
- upm-ci package pack --package-path com.unity.formats.fbx
25+
artifacts:
26+
packages:
27+
paths:
28+
- "upm-ci~/packages/**/*"
29+
build:
30+
paths:
31+
- "com.unity.formats.fbx/*"
32+
33+
{% for editor in editors %}
34+
{% for platform in platforms %}
35+
test_{{ platform.name }}_{{ editor.version }}:
36+
name : Test version {{ editor.version }} on {{ platform.name }}
37+
agent:
38+
type: {{ platform.type }}
39+
image: {{ platform.image }}
40+
flavor: {{ platform.flavor}}
41+
commands:
42+
- git clone --branch dev --single-branch [email protected]:upm-packages/project-templates/upm-template-utils.git upm-ci-utils
43+
- npm install upm-ci-utils/ -g
44+
- upm-ci package test --unity-version {{ editor.version }} --package-path com.unity.formats.fbx
45+
artifacts:
46+
logs.zip:
47+
paths:
48+
- "upm-ci~/logs/**/*"
49+
- "upm-ci~/test-results/**/*"
50+
artifacts.zip:
51+
paths:
52+
- "upm-ci~/packages/**/*"
53+
- "upm-ci~/templates/**/*"
54+
dependencies:
55+
- .yamato/upm-ci.yml#pack
56+
{% endfor %}
57+
{% endfor %}
58+
59+
test_trigger:
60+
name: Tests Trigger
61+
agent:
62+
type: Unity::VM
63+
image: package-ci/win10:stable
64+
flavor: m1.large
65+
commands:
66+
- dir
67+
triggers:
68+
branches:
69+
only:
70+
- "/.*/"
71+
except:
72+
- master
73+
artifacts:
74+
logs:
75+
paths:
76+
- "upm-ci~/test-results/**/*"
77+
packages:
78+
paths:
79+
- "upm-ci~/packages/**/*"
80+
dependencies:
81+
- .yamato/upm-ci.yml#pack
82+
{% for editor in editors %}
83+
{% for platform in platforms %}
84+
- .yamato/upm-ci.yml#test_{{platform.name}}_{{editor.version}}
85+
{% endfor %}
86+
{% endfor %}
87+
88+
publish:
89+
name: Publish
90+
agent:
91+
type: Unity::VM
92+
image: package-ci/win10:latest
93+
flavor: m1.large
94+
name: Runner
95+
commands:
96+
- npm install upm-ci-utils -g --registry https://api.bintray.com/npm/unity/unity-npm
97+
- upm-ci package publish
98+
triggers:
99+
tags:
100+
only:
101+
- /^(v|V)[0-9]+.[0-9]+.[0-9]+/
102+
artifacts:
103+
logs.zip:
104+
paths:
105+
- "upm-ci~/logs/**/*"
106+
- "upm-ci~/test-results/**/*"
107+
Package.zip:
108+
paths:
109+
- "upm-ci~/package/*.tgz"
110+
dependencies:
111+
{% for editor in editors %}
112+
{% for platform in platforms %}
113+
- .yamato/upm-ci.yml#test_{{ platform.name }}_{{ editor.version }}
114+
{% endfor %}
115+
{% endfor %}

CMakeLists.txt

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,6 @@ MESSAGE(STATUS "CMAKE_INSTALL_PREFIX is: " ${CMAKE_INSTALL_PREFIX})
55

66
project (UnityFbxExporterEditorPackage NONE)
77

8-
###########################################################################
9-
10-
# Get git tag as package version
11-
find_package(Git REQUIRED)
12-
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags HEAD
13-
OUTPUT_VARIABLE PACKAGE_VERSION
14-
OUTPUT_STRIP_TRAILING_WHITESPACE)
15-
# only keep x.y.z[-preview.n]
16-
string(REGEX REPLACE "^.*([0-9]\.[0-9]\.[0-9].*)$" "\\1" PACKAGE_VERSION "${PACKAGE_VERSION}")
17-
18-
# Get git revision hash as package revision
19-
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
20-
OUTPUT_VARIABLE PACKAGE_REVISION
21-
OUTPUT_STRIP_TRAILING_WHITESPACE)
22-
23-
# Get git repo url
24-
execute_process(COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url
25-
OUTPUT_VARIABLE PACKAGE_REPO_URL
26-
OUTPUT_STRIP_TRAILING_WHITESPACE)
27-
28-
configure_file(${CMAKE_SOURCE_DIR}/package.json.in ${CMAKE_BINARY_DIR}/package.json @ONLY)
29-
308
###########################################################################
319
# Zip integrations folder
3210

@@ -83,7 +61,7 @@ install(
8361
DESTINATION "${CMAKE_INSTALL_PREFIX}/com.unity.formats.fbx/Editor/Integrations~"
8462
)
8563
install(
86-
FILES "${CMAKE_SOURCE_DIR}/CHANGELOG.md" "${CMAKE_SOURCE_DIR}/LICENSE.md" "${CMAKE_BINARY_DIR}/package.json"
64+
FILES "${CMAKE_SOURCE_DIR}/CHANGELOG.md" "${CMAKE_SOURCE_DIR}/LICENSE.md"
8765
DESTINATION "${CMAKE_INSTALL_PREFIX}/com.unity.formats.fbx"
8866
)
8967

TestProjects/FbxTests/Packages/manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"com.unity.analytics": "3.2.2",
55
"com.unity.collab-proxy": "1.2.15",
66
"com.unity.formats.fbx": "file:../../../com.unity.formats.fbx",
7-
"com.unity.formats.fbx.tests": "file:../../../com.unity.formats.fbx.tests",
87
"com.unity.package-manager-ui": "2.1.1",
98
"com.unity.package-validation-suite": "0.4.0-preview.13",
109
"com.unity.purchasing": "2.0.1",

com.unity.formats.fbx.tests/package.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

com.unity.formats.fbx.tests/package.json.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,8 @@ internal static void CopySerializedProperty(SerializedObject serializedObject, S
840840
}
841841

842842
/// <summary>
843-
/// Copy components on the 'from' object which is the FBX,
844-
/// over to the 'to' object which is the object in the
845-
/// scene we exported.
843+
/// Copy components on the 'from' object which is the object being converted,
844+
/// over to the 'to' object which is the FBX.
846845
///
847846
/// Copy over everything except meshes and materials, since these
848847
/// are already in the FBX.
@@ -872,7 +871,10 @@ internal static void CopyComponents(GameObject to, GameObject from, GameObject r
872871
}
873872

874873
// ignore FbxPrefab (when converting LinkedPrefabs)
875-
if (fromComponent is UnityEngine.Formats.Fbx.Exporter.FbxPrefab)
874+
// Also ignore RectTransform, since it is not currently possible to switch transforms
875+
// in a prefab.
876+
if (fromComponent is UnityEngine.Formats.Fbx.Exporter.FbxPrefab ||
877+
fromComponent is RectTransform)
876878
{
877879
continue;
878880
}
@@ -920,6 +922,13 @@ internal static void CopyComponents(GameObject to, GameObject from, GameObject r
920922
toComponent = to.AddComponent(fromComponent.GetType());
921923
}
922924

925+
if (!toComponent)
926+
{
927+
// Failed to add component
928+
Debug.LogWarningFormat("{0}: Failed to add component of type {1} to converted object", ModelExporter.PACKAGE_UI_NAME, fromComponent.GetType().Name);
929+
continue;
930+
}
931+
923932
FixSceneReferences(fromComponent, toComponent, root);
924933

925934
// Do not try to copy materials for ParticleSystemRenderer, since it is not in the

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,26 @@ protected override void OnEnable()
103103
m_prefabExtLabelWidth = FbxExtLabelStyle.CalcSize(new GUIContent(".prefab")).x;
104104
}
105105

106+
/// <summary>
107+
/// Get a list of all the export set objects that contain
108+
/// RectTransforms or have children with RectTransforms.
109+
/// </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)
113+
{
114+
uiObjectNames = new List<string>();
115+
foreach (var obj in GetToExport())
116+
{
117+
var go = ModelExporter.GetGameObject(obj);
118+
if (go.GetComponentInChildren<RectTransform>())
119+
{
120+
uiObjectNames.Add(go.name);
121+
}
122+
}
123+
return uiObjectNames.Count > 0;
124+
}
125+
106126
protected bool ExportSetContainsAnimation()
107127
{
108128
foreach (var obj in GetToExport())
@@ -143,6 +163,21 @@ protected override bool Export()
143163
return false;
144164
}
145165

166+
List<string> hierarchiesWithUI;
167+
if (GetUIElementsInExportSet(out hierarchiesWithUI))
168+
{
169+
// 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));
172+
bool result = UnityEditor.EditorUtility.DisplayDialog(
173+
string.Format("{0} Warning", ModelExporter.PACKAGE_UI_NAME), warning, "Convert and lose UI", "Cancel");
174+
175+
if (!result)
176+
{
177+
return false;
178+
}
179+
}
180+
146181
if (SettingsObject.UseMayaCompatibleNames && SettingsObject.AllowSceneModification)
147182
{
148183
string warning = "Names of objects in the hierarchy may change with the Compatible Naming option turned on";

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,26 +170,6 @@ public override void OnInspectorGUI() {
170170
Debug.LogFormat ("Failed to update the FbxPrefab components in the following files:\n{0}", string.Join ("\n", assetsToRepair));
171171
}
172172
}
173-
174-
var prefabUpdater = new RepairLinkedPrefabs();
175-
var prefabsToUpdateCount = prefabUpdater.AssetsToRepairCount;
176-
if (prefabsToUpdateCount > 0)
177-
{
178-
bool result = UnityEditor.EditorUtility.DisplayDialog("Linked Prefab Updater",
179-
string.Format("Found {0} prefab(s) requiring update. If you choose 'Go Ahead', " +
180-
"these Linked Prefabs will be converted to a new Prefab Variant and FBX file.", prefabsToUpdateCount),
181-
"Go Ahead", "No Thanks"
182-
);
183-
if (result)
184-
{
185-
prefabUpdater.ConvertLinkedPrefabs();
186-
}
187-
else
188-
{
189-
var prefabsToUpdate = prefabUpdater.AssetsToRepair;
190-
Debug.LogFormat("Failed to convert following Linked Prefab files:\n{0}", string.Join("\n", prefabsToUpdate));
191-
}
192-
}
193173
else
194174
{
195175
UnityEditor.EditorUtility.DisplayDialog(dialogTitle,

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

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)