fourlastor-alexandria / scope-gdx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Float slider

fourlastor opened this issue · 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)
        }
    }
}