Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix migration #29

Merged
merged 8 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -16,6 +16,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 @@ -155,8 +155,15 @@ private static void MigratePrefabs(List<GameObject> prefabAssets, Action<string,

var modified = false;

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

if (modified)
PrefabUtility.SavePrefabAsset(prefabAsset);
Expand All @@ -175,9 +182,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);

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

if (modified)
EditorSceneManager.SaveScene(scene);
}
Expand Down Expand Up @@ -330,8 +346,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
}
}