Skip to content

Commit

Permalink
Merge pull request #82 from vrchat-community/nested-prefab-upgrade-fixes
Browse files Browse the repository at this point in the history
Nested prefab upgrade fixes
  • Loading branch information
MerlinVR committed Dec 1, 2022
2 parents a89fc5e + 0d0450b commit 3fa998d
Show file tree
Hide file tree
Showing 4 changed files with 446 additions and 74 deletions.
28 changes: 14 additions & 14 deletions Packages/com.vrchat.UdonSharp/Editor/UdonSharpEditorManager.cs
Expand Up @@ -907,7 +907,7 @@ private static IEnumerable<GameObject> GetAllPrefabsWithUdonSharpBehaviours()
if (prefabRoot == null)
continue;

var prefabAssetType = PrefabUtility.GetPrefabAssetType(prefabRoot);
PrefabAssetType prefabAssetType = PrefabUtility.GetPrefabAssetType(prefabRoot);
if (prefabAssetType == PrefabAssetType.Model ||
prefabAssetType == PrefabAssetType.MissingAsset)
continue;
Expand All @@ -919,7 +919,7 @@ private static IEnumerable<GameObject> GetAllPrefabsWithUdonSharpBehaviours()

bool hasUdonSharpBehaviour = false;

foreach (var behaviour in behaviourScratch)
foreach (UdonBehaviour behaviour in behaviourScratch)
{
if (UdonSharpEditorUtility.IsUdonSharpBehaviour(behaviour))
{
Expand All @@ -942,7 +942,7 @@ private static IImmutableSet<GameObject> GetRootPrefabGameObjectRefs(IEnumerable

HashSet<GameObject> newObjectSet = new HashSet<GameObject>();

foreach (var unityObject in unityObjects)
foreach (Object unityObject in unityObjects)
{
if (unityObject == null)
continue;
Expand All @@ -953,7 +953,7 @@ private static IImmutableSet<GameObject> GetRootPrefabGameObjectRefs(IEnumerable
if (!PrefabUtility.IsPartOfPrefabAsset(unityObject))
continue;

var prefabAssetType = PrefabUtility.GetPrefabAssetType(unityObject);
PrefabAssetType prefabAssetType = PrefabUtility.GetPrefabAssetType(unityObject);
if (prefabAssetType == PrefabAssetType.Model ||
prefabAssetType == PrefabAssetType.MissingAsset)
continue;
Expand Down Expand Up @@ -995,12 +995,12 @@ private static HashSet<Object> GetBehaviourComponentOrGameObjectReferences(UdonB
if (behaviour == null)
return unityObjects;

var unityObjectList = (List<Object>)_serializedObjectReferencesField.GetValue(behaviour);
List<Object> unityObjectList = (List<Object>)_serializedObjectReferencesField.GetValue(behaviour);

if (unityObjectList == null)
return unityObjects;

foreach (var unityObject in unityObjectList)
foreach (Object unityObject in unityObjectList)
{
if (unityObject is Component || unityObject is GameObject)
unityObjects.Add(unityObject);
Expand All @@ -1013,7 +1013,7 @@ private static HashSet<GameObject> CollectScenePrefabRoots(List<UdonBehaviour> a
{
HashSet<GameObject> prefabRoots = new HashSet<GameObject>();

foreach (var udonBehaviour in allBehaviours)
foreach (UdonBehaviour udonBehaviour in allBehaviours)
{
if (!PrefabUtility.IsPartOfPrefabInstance(udonBehaviour))
continue;
Expand All @@ -1033,7 +1033,7 @@ private static IEnumerable<GameObject> CollectAllReferencedPrefabRoots(IEnumerab
{
HashSet<GameObject> gameObjectsToVisit = new HashSet<GameObject>();

foreach (var rootBehaviour in rootSet)
foreach (UdonBehaviour rootBehaviour in rootSet)
{
HashSet<Object> objects = GetBehaviourComponentOrGameObjectReferences(rootBehaviour);
gameObjectsToVisit.UnionWith(GetRootPrefabGameObjectRefs(objects.Count != 0 ? objects : null));
Expand All @@ -1052,14 +1052,14 @@ private static IEnumerable<GameObject> CollectAllReferencedPrefabRoots(IEnumerab
{
HashSet<GameObject> newVisitSet = new HashSet<GameObject>();

foreach (var gameObject in gameObjectsToVisit)
foreach (GameObject gameObject in gameObjectsToVisit)
{
if (visitedSet.Contains(gameObject))
continue;

visitedSet.Add(gameObject);

foreach (var udonBehaviour in gameObject.GetComponentsInChildren<UdonBehaviour>(true))
foreach (UdonBehaviour udonBehaviour in gameObject.GetComponentsInChildren<UdonBehaviour>(true))
{
HashSet<Object> objectRefs;

Expand All @@ -1081,7 +1081,7 @@ private static IEnumerable<GameObject> CollectAllReferencedPrefabRoots(IEnumerab
objectRefs = GetBehaviourComponentOrGameObjectReferences(udonBehaviour);
}

foreach (var newObjRef in GetRootPrefabGameObjectRefs((objectRefs != null && objectRefs.Count != 0) ? objectRefs : null))
foreach (GameObject newObjRef in GetRootPrefabGameObjectRefs((objectRefs != null && objectRefs.Count != 0) ? objectRefs : null))
{
if (!visitedSet.Contains(newObjRef))
newVisitSet.Add(newObjRef);
Expand Down Expand Up @@ -1584,9 +1584,9 @@ private static void SanitizeProxyBehaviours(GameObject[] allGameObjects, bool ap

private static bool AreUdonSharpScriptsUpdated()
{
var allPrograms = UdonSharpProgramAsset.GetAllUdonSharpPrograms();
UdonSharpProgramAsset[] allPrograms = UdonSharpProgramAsset.GetAllUdonSharpPrograms();

foreach (var programAsset in allPrograms)
foreach (UdonSharpProgramAsset programAsset in allPrograms)
{
if (programAsset.ScriptVersion != UdonSharpProgramVersion.CurrentVersion)
return false;
Expand Down Expand Up @@ -1960,7 +1960,7 @@ private static void OnPostprocessAllAssets(string[] importedAssets, string[] del

bool needsUpdate = false;

foreach (var behaviour in behaviours)
foreach (UdonBehaviour behaviour in behaviours)
{
if (!UdonSharpEditorUtility.IsUdonSharpBehaviour(behaviour))
continue;
Expand Down

0 comments on commit 3fa998d

Please sign in to comment.