Skip to content

Commit 4b808ac

Browse files
authored
Uni-50158-api_review_modfications (#433)
* Changes protected methods to private * Probuilder is our friend * Removed useless implementation of Dispose()
1 parent 5d93cc8 commit 4b808ac

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

Packages/com.unity.formats.fbx/Editor/Scripts/FbxExporter.cs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Security.Permissions;
1313

1414
[assembly: InternalsVisibleTo("Unity.Formats.Fbx.Editortests")]
15+
[assembly: InternalsVisibleTo("Unity.ProBuilder.AddOns.Editor")]
1516

1617
namespace UnityEditor.Formats.Fbx.Exporter
1718
{
@@ -61,7 +62,7 @@ protected ModelExportException(SerializationInfo info, StreamingContext context)
6162
/// To do so, simply use its ExportObject and ExportObjects methods. Default export
6263
/// options are used when exporting the objects to the FBX file.
6364
/// </summary>
64-
public class ModelExporter : System.IDisposable
65+
public sealed class ModelExporter : System.IDisposable
6566
{
6667
const string Title =
6768
"Created by FBX Exporter from Unity Technologies";
@@ -883,7 +884,7 @@ bool ExportMesh (MeshInfo meshInfo, FbxNode fbxNode)
883884
/// Export GameObject as a skinned mesh with material, bones, a skin and, a bind pose.
884885
/// </summary>
885886
[SecurityPermission(SecurityAction.LinkDemand)]
886-
protected bool ExportSkinnedMesh (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNode)
887+
private bool ExportSkinnedMesh (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNode)
887888
{
888889
if(!unityGo || fbxNode == null)
889890
{
@@ -1126,7 +1127,7 @@ boneWeights [i].weight3
11261127
/// <summary>
11271128
/// Export bind pose of mesh to skeleton
11281129
/// </summary>
1129-
protected bool ExportBindPose (SkinnedMeshRenderer skinnedMesh, FbxNode fbxMeshNode,
1130+
private bool ExportBindPose (SkinnedMeshRenderer skinnedMesh, FbxNode fbxMeshNode,
11301131
FbxScene fbxScene, Dictionary<SkinnedMeshRenderer, Transform[]> skinnedMeshToBonesMap)
11311132
{
11321133
if (fbxMeshNode == null || skinnedMeshToBonesMap == null || fbxScene == null)
@@ -1297,7 +1298,7 @@ internal bool ExportTransform (UnityEngine.Transform unityTransform, FbxNode fbx
12971298
/// if this game object is a model prefab then export with shared components
12981299
/// </summary>
12991300
[SecurityPermission(SecurityAction.LinkDemand)]
1300-
protected bool ExportInstance(GameObject unityGo, FbxNode fbxNode)
1301+
private bool ExportInstance(GameObject unityGo, FbxNode fbxNode)
13011302
{
13021303
if (!unityGo || fbxNode == null)
13031304
{
@@ -1350,7 +1351,7 @@ protected bool ExportInstance(GameObject unityGo, FbxNode fbxNode)
13501351
/// <summary>
13511352
/// Exports camera component
13521353
/// </summary>
1353-
protected bool ExportCamera (GameObject unityGO, FbxScene fbxScene, FbxNode fbxNode)
1354+
private bool ExportCamera (GameObject unityGO, FbxScene fbxScene, FbxNode fbxNode)
13541355
{
13551356
if (!unityGO || fbxScene == null || fbxNode == null)
13561357
{
@@ -1387,7 +1388,7 @@ protected bool ExportCamera (GameObject unityGO, FbxScene fbxScene, FbxNode fbxN
13871388
/// Supported types: point, spot and directional
13881389
/// Cookie => Gobo
13891390
/// </summary>
1390-
protected bool ExportLight (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNode)
1391+
private bool ExportLight (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNode)
13911392
{
13921393
if(!unityGo || fbxScene == null || fbxNode == null)
13931394
{
@@ -1457,7 +1458,7 @@ protected bool ExportLight (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNo
14571458
return true;
14581459
}
14591460

1460-
protected bool ExportCommonConstraintProperties<TUnityConstraint,TFbxConstraint>(TUnityConstraint uniConstraint, TFbxConstraint fbxConstraint, FbxNode fbxNode)
1461+
private bool ExportCommonConstraintProperties<TUnityConstraint,TFbxConstraint>(TUnityConstraint uniConstraint, TFbxConstraint fbxConstraint, FbxNode fbxNode)
14611462
where TUnityConstraint : IConstraint where TFbxConstraint : FbxConstraint
14621463
{
14631464
fbxConstraint.Active.Set(uniConstraint.constraintActive);
@@ -1468,7 +1469,7 @@ protected bool ExportCommonConstraintProperties<TUnityConstraint,TFbxConstraint>
14681469
return true;
14691470
}
14701471

1471-
protected struct ExpConstraintSource
1472+
private struct ExpConstraintSource
14721473
{
14731474
private FbxNode m_node;
14741475
public FbxNode node
@@ -1491,7 +1492,7 @@ public ExpConstraintSource(FbxNode node, float weight)
14911492
}
14921493
}
14931494

1494-
protected List<ExpConstraintSource> GetConstraintSources(IConstraint unityConstraint)
1495+
private List<ExpConstraintSource> GetConstraintSources(IConstraint unityConstraint)
14951496
{
14961497
if(unityConstraint == null)
14971498
{
@@ -1514,7 +1515,7 @@ protected List<ExpConstraintSource> GetConstraintSources(IConstraint unityConstr
15141515
return fbxSources;
15151516
}
15161517

1517-
protected void AddFbxNodeToConstraintsMapping<T>(FbxNode fbxNode, T fbxConstraint, System.Type uniConstraintType) where T : FbxConstraint
1518+
private void AddFbxNodeToConstraintsMapping<T>(FbxNode fbxNode, T fbxConstraint, System.Type uniConstraintType) where T : FbxConstraint
15181519
{
15191520
Dictionary<FbxConstraint, System.Type> constraintMapping;
15201521
if (!MapConstrainedObjectToConstraints.TryGetValue(fbxNode, out constraintMapping))
@@ -1525,7 +1526,7 @@ protected void AddFbxNodeToConstraintsMapping<T>(FbxNode fbxNode, T fbxConstrain
15251526
constraintMapping.Add(fbxConstraint, uniConstraintType);
15261527
}
15271528

1528-
protected bool ExportPositionConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
1529+
private bool ExportPositionConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
15291530
{
15301531
if(fbxNode == null)
15311532
{
@@ -1556,7 +1557,7 @@ protected bool ExportPositionConstraint(IConstraint uniConstraint, FbxScene fbxS
15561557
return true;
15571558
}
15581559

1559-
protected bool ExportRotationConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
1560+
private bool ExportRotationConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
15601561
{
15611562
if(fbxNode == null)
15621563
{
@@ -1591,7 +1592,7 @@ protected bool ExportRotationConstraint(IConstraint uniConstraint, FbxScene fbxS
15911592
return true;
15921593
}
15931594

1594-
protected bool ExportScaleConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
1595+
private bool ExportScaleConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
15951596
{
15961597
if(fbxNode == null)
15971598
{
@@ -1624,7 +1625,7 @@ protected bool ExportScaleConstraint(IConstraint uniConstraint, FbxScene fbxScen
16241625
return true;
16251626
}
16261627

1627-
protected bool ExportAimConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
1628+
private bool ExportAimConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
16281629
{
16291630
if(fbxNode == null)
16301631
{
@@ -1690,7 +1691,7 @@ protected bool ExportAimConstraint(IConstraint uniConstraint, FbxScene fbxScene,
16901691
return true;
16911692
}
16921693

1693-
protected bool ExportParentConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
1694+
private bool ExportParentConstraint(IConstraint uniConstraint, FbxScene fbxScene, FbxNode fbxNode)
16941695
{
16951696
if(fbxNode == null)
16961697
{
@@ -1746,7 +1747,7 @@ protected bool ExportParentConstraint(IConstraint uniConstraint, FbxScene fbxSce
17461747

17471748
private delegate bool ExportConstraintDelegate(IConstraint c , FbxScene fs, FbxNode fn);
17481749

1749-
protected bool ExportConstraints (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNode)
1750+
private bool ExportConstraints (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNode)
17501751
{
17511752
if (!unityGo)
17521753
{
@@ -1912,7 +1913,7 @@ internal void ExportAnimationSamples (AnimationCurve uniAnimCurve, FbxAnimCurve
19121913
/// <param name="constrainedNode"></param>
19131914
/// <param name="uniConstraintType"></param>
19141915
/// <returns></returns>
1915-
protected FbxConstraint GetFbxConstraint(FbxNode constrainedNode, System.Type uniConstraintType)
1916+
private FbxConstraint GetFbxConstraint(FbxNode constrainedNode, System.Type uniConstraintType)
19161917
{
19171918
if (uniConstraintType == null || !uniConstraintType.GetInterfaces().Contains(typeof(IConstraint)))
19181919
{
@@ -1939,7 +1940,7 @@ protected FbxConstraint GetFbxConstraint(FbxNode constrainedNode, System.Type un
19391940
return null;
19401941
}
19411942

1942-
protected FbxProperty GetFbxProperty(FbxNode fbxNode, string fbxPropertyName, System.Type uniPropertyType)
1943+
private FbxProperty GetFbxProperty(FbxNode fbxNode, string fbxPropertyName, System.Type uniPropertyType)
19431944
{
19441945
if(fbxNode == null)
19451946
{
@@ -1980,7 +1981,7 @@ protected FbxProperty GetFbxProperty(FbxNode fbxNode, string fbxPropertyName, Sy
19801981
/// quaternion to euler and various other stuff.
19811982
/// </summary>
19821983
[SecurityPermission(SecurityAction.LinkDemand)]
1983-
protected void ExportAnimationCurve (FbxNode fbxNode,
1984+
private void ExportAnimationCurve (FbxNode fbxNode,
19841985
AnimationCurve uniAnimCurve,
19851986
float frameRate,
19861987
string uniPropertyName,
@@ -2080,7 +2081,7 @@ public float Convert(float value)
20802081
/// Export an AnimationClip as a single take
20812082
/// </summary>
20822083
[SecurityPermission(SecurityAction.LinkDemand)]
2083-
protected void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoot, FbxScene fbxScene)
2084+
private void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoot, FbxScene fbxScene)
20842085
{
20852086
if (!uniAnimClip || !uniRoot || fbxScene == null) return;
20862087

@@ -2476,7 +2477,7 @@ ref Dictionary<GameObject, RotationCurve> rotations
24762477
/// Export the Animator component on this game object
24772478
/// </summary>
24782479
[SecurityPermission(SecurityAction.LinkDemand)]
2479-
protected void ExportAnimation (GameObject uniRoot, FbxScene fbxScene)
2480+
private void ExportAnimation (GameObject uniRoot, FbxScene fbxScene)
24802481
{
24812482
if (!uniRoot)
24822483
{
@@ -2531,7 +2532,7 @@ protected void ExportAnimation (GameObject uniRoot, FbxScene fbxScene)
25312532
/// <summary>
25322533
/// configures default camera for the scene
25332534
/// </summary>
2534-
protected void SetDefaultCamera (FbxScene fbxScene)
2535+
private void SetDefaultCamera (FbxScene fbxScene)
25352536
{
25362537
if(fbxScene == null) { return; }
25372538

@@ -3114,7 +3115,7 @@ internal static IExportData GetExportData(GameObject go, IExportOptions exportOp
31143115
/// This function exports the other components and animation.
31153116
/// </summary>
31163117
[SecurityPermission(SecurityAction.LinkDemand)]
3117-
protected bool ExportComponents(FbxScene fbxScene, bool exportAnim = true)
3118+
private bool ExportComponents(FbxScene fbxScene, bool exportAnim = true)
31183119
{
31193120
var animationNodes = new HashSet<GameObject> ();
31203121

@@ -3175,7 +3176,7 @@ protected bool ExportComponents(FbxScene fbxScene, bool exportAnim = true)
31753176
/// </summary>
31763177
/// <returns><c>true</c>, if object has animation, <c>false</c> otherwise.</returns>
31773178
/// <param name="go">Go.</param>
3178-
protected bool GameObjectHasAnimation(GameObject go){
3179+
private bool GameObjectHasAnimation(GameObject go){
31793180
return go != null &&
31803181
(go.GetComponent<Animator> () ||
31813182
go.GetComponent<Animation> () ||
@@ -4054,14 +4055,9 @@ bool ExportMesh (GameObject gameObject, FbxNode fbxNode)
40544055
/// </summary>
40554056
public void Dispose ()
40564057
{
4057-
Dispose(true);
40584058
System.GC.SuppressFinalize(this);
40594059
}
40604060

4061-
protected virtual void Dispose(bool cleanUpManaged)
4062-
{
4063-
}
4064-
40654061
internal bool Verbose { get { return ExportSettings.instance.VerboseProperty; } }
40664062

40674063
/// <summary>

Packages/com.unity.formats.fbx/Runtime/FbxPrefab.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
[assembly: InternalsVisibleTo("Unity.Formats.Fbx.Editor")]
66
[assembly: InternalsVisibleTo("Unity.Formats.Fbx.Editortests")]
7+
[assembly: InternalsVisibleTo("Unity.ProBuilder.AddOns.Editor")]
78

89
namespace UnityEngine.Formats.Fbx.Exporter
910
{

0 commit comments

Comments
 (0)