Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Add warning for modifying source script on program assets
Browse files Browse the repository at this point in the history
- Add a warning dialong on UdonSharpProgramAssets when attempting to change the program source to a program asset to prevent people from shooting themselves in the foot with editor issues that may arise from changing the script type on established objects.
  • Loading branch information
MerlinVR committed Dec 11, 2020
1 parent f4125e7 commit b2eea00
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ protected override void DrawProgramSourceGUI(UdonBehaviour udonBehaviour, ref bo
MonoScript newSourceCsScript = (MonoScript)EditorGUILayout.ObjectField("Source Script", sourceCsScript, typeof(MonoScript), false);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(this, "Changed source C# script");
sourceCsScript = newSourceCsScript;
dirty = true;
bool shouldReplace = true;

if (sourceCsScript != null)
shouldReplace = EditorUtility.DisplayDialog("Modifying script on program asset", "If you modify a script on a program asset while it is being used by objects in a scene it can cause issues. Are you sure you want to change the source script?", "Ok", "Cancel");

if (shouldReplace)
{
Undo.RecordObject(this, "Changed source C# script");
sourceCsScript = newSourceCsScript;
dirty = true;
}
}

EditorGUI.BeginDisabledGroup(true);
Expand Down

0 comments on commit b2eea00

Please sign in to comment.