func (s *Scene) Update(dt float64) {
	if s.isElementsNextUpdateDirty {
		s.elements = s.elementsNextUpdate
		s.isElementsNextUpdateDirty = false
	}
	for _, e := range s.elements {
		e.Update(dt)
		if e.IsDestroyed() {
			s.RemoveElement(e.Name())
		}
	}
}
Update is called during a frame update
package egui
import (
	"image"
	"sort"
	"github.com/hajimehoshi/ebiten"
	"github.com/xackery/egui/common"
	"github.com/xackery/egui/element"
)
type Scene struct {
	isElementsNextUpdateDirty bool
	elementsNextUpdate        elements
	elements                  elements
}
func (ui *UI) NewScene(name string) (*Scene, error) {
	s := &Scene{}
	err := ui.AddScene(name, s)
	if err != nil {
		return nil, err
	}
	return s, nil
}
func (s *Scene) Element(name string) (element.Interfacer, error) {
	if name == "" {
		return nil, common.ErrElementNameInvalid
	}
	for _, se := range s.elementsNextUpdate {
		if se.Name() != name {
			continue
		}
		return se, nil
	}
	return nil, common.ErrElementNotFound
}
func (s *Scene) AddElement(e element.Interfacer) error {
	if e.Name() == "" {
		return common.ErrElementNotFound
	}
	for _, se := range s.elementsNextUpdate {
		if se.Name() != e.Name() {
			continue
		}
		return common.ErrElementAlreadyExists
	}
	s.elementsNextUpdate = append(s.elementsNextUpdate, e)
	s.isElementsNextUpdateDirty = true
	sort.Sort(elements(s.elementsNextUpdate))
	return nil
}
func (s *Scene) RemoveElement(name string) error {
	if name == "" {
		return common.ErrElementNameInvalid
	}
	var isFound bool
	for i := range s.elementsNextUpdate {
		if s.elementsNextUpdate[i].Name() != name {
			continue
		}
		isFound = true
		s.elementsNextUpdate[i] = s.elementsNextUpdate[len(s.elementsNextUpdate)-1]
		s.elementsNextUpdate = s.elementsNextUpdate[:len(s.elementsNextUpdate)-1]
		break
	}
	if !isFound {
		return common.ErrElementNotFound
	}
	sort.Sort(elements(s.elementsNextUpdate))
	s.isElementsNextUpdateDirty = true
	return nil
}