Skip to content

Commit fe79cc5

Browse files
committed
Handle prefab modifications properly on field update
- Update variable types properly when working with prefabs in the scene
1 parent 61f725a commit fe79cc5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Assets/UdonSharp/Editor/UdonSharpEditorManager.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ static void UpdateSyncModes(List<UdonBehaviour> udonBehaviours)
567567
if (behaviour.programSource == null || !(behaviour.programSource is UdonSharpProgramAsset programAsset))
568568
continue;
569569

570+
int originalModificationcount = modificationCount;
571+
570572
behaviourGameObjects.Add(behaviour.gameObject);
571573

572574
if (behaviour.Reliable == true &&
@@ -581,6 +583,9 @@ static void UpdateSyncModes(List<UdonBehaviour> udonBehaviours)
581583
behaviour.Reliable = true;
582584
modificationCount++;
583585
}
586+
587+
if (originalModificationcount != modificationCount)
588+
PrefabUtility.RecordPrefabInstancePropertyModifications(behaviour);
584589
}
585590

586591
if (modificationCount > 0)
@@ -818,6 +823,8 @@ static void UpdatePublicVariables(List<UdonBehaviour> udonBehaviours)
818823
if (behaviour.programSource == null || !(behaviour.programSource is UdonSharpProgramAsset programAsset))
819824
continue;
820825

826+
int originalUpdateCount = updatedBehaviourVariables;
827+
821828
IUdonVariableTable publicVariables = behaviour.publicVariables;
822829

823830
Dictionary<string, FieldDefinition> fieldDefinitions = programAsset.fieldDefinitions;
@@ -964,12 +971,13 @@ static void UpdatePublicVariables(List<UdonBehaviour> udonBehaviours)
964971
Debug.LogError($"Failed to update public variable {variableSymbol} on behaviour {behaviour}, exception {e}\n\nPlease report this error to Merlin!");
965972
}
966973
}
974+
975+
if (originalUpdateCount != updatedBehaviourVariables)
976+
PrefabUtility.RecordPrefabInstancePropertyModifications(behaviour);
967977
}
968978

969979
if (updatedBehaviourVariables > 0)
970-
{
971980
EditorSceneManager.MarkAllScenesDirty();
972-
}
973981
}
974982

975983
/// <summary>

0 commit comments

Comments
 (0)