Skip to content

Commit 79d6db6

Browse files
committed
find object in scene with FbxTurnTableBase script
to use as the turn table. Also update scene name to be the name of the selected turn table scene.
1 parent f4360f7 commit 79d6db6

File tree

3 files changed

+56
-13
lines changed

3 files changed

+56
-13
lines changed

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// ***********************************************************************
2+
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3+
//
4+
// Licensed under the ##LICENSENAME##.
5+
// See LICENSE.md file in the project root for full license information.
6+
// ***********************************************************************
17

28
using UnityEngine;
39

@@ -10,7 +16,7 @@ class TurnTable
1016
const string MenuItemName = "FbxExporters/Turntable Review/Autoload Last Saved Prefab";
1117

1218
const string ScenesPath = "Assets";
13-
const string SceneName = "FbxExporters_TurnTableReview";
19+
static string SceneName = "FbxExporters_TurnTableReview";
1420

1521
public const string TempSavePath = "_safe_to_delete";
1622

@@ -82,12 +88,18 @@ private static Object LoadModel (string fbxFileName)
8288
if (unityMainAsset) {
8389
modelGO = UnityEditor.PrefabUtility.InstantiatePrefab (unityMainAsset) as GameObject;
8490

85-
GameObject turntableGO = GameObject.Find ("TurnTable");
91+
var turnTableBase = GameObject.FindObjectOfType<FbxTurnTableBase> ();
92+
GameObject turntableGO = null;
93+
if (turnTableBase != null) {
94+
turntableGO = turnTableBase.gameObject;
95+
}
96+
8697
if (turntableGO != null) {
8798
modelGO.transform.parent = turntableGO.transform;
88-
turntableGO.AddComponent<RotateModel> ();
8999
} else {
90-
modelGO.AddComponent<RotateModel> ();
100+
if (!modelGO.GetComponent<RotateModel> ()) {
101+
modelGO.AddComponent<RotateModel> ();
102+
}
91103
}
92104
}
93105

@@ -173,7 +185,6 @@ public static void LastSavedModel ()
173185
string scenePath = null;
174186
if (desiredScene) {
175187
scenePath = UnityEditor.AssetDatabase.GetAssetPath (desiredScene);
176-
Debug.LogWarning (scenePath);
177188
} else {
178189

179190
// and if for some reason the turntable scene is missing create an empty scene
@@ -190,6 +201,8 @@ public static void LastSavedModel ()
190201
scene = UnityEditor.SceneManagement.EditorSceneManager.OpenScene (scenePath, UnityEditor.SceneManagement.OpenSceneMode.Additive);
191202
}
192203

204+
SceneName = scene.name;
205+
193206
// save unmodified scenes (but not the untitled or turntable scene)
194207
if (UnityEditor.SceneManagement.EditorSceneManager.SaveModifiedScenesIfUserWantsTo (scenes.ToArray ()))
195208
{
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ***********************************************************************
2+
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3+
//
4+
// Licensed under the ##LICENSENAME##.
5+
// See LICENSE.md file in the project root for full license information.
6+
// ***********************************************************************
7+
8+
using System.Collections;
9+
using System.Collections.Generic;
10+
using UnityEngine;
11+
12+
namespace FbxExporters.Review
13+
{
14+
public class FbxTurnTableBase : RotateModel
15+
{
16+
17+
}
18+
}

Assets/FbxExporters/RotateModel.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
using System.Collections;
1+
// ***********************************************************************
2+
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3+
//
4+
// Licensed under the ##LICENSENAME##.
5+
// See LICENSE.md file in the project root for full license information.
6+
// ***********************************************************************
7+
8+
using System.Collections;
29
using System.Collections.Generic;
310
using UnityEngine;
411

5-
public class RotateModel : MonoBehaviour {
12+
namespace FbxExporters.Review
13+
{
14+
public class RotateModel : MonoBehaviour
15+
{
16+
17+
[Tooltip ("Rotation speed in degrees/second")]
18+
[SerializeField]
19+
private float speed = 10f;
620

7-
[Tooltip("Rotation speed in degrees/second")]
8-
[SerializeField]
9-
private float speed = 10f;
10-
11-
void Update () {
12-
transform.Rotate (Vector3.up, speed * Time.deltaTime, Space.World);
21+
void Update ()
22+
{
23+
transform.Rotate (Vector3.up, speed * Time.deltaTime, Space.World);
24+
}
1325
}
1426
}

0 commit comments

Comments
 (0)