| Description | If we define a relative image path such as:
<Image x:Name="Layer07"
Source="../Images/MainMenu/titlemenu_layer_07.png"
Stretch="Uniform"
Width="Auto"
Canvas.ZIndex="5"
SnapsToDevicePixels="False">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="Layer07Scale" ScaleX="1.5" ScaleY="1.5"/>
<TranslateTransform x:Name="Layer07Transform"/>
</TransformGroup>
</Image.RenderTransform>
</Image>
The lang server cannot resolve the path. It appears to be doubling the path at some point during path resolution. Note that the images work fine during normal play and do show up as dependencies for the xaml.
This appears to be an issue with LangServerTextureLoad and I wrote a fix locally. I'm not sure if the broken pattern is repeated across other path loading.
A stack trace follows.
DirectoryNotFoundException: Could not find a part of the path "/mnt/dev/deadmoney/aor/mnt/dev/deadmoney/aor/Assets/Code/UI/Images/MainMenu/titlemenu_layer_07.png".
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <f7d6f0a1fddf40db94ab7360f6bb8408>:0)
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) (at <f7d6f0a1fddf40db94ab7360f6bb8408>:0)
(wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int)
System.IO.File.ReadAllBytes (System.String path) (at <f7d6f0a1fddf40db94ab7360f6bb8408>:0)
NoesisLangServer.LangServerTextureLoad (System.IntPtr filenamePtr, System.UInt32& x, System.UInt32& y, System.UInt32& width, System.UInt32& height, System.Single& dpiScale, System.UInt32& numLevels) (at ./Packages/com.noesis.noesisgui/Editor/NoesisLangServer.cs:196)
UnityEngine.Debug:LogException(Exception)
NoesisUnity:OnUnhandledException(Exception) (at ./Packages/com.noesis.noesisgui/Runtime/NoesisUnity.cs:371)
Noesis.Error:UnhandledException(Exception) (at ./Packages/com.noesis.noesisgui/Runtime/API/Core/Error.cs:18)
NoesisLangServer:LangServerTextureLoad(IntPtr, UInt32&, UInt32&, UInt32&, UInt32&, Single&, UInt32&) (at ./Packages/com.noesis.noesisgui/Editor/NoesisLangServer.cs:245)
Noesis.GUI:Noesis_LoadComponent(HandleRef, String)
Noesis.GUI:LoadComponent(Object, String) (at ./Packages/com.noesis.noesisgui/Runtime/API/Core/NoesisGUI.cs:354)
NoesisUnity:LoadComponent(Object, String) (at ./Packages/com.noesis.noesisgui/Runtime/NoesisUnity.cs:325)
AOR.MainMenu:InitializeComponent() (at Assets/Code/UI/Menus/MainMenu.xaml.cs:105)
AOR.MainMenu:.ctor() (at Assets/Code/UI/Menus/MainMenu.xaml.cs:78)
System.Object:lambda_method(Closure)
Noesis.Extend:CreateInstance(IntPtr, IntPtr) (at ./Packages/com.noesis.noesisgui/Runtime/API/Core/Extend.cs:5812)
NoesisLangServer:Noesis_LangServer_RunTick()
<>c:<.cctor>b__6_0() (at ./Packages/com.noesis.noesisgui/Editor/NoesisLangServer.cs:35)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions() (at /home/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:384)
My naive fix. I am not a path specialist. I used AI to sort this one out because it is confusing.
#region Path helpers
// DEAD MONEY: On Linux, native Noesis code produces paths like
// "mnt/dev/project/Assets/..." (project path without leading slash).
// This gets doubled when .NET prepends the project path again.
// Fix by detecting the pattern and converting to proper absolute path.
private static string FixDoubledPath(string path)
{
if (string.IsNullOrEmpty(path))
return path;
// Get the project path (parent of Assets folder).
string projectPath = System.IO.Path.GetDirectoryName(Application.dataPath);
if (string.IsNullOrEmpty(projectPath))
return path;
// Project path without leading slash (e.g., "mnt/dev/deadmoney/aor").
string projectPathNoSlash = projectPath.TrimStart('/');
// Check if path starts with project path without leading slash.
// Pattern: mnt/dev/project/Assets/... -> should be /mnt/dev/project/Assets/...
if (path.StartsWith(projectPathNoSlash + "/"))
{
// Add the leading slash to make it a proper absolute path.
string fixedPath = "/" + path;
Debug.Log($"[NoesisLangServer] Fixed path (added /): {fixedPath}");
return fixedPath;
}
// Also check for already-doubled paths with leading slash.
string doubledPrefix = projectPath + projectPath;
if (path.StartsWith(doubledPrefix))
{
string fixedPath = path.Substring(projectPath.Length);
Debug.Log($"[NoesisLangServer] Fixed path (removed double): {fixedPath}");
return fixedPath;
}
return path;
}
#endregion
[MonoPInvokeCallback(typeof(Callback_LangServerTextureLoad))]
private static IntPtr LangServerTextureLoad(IntPtr filenamePtr,
ref uint x, ref uint y, ref uint width, ref uint height, ref float dpiScale,
ref uint numLevels)
{
try
{
string filename = StringFromNativeUtf8(filenamePtr);
// DEAD MONEY: Fix doubled paths on Linux.
filename = FixDoubledPath(filename);
Texture2D texture = new Texture2D(1, 1);
byte[] bytes = System.IO.File.ReadAllBytes(filename);
if (texture.LoadImage(bytes))
{
// NoesisGUI needs premultipled alpha
UnityEngine.Color[] c = texture.GetPixels(0);
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
{
for (int i = 0; i < c.Length; i++)
{
c[i].r = Mathf.LinearToGammaSpace(Mathf.GammaToLinearSpace(c[i].r) * c[i].a);
c[i].g = Mathf.LinearToGammaSpace(Mathf.GammaToLinearSpace(c[i].g) * c[i].a);
c[i].b = Mathf.LinearToGammaSpace(Mathf.GammaToLinearSpace(c[i].b) * c[i].a);
}
}
else
{
for (int i = 0; i < c.Length; i++)
{
c[i].r = c[i].r * c[i].a;
c[i].g = c[i].g * c[i].a;
c[i].b = c[i].b * c[i].a;
}
}
// Set new content
texture.SetPixels(c, 0);
texture.Apply(true, true);
// Set texture info
x = 0;
y = 0;
width = (uint)texture.width;
height = (uint)texture.height;
dpiScale = 1;
numLevels = (uint)texture.mipmapCount;
return texture.GetNativeTexturePtr();
}
x = 0;
y = 0;
width = 0;
height = 0;
dpiScale = 1;
}
catch (Exception e)
{
Error.UnhandledException(e);
}
return IntPtr.Zero;
}
|
|---|