fourlastor-alexandria/scope-gdx

Float slider

Opened this issue · 0 comments

private class FloatFieldScope constructor(name: String?, instance: Any?, field: Field) :
    FieldScope(name, instance, field) {
    private val value: FloatArray

    init {
        try {
            value = FloatArray(1) { field.getFloat(instance) }
        } catch (e: IllegalAccessException) {
            throw RuntimeException(e)
        }
    }

    override fun display() {
        ImGui.dragFloat(name, value )
    }

    override fun apply() {
        try {
            field.setFloat(instance, value[0])
        } catch (e: IllegalAccessException) {
            throw RuntimeException(e)
        }
    }
}