generated from max/template-unity-project
Compare commits
4 Commits
ReadableFi
...
RootOrder
Author | SHA1 | Date | |
---|---|---|---|
28e30a30a4 | |||
8453143918 | |||
1b9c367221 | |||
4fe602e932 |
@ -92,7 +92,7 @@ namespace VertexColor.ScenePartition.Editor
|
||||
|
||||
// Add always load ids.
|
||||
SortedSet<ulong> baseIds = GetAlwaysLoadIds();
|
||||
foreach (var id in baseIds)
|
||||
foreach (ulong id in baseIds)
|
||||
{
|
||||
partitionIds.Add(id);
|
||||
}
|
||||
@ -129,6 +129,8 @@ namespace VertexColor.ScenePartition.Editor
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
// 'Reload' the scene to prevent the user getting the popup 'Scene has been changed on disk'.
|
||||
EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,6 +141,9 @@ namespace VertexColor.ScenePartition.Editor
|
||||
{
|
||||
using (new ProfilerUtility.ProfilerScope($"{nameof(Save)}"))
|
||||
{
|
||||
// Check if the user wants to save the scene if dirty.
|
||||
if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) return;
|
||||
|
||||
DeleteLoadedPartitions(); // Delete the loaded partitions from disk so we can write the new ones.
|
||||
|
||||
string pattern = @"&(\d+)";
|
||||
@ -158,7 +163,11 @@ namespace VertexColor.ScenePartition.Editor
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
// Extract the file number
|
||||
// Modify scene data.
|
||||
// Optional: ClearRootOrderProperty.
|
||||
ClearRootOrderProperty(ref sceneData, i, lastIndex);
|
||||
|
||||
// Extract the file number.
|
||||
string id = match.Groups[1].Value;
|
||||
|
||||
// Write data to disk.
|
||||
@ -377,5 +386,47 @@ namespace VertexColor.ScenePartition.Editor
|
||||
{
|
||||
data = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the m_RootOrder property to '0' on all transforms and prefab transform modifications.
|
||||
/// The property changes every time you add/remove something in the scene for each object underneat it in the hierarchy.
|
||||
/// This results in a lot of changes in source control that might cause conficts, and we don't want that.
|
||||
/// This does however change the scene hierarchy order, so if things are order dependent this will break it.
|
||||
/// </summary>
|
||||
private void ClearRootOrderProperty(ref string[] data, int i, int lastIndex)
|
||||
{
|
||||
using (new ProfilerUtility.ProfilerScope($"{nameof(ClearRootOrderProperty)}"))
|
||||
{
|
||||
const string prefabHeaderPattern = "--- !u!1001 &";
|
||||
const string transformHeaderPattern = "--- !u!4 &";
|
||||
const string prefabRootOrderPropertyPattern = " propertyPath: m_RootOrder";
|
||||
const string transformRootOrderPropertyPattern = " m_RootOrder:";
|
||||
const string numberPattern = @"[\d-]";
|
||||
|
||||
// If object is a Prefab.
|
||||
if (data[i].StartsWith(prefabHeaderPattern))
|
||||
{
|
||||
for (int j = i; j < lastIndex; j++)
|
||||
{
|
||||
if (!data[j].StartsWith(prefabRootOrderPropertyPattern)) continue;
|
||||
|
||||
data[j + 1] = Regex.Replace(data[j + 1], numberPattern, "0");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If object is a Transform.
|
||||
else if (data[i].StartsWith(transformHeaderPattern))
|
||||
{
|
||||
// Reverse loop since property is usually at the bottom of the transform component.
|
||||
for (int j = lastIndex - 1; j >= 0; j--)
|
||||
{
|
||||
if (!data[j].StartsWith(transformRootOrderPropertyPattern)) continue;
|
||||
|
||||
data[j] = Regex.Replace(data[j], numberPattern, "0");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user