Skip to content

Commit

Permalink
Fix some issues with inspector cache not updating for behaviour conve…
Browse files Browse the repository at this point in the history
…rsion

- Also catch errors on serialization on conversion to prevent complete failure
  • Loading branch information
MerlinVR committed Sep 4, 2020
1 parent 2f13b8d commit b400682
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private void OnEnable()

if (target is UdonBehaviour udonBehaviour && UdonSharpEditorUtility.IsUdonSharpBehaviour(udonBehaviour))
{
UdonSharpBehaviour proxyBehaviour = UdonSharpEditorUtility.GetProxyBehaviour(udonBehaviour);
UdonSharpBehaviour proxyBehaviour = UdonSharpEditorUtility.GetProxyBehaviour(udonBehaviour, ProxySerializationPolicy.NoSerialization);

if (proxyBehaviour)
proxyBehaviour.hideFlags =
Expand Down
12 changes: 9 additions & 3 deletions Assets/UdonSharp/Editor/UdonSharpEditorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static UdonBehaviour[] ConvertToUdonBehavioursWithUndo(UdonSharpBehaviour
return ConvertToUdonBehavioursInternal(components, true, false);
}

static Dictionary<MonoScript, UdonSharpProgramAsset> _programAssetLookup;
static internal Dictionary<MonoScript, UdonSharpProgramAsset> _programAssetLookup;
private static UdonSharpProgramAsset GetUdonSharpProgramAsset(MonoScript programScript)
{
if (_programAssetLookup == null)
Expand Down Expand Up @@ -628,8 +628,14 @@ internal static UdonBehaviour[] ConvertToUdonBehavioursInternal(UdonSharpBehavio
newProxy = (UdonSharpBehaviour)targetObject.gameObject.AddComponent(behaviourType);

UdonSharpEditorUtility.SetBackingUdonBehaviour(newProxy, udonBehaviour);

UdonSharpEditorUtility.CopyUdonToProxy(newProxy);
try
{
UdonSharpEditorUtility.CopyUdonToProxy(newProxy);
}
catch (System.Exception e)
{
Debug.LogError(e);
}

if (shouldUndo)
Undo.DestroyObjectImmediate(targetObject);
Expand Down
1 change: 1 addition & 0 deletions Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public static void CompileAllCsPrograms(bool forceCompile = false, bool editorBu
internal static void ClearProgramAssetCache()
{
_programAssetCache = null;
UdonSharpEditorUtility._programAssetLookup = null;
}

[PublicAPI]
Expand Down

0 comments on commit b400682

Please sign in to comment.