Drawing API throws value error in KSP 1.9 KRPC 0.4.8
ToxicCoder opened this issue ยท 9 comments
I've been trying to figure out how to use reference frames and tried the landing site example however it gives this error.
Traceback (most recent call last):
File "landingSite.py", line 43, in <module>
conn.drawing.add_line((0, 0, 0), (1, 0, 0), landing_reference_frame)
File "<string>", line 1, in <lambda>
File "D:\Python\Python-3.6.6-64\lib\site-packages\krpc\client.py", line 163, in _invoke
raise self._build_error(response.results[0].error)
ValueError: Value cannot be null.
Parameter name: shader
Server stack trace:
at (wrapper managed-to-native) UnityEngine.Material.CreateWithShader(UnityEngine.Material,UnityEngine.Shader)
at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00007] in <5aeafee3fea24f37abd1315553f2cfa6>:0
at KRPC.Drawing.Drawable`1[T].set_Material (System.String value) [0x0000c] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at KRPC.Drawing.Drawable`1[T]..ctor (System.Type rendererType) [0x00041] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at KRPC.Drawing.Line..ctor (Vector3d lineStart, Vector3d lineEnd, KRPC.SpaceCenter.Services.ReferenceFrame referenceFrame, System.Boolean visible) [0x00000] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at KRPC.Drawing.Drawing.AddLine (KRPC.Utils.Tuple`3[T1,T2,T3] start, KRPC.Utils.Tuple`3[T1,T2,T3] end, KRPC.SpaceCenter.Services.ReferenceFrame referenceFrame, System.Boolean visible) [0x0000c] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <ad04dee02e7e4a85a1299c7ee81c79f6>:0
I've tried other drawing API commands and they all give the same error.
I'm using KSP 1.9 and KRPC 0.4.8
Was actually already fixed in #585
Do you reckon this is related to
If your "Shader.Find" call does not find your old shader you can try to add "Legacy Shaders/" to the name. LIke "Legacy Shaders/Particles/Additive"
https://forum.kerbalspaceprogram.com/index.php?/topic/188933-180-modders-notes/
The current file that references, Particles/Additive within Drawing/Drawable.cs
protected Drawable (Type rendererType)
{
GameObject = new GameObject ("KRPC.Drawing." + typeof(T).Name);
Renderer = (Renderer)GameObject.AddComponent (rendererType);
Material = "Particles/Additive";
Addon.AddObject (this);
}
to
protected Drawable (Type rendererType)
{
GameObject = new GameObject ("KRPC.Drawing." + typeof(T).Name);
Renderer = (Renderer)GameObject.AddComponent (rendererType);
Material = "Legacy Shaders/Particles/Additive";
Addon.AddObject (this);
}
I have no experience in the area whatsoever, I was just having the same issue and wanted to take a peak at what could be up, nothing in the Discord helped either.
@djungelorm
Could you have a look at this please?
That seems promising. I'll try and run the code on a pre-1.8 version of ksp and share the results.
I could maybe make a fork of krpc and see if I can change anything.
Thanks
Update, I've run the landing site example code on ksp 1.7.3 and it works perfectly.
Seems this is the origin of the problem.
If your "Shader.Find" call does not find your old shader you can try to add "Legacy Shaders/" to the name. LIke "Legacy Shaders/Particles/Additive"
https://forum.kerbalspaceprogram.com/index.php?/topic/188933-180-modders-notes/
I'm unable to build KRPC myself so I can't test any changes.
Downgrading to KSP 1.7 allows drawing API to work.
I can confirm this issue.
Setup:
KSP 1.9.1
kRPC (server and python client) 0.4.8
Python 2.7.17
Reproducing the bug:
Python 2.7.17 (default, Apr 15 2020, 17:20:14)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import krpc
>>> conn = krpc.connect(name='Hello World')
>>> rf = conn.space_center.active_vessel.reference_frame
>>> conn.drawing.add_line((0,0,0), (1,1,1), rf)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <lambda>
File "build/bdist.linux-x86_64/egg/krpc/client.py", line 163, in _invoke
ValueError: Value cannot be null.
Parameter name: shader
Server stack trace:
at (wrapper managed-to-native) UnityEngine.Material.CreateWithShader(UnityEngine.Material,UnityEngine.Shader)
at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00007] in <7d9ec060e791409ab3eb85c61e312ed6>:0
at KRPC.Drawing.Drawable`1[T].set_Material (System.String value) [0x0000c] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at KRPC.Drawing.Drawable`1[T]..ctor (System.Type rendererType) [0x00041] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at KRPC.Drawing.Line..ctor (Vector3d lineStart, Vector3d lineEnd, KRPC.SpaceCenter.Services.ReferenceFrame referenceFrame, System.Boolean visible) [0x00000] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at KRPC.Drawing.Drawing.AddLine (KRPC.Utils.Tuple`3[T1,T2,T3] start, KRPC.Utils.Tuple`3[T1,T2,T3] end, KRPC.SpaceCenter.Services.ReferenceFrame referenceFrame, System.Boolean visible) [0x0000c] in <82f4ee9c3604449bbd2dc8f3a69fa0cf>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <ad04dee02e7e4a85a1299c7ee81c79f6>:0