Skip to content

Commit db3eb64

Browse files
author
AJubrey
committed
[REMOVED] code for exporting that we didn't need
[ADDED] comments and a log to give some information [ADDED] added a check if the index of the potential recttransform is below 0 (which means it isnt a rect transform)
1 parent 0c646d4 commit db3eb64

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -683,41 +683,22 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
683683
FbxDouble3 fbxRotate;
684684
UnityEngine.Vector3 unityScale;
685685

686-
RectTransform uiComponent = unityTransform.gameObject.GetComponent<RectTransform>();
687686

688687
switch (exportType) {
689688
case TransformExportType.Reset:
690689
unityTranslate = Vector3.zero;
691690
fbxRotate = new FbxDouble3 (0);
692691
unityScale = Vector3.one;
693-
if (uiComponent != null) // if this component is a RectTransform
694-
{
695-
unityTranslate = uiComponent.localPosition;
696-
fbxRotate = ConvertQuaternionToXYZEuler(uiComponent.localRotation);
697-
unityScale = uiComponent.localScale;
698-
}
699692
break;
700693
case TransformExportType.Global:
701694
unityTranslate = GetRecenteredTranslation(unityTransform, newCenter);
702695
fbxRotate = ConvertQuaternionToXYZEuler(unityTransform.rotation);
703696
unityScale = unityTransform.lossyScale;
704-
if (uiComponent != null) // if this component is a RectTransform
705-
{
706-
unityTranslate = GetRecenteredTranslation(uiComponent.transform, newCenter);
707-
fbxRotate = ConvertQuaternionToXYZEuler(uiComponent.rotation);
708-
unityScale = uiComponent.lossyScale;
709-
}
710697
break;
711698
default: /*case TransformExportType.Local*/
712699
unityTranslate = unityTransform.localPosition;
713700
fbxRotate = ConvertQuaternionToXYZEuler(unityTransform.localRotation);
714701
unityScale = unityTransform.localScale;
715-
if(uiComponent != null) // if this component is a RectTransform
716-
{
717-
unityTranslate = uiComponent.localPosition;
718-
fbxRotate = ConvertQuaternionToXYZEuler(uiComponent.localRotation);
719-
unityScale = uiComponent.localScale;
720-
}
721702
break;
722703
}
723704

Assets/FbxExporters/Editor/FbxPrefabAutoUpdater.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -984,23 +984,32 @@ public HashSet<GameObject> ImplementUpdates(FbxPrefab prefabInstance)
984984
Log("created component {0}:{1}", nodeName, fbxComponent.t);
985985
}
986986

987+
//If the prefabComponent has not been assigned yet,
988+
//it means that we couldn't find it, and that we tried to add it but that it seems like it already exists.
987989
if (!prefabComponent) {
988-
990+
//This is to confirm that it is a RectTransform
989991
index = prefabComponents.FindIndex(x => x.GetType() == typeof(RectTransform));
992+
993+
if (index < 0)
994+
{
995+
Log("The component could not be found or added, and was not a RectTransform");
996+
continue;
997+
}
998+
990999
prefabComponent = prefabComponents[index];
9911000
prefabComponents.RemoveAt(index);
9921001

9931002
GameObject tempGameObject = new GameObject();
9941003
try
995-
{
996-
1004+
{
9971005
Transform tempTransform = tempGameObject.transform;
9981006

9991007
UnityEditor.EditorJsonUtility.FromJsonOverwrite(fbxComponent.jsonValue, tempTransform);
10001008

1001-
prefabComponent.gameObject.GetComponent<RectTransform>().rotation = tempTransform.rotation;
1002-
prefabComponent.gameObject.GetComponent<RectTransform>().position = tempTransform.position;
1003-
prefabComponent.gameObject.GetComponent<RectTransform>().localScale = tempTransform.localScale;
1009+
var rectTransform = prefabComponent as RectTransform;
1010+
rectTransform.rotation = tempTransform.rotation;
1011+
rectTransform.position = tempTransform.position;
1012+
rectTransform.localScale = tempTransform.localScale;
10041013
}
10051014
finally
10061015
{

0 commit comments

Comments
 (0)