I have 2 partial classes in main/editor projects unity, but unity show me error message "error CS1061: Type 'Engine.Test' does not contain a definition for 'radius' and no extension method 'radius' of type 'Engine.Test' could be found. Are you missing an assembly reference?"
./Assets/Test.cs (in main project):
namespace Engine {
public partial class Test : MonoBehaviour {
[SerializeField]
private float radius = 1f;
}
}
./Assets/Editor/TestEditor.cs (in project Editor):
namespace Engine {
public partial class Test {
private void OnDrawGizmosSelected() {
Gizmos.color = new Color(1f, 1f, 0f, 0.3f);
Gizmos.DrawSphere(new Vector3(0,0,0), radius); // in "this" context field "radius" not found
}
}
}
What am i doing wrong?
Unity Editor files are included in a separate C# project, and end up in a separate assembly. You cannot define partial classes over assembly boundaries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With