Skip to content

Commit 2c5cacd

Browse files
committed
Refactoring
1 parent f86b798 commit 2c5cacd

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

Runtime/Scripts/BaseMeshSync.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,19 @@ static Transform FindOrCreateByPath(Transform parent, string path, Action<string
17501750
string[] names = path.Split('/');
17511751
if (names.Length <= 0)
17521752
return null;
1753-
1753+
1754+
static Transform FindFirstRoot(string objectName) {
1755+
GameObject[] roots = SceneManager.GetActiveScene().GetRootGameObjects();
1756+
foreach (GameObject go in roots) {
1757+
if (go.name != objectName)
1758+
continue;
1759+
1760+
return go.transform;
1761+
}
1762+
1763+
return null;
1764+
}
1765+
17541766
//if parent is null, search from root
17551767
Transform t = parent;
17561768
int tokenStartIdx = 0;
@@ -1832,15 +1844,22 @@ void AddClientObject(string path, out EntityRecord rec) {
18321844
}
18331845
}
18341846

1835-
void AddClientObject(string path, out EntityRecord rec, ref Transform trans) {
18361847
if (m_clientObjects.TryGetValue(path, out rec))
18371848
if (rec.go == null) {
18381849
m_clientObjects.Remove(path);
18391850
rec = null;
18401851
}
18411852

18421853
if (rec == null) {
1843-
trans = FilmInternalUtilities.GameObjectUtility.FindOrCreateByPath(m_rootObject, path, false);
1854+
var trans = FindOrCreateByPath(m_rootObject, path,
1855+
delegate(string parentPath) {
1856+
EntityRecord parentRec = null;
1857+
AddClientObject(parentPath, out parentRec);
1858+
if (parentRec.dataType == EntityType.Unknown)
1859+
parentRec.dataType = EntityType.Transform;
1860+
},
1861+
false);
1862+
18441863
rec = new EntityRecord {
18451864
go = trans.gameObject,
18461865
trans = trans,

0 commit comments

Comments
 (0)