Open nanonull opened 8 years ago
I've tested It's possible extract primitive types of classe with:
public class RigidBodyComponent extends Component {
public final Vector2 velocity = new Vector2();
}
Class cls = RigidBodyComponent.class;
showFields(cls);
public void showFields(Class cls) {
Field[] fields = cls.getFields();
for (Field field : fields) {
String name = String.valueOf(field.getName());
if (ClassUtils.isPrimitiveOrWrapper(field.getType())) {
Gdx.app.log("Field", name);
} else if (!Modifier.isStatic(field.getModifiers())) {
showFields(field.getType());
}
}
}
I'm using for ClassUtils:
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'
Output was x and y
Object[] possibleValues = enumValue.getDeclaringClass().getEnumConstants();
returns all enums values
Hi, thanks for your input. I remember about this issue. However, I've taken the long path to solve it. Instead of serializing just directive primitive fields in components I decided to implement my own serializer that deserializes into general value tree which is to be represtented in GUI. In practice, you should be able to modify any object in your component. No ETA/roadmap, though.
More on this here: https://www.namekdev.net/2017/04/serializing-java-why-i-work-on-new-serializer/ and here: https://www.namekdev.net/2017/03/artemis-entity-tracker-inspecting-your-game-state-through-network/
Given: Component with Field1 of non-primitive type
Expected: String.valueOf(Field1) is invoked and this result is displayed (read-only) in Component-Details-View for Field1
Actual: 'reference' text is displayed for Field1