Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into force-migration_
Browse files Browse the repository at this point in the history
# Conflicts:
#	Editor/Migration/Migration.cs
  • Loading branch information
anatawa12 committed Mar 4, 2023
2 parents dfc233a + 1bc2303 commit a6ca53a
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 13 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/gameci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ jobs:
with:
name: Test results
path: ${{ steps.gameci.outputs.artifactsPath }}
# Coverage not supported on unity 2019
#- uses: actions/upload-artifact@v3
# if: always()
# with:
# name: Coverage results
# path: ${{ steps.ganmeci.outputs.coveragePath }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: Coverage results
path: ${{ steps.gameci.outputs.coveragePath }}
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Migration of PrefabSafeSet prefab overrides is not well `#29`

### Security

Expand Down
32 changes: 26 additions & 6 deletions Editor/Migration/Migration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,15 @@ private static void MigratePrefabs(List<GameObject> prefabAssets, Action<string,

var modified = false;

foreach (var component in prefabAsset.GetComponentsInChildren<AvatarTagComponent>())
modified |= MigrateComponent(component, forceVersion);
try
{
foreach (var component in prefabAsset.GetComponentsInChildren<AvatarTagComponent>())
modified |= MigrateComponent(component, forceVersion);
}
catch (Exception e)
{
throw new Exception($"Migrating Prefab {prefabAsset.name}: {e.Message}", e);
}

if (modified)
PrefabUtility.SavePrefabAsset(prefabAsset);
Expand All @@ -215,9 +222,18 @@ private static void MigrateAllScenes(List<string> scenePaths, Action<string, int
progressCallback(scene.name, i);

var modified = false;
foreach (var rootGameObject in scene.GetRootGameObjects())
foreach (var component in rootGameObject.GetComponentsInChildren<AvatarTagComponent>())
modified |= MigrateComponent(component, forceVersion);

try
{
foreach (var rootGameObject in scene.GetRootGameObjects())
foreach (var component in rootGameObject.GetComponentsInChildren<AvatarTagComponent>())
modified |= MigrateComponent(component, forceVersion);
}
catch (Exception e)
{
throw new Exception($"Migrating Scene {scene.name}: {e.Message}", e);
}

if (modified)
EditorSceneManager.SaveScene(scene);
}
Expand Down Expand Up @@ -372,8 +388,12 @@ private static void MigrateSet<T>(

renderersSet.Clear();

foreach (var value in values)
var valuesSet = new HashSet<T>(values);

foreach (var value in valuesSet)
renderersSet.GetElementOf(value).EnsureAdded();

Assert.IsTrue(valuesSet.SetEquals(renderersSet.Values));
}

private static void MigrateList(SerializedProperty arrayProperty, SerializedProperty listProperty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void DoInitialize()
public override void Clear()
{
Initialize();
for (var i = _elements.Count - 1; i >= _upstreamElementCount; i--)
for (var i = _elements.Count - 1; i >= 0; i--)
_elements[i].EnsureRemoved();
_currentAdditionsSize = _currentAdditions.arraySize = 0;
}
Expand Down
35 changes: 35 additions & 0 deletions Test~/PrefabSafeSet/EditorUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,40 @@ public void InstanceElements()
}

#endregion

#region Elements

[Test]
public void PrefabClear()
{
using (var scope = new PSSTestUtil.Scope())
{
scope.PrefabEditorUtil.Clear();
Assert.That(scope.PrefabEditorUtil.Count, Is.EqualTo(0));
}
}

[Test]
public void VariantClear()
{
using (var scope = new PSSTestUtil.Scope())
{
scope.VariantEditorUtil.Clear();
Assert.That(scope.VariantEditorUtil.Count, Is.EqualTo(0));
}
}


[Test]
public void InstanceClear()
{
using (var scope = new PSSTestUtil.Scope())
{
scope.InstanceEditorUtil.Clear();
Assert.That(scope.InstanceEditorUtil.Count, Is.EqualTo(0));
}
}

#endregion
}
}

0 comments on commit a6ca53a

Please sign in to comment.