Skip to content

Fixes errors pointing at LogError instead of project asset #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public static void Compile(UdonSharpCompileOptions options = null)
{
if (udonSharpProgram.sourceCsScript == null)
{
UdonSharpUtils.LogError($"Source C# script on {udonSharpProgram} is null", udonSharpProgram);
UdonSharpUtils.LogError($"Source C# script on {udonSharpProgram} is null. Add the source C# script, or delete {udonSharpProgram}.", udonSharpProgram);
hasError = true;
continue;
}
Expand All @@ -291,7 +291,7 @@ public static void Compile(UdonSharpCompileOptions options = null)

if (string.IsNullOrEmpty(assetPath))
{
UdonSharpUtils.LogError($"Source C# script on {udonSharpProgram} is null", udonSharpProgram);
UdonSharpUtils.LogError($"Source C# script on {udonSharpProgram} is null. Add the source C# script, or delete {udonSharpProgram}.", udonSharpProgram);
hasError = true;
continue;
}
Expand Down
7 changes: 7 additions & 0 deletions Packages/com.vrchat.UdonSharp/Editor/UdonSharpUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@ public static void LogError(object message, UnityEngine.Object context)
Debug.LogError($"[<color=#FF00FF>UdonSharp</color>] {message}", context);
}

public static void LogError(object message, UdonSharpProgramAsset context)
{
var asset = AssetDatabase.FindAssets($"t:{nameof(UdonSharpProgramAsset)} {context.name}");
if (asset == null || asset[0] == null) LogError(message, context);
else Debug.LogError($"[<color=#FF00FF>UdonSharp</color>] {message}", AssetDatabase.LoadAssetAtPath<UdonSharpProgramAsset>(AssetDatabase.GUIDToAssetPath(asset[0])));
}

private static readonly MethodInfo _displayProgressBar = typeof(Editor).Assembly.GetTypes().FirstOrDefault(e => e.Name == "AsyncProgressBar")?.GetMethod("Display");
private static readonly MethodInfo _clearProgressBar = typeof(Editor).Assembly.GetTypes().FirstOrDefault(e => e.Name == "AsyncProgressBar")?.GetMethod("Clear");

Expand Down