Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
waynecochran's avatar
8 months ago

Looking for getter methods for SceneObject's

There are a number of "setter methods" for SceneObject, but I am not finding where the corresponding "getter methods" are.

e.g. getName(), getPosition(), getRotation(), isVisible(), etc...

1 Reply

Replies have been turned off for this discussion
  • NotBadB's avatar
    NotBadB
    Meta Employee

    Hi, we don't provide those getter APIs, however if you used an entity to create your SceneObject by attaching a Mesh component, you can get the Transform and Visible components of that entity to get the values of the SceneObject. Here's an example:

    val myEntity = Entity.create(Mesh(Uri.parse("example.glb")), Transform(Pose(Vector3(1f, 2f, 3f))), Visible())
    
    // This will create a SceneObject
    // Sometime later (at least one tick)
    val mySceneObject = systemManager.findSystem<SceneObjectSystem>().getSceneObject(myEntity)
    
    val myTransform = myEntity.getComponent<Transform>().transform
    val myPosition = myTransform.t
    val myRotation = myTransform.q
    
    val myVisible =myEntity.getComponent<Visible>()
    
    // example of changing isVisible to false
    myVisible.isVisible = false
    myEntity.setComponent(myVisible)


    Hopefully this answers your question. Let me know if you need any more help