Skip to content

Commit

Permalink
Fix changes to instances of prefabs in the scene
Browse files Browse the repository at this point in the history
- Record undos on the current inspected object when using custom inspectors. This needs a better solution for every object that is modified by a custom inspector.
  • Loading branch information
MerlinVR committed Sep 16, 2020
1 parent 633f06d commit 47f82f2
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions Assets/UdonSharp/Editor/Editors/UdonSharpBehaviourEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,23 @@ static void InitInspectorMap()
/// <returns></returns>
static UndoPropertyModification[] OnPostprocessUndoModifications(UndoPropertyModification[] propertyModifications)
{
if (!EditorApplication.isPlaying)
{
foreach (UndoPropertyModification propertyModification in propertyModifications)
{
UnityEngine.Object target = propertyModification.currentValue.target;

if (target is UdonSharpBehaviour udonSharpBehaviour)
{
UdonBehaviour backingBehaviour = UdonSharpEditorUtility.GetBackingUdonBehaviour(udonSharpBehaviour);

if (backingBehaviour)
{
EditorSceneManager.MarkSceneDirty(backingBehaviour.gameObject.scene);
}
}
}
}
//if (!EditorApplication.isPlaying)
//{
// foreach (UndoPropertyModification propertyModification in propertyModifications)
// {
// UnityEngine.Object target = propertyModification.currentValue.target;

// if (target is UdonSharpBehaviour udonSharpBehaviour)
// {
// UdonBehaviour backingBehaviour = UdonSharpEditorUtility.GetBackingUdonBehaviour(udonSharpBehaviour);

// if (backingBehaviour)
// {
// EditorSceneManager.MarkSceneDirty(backingBehaviour.gameObject.scene);
// }
// }
// }
//}

return propertyModifications;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ public override void OnInspectorGUI()
{
if (!baseEditor)
Editor.CreateCachedEditorWithContext(targets, this, typeof(UdonBehaviourEditor), ref baseEditor);

baseEditor.OnInspectorGUI();
return;
}
Expand Down Expand Up @@ -427,14 +427,14 @@ public override void OnInspectorGUI()
inspectorTarget.enabled = false;

Editor.CreateCachedEditorWithContext(inspectorTarget, this, customEditorType, ref baseEditor);

currentProxyBehaviour = inspectorTarget;

baseEditor.serializedObject.Update();

baseEditor.OnInspectorGUI();

UdonSharpEditorUtility.CopyProxyToUdon(inspectorTarget, ProxySerializationPolicy.All);
Undo.RecordObject(behaviour, Undo.GetCurrentGroupName());
}
else
{
Expand All @@ -456,12 +456,12 @@ private void OnSceneGUI()
return;

UdonBehaviour behaviour = target as UdonBehaviour;
if (behaviour.programSource == null ||
!(behaviour.programSource is UdonSharpProgramAsset udonSharpProgram) ||

if (behaviour.programSource == null ||
!(behaviour.programSource is UdonSharpProgramAsset udonSharpProgram) ||
udonSharpProgram.sourceCsScript == null)
return;

System.Type customEditorType = null;
System.Type inspectedType = udonSharpProgram.sourceCsScript.GetClass();
if (inspectedType != null)
Expand Down

0 comments on commit 47f82f2

Please sign in to comment.