Search code examples
pythoncameraursina

Ursina EditorCamera() toggle


this is the code I have used to toggle between having an EditorCamera in Ursina and turning it off:

from ursina import *
app = Ursina()
def input(key):
    if key == 'd':
        editor_camera.enabled = False
    if key == 'e':
        editor_camera.enabled = True

editor_camera = EditorCamera(enabled = False)

cube = Entity(model = "cube", texture = "brick") # just to see if it works


app.run()

When applied on its own like this, it works fine but when I apply the same logic to a much larger project, when enabling the camera (press e) everything just disappears and when I disable the camera (press d), it all reappears. Is there something I'm missing? Any help is appreciated.


Solution

  • After @pokepetter's answer, I figured out a new solution, just replace your code with this one:

    from ursina import *
    app = Ursina()
    
    def input(key):
        if key == 'd':
            editor_camera.ignore = True
    
        if key == 'e':
            editor_camera.ignore = False
    
    
    editor_camera = EditorCamera()
    cube = Entity(model = "cube", texture = "brick")
    app.run()