Apologies for how basic this question is, but I have spent hours at this to no avail.
Here is a very basic script that has a public field for a MeshRender (which is assigned in the inspector in Unity)
`import { Behaviour, MeshRenderer, serializable } from “@needle-tools/engine”
import { Object3D } from “three”;
export class SphereMeshController extends Behaviour
{
@serializable(Object3D)
public sphereMesh?: MeshRenderer;
DisableMesh()
{
if(this.sphereMesh != null)
{
this.sphereMesh.enabled = false;
}
}
} export default SphereMeshController;`
I am calling DisableMesh() like so from a different script, by creating an instance of the SphereMeshController object.
let sphereController = new SphereMeshController(); sphereController.DisableMesh();
however within the DisableMesh() method, the sphereMesh variable is always null.
Ive read through the documentation and the only thing I can see is that I could maybe try and do this through events, but that seems overly complex for such a trivial action.
Am I doing something unbelievably stupid? Any links to relevant documentation or examples would be appreciated. I looked through the scripting docs on the website but haven’t seen the solution.
by user 259070246382469121