Skip to main content
66 votes
Accepted

Why code reflection became a must in game engines?

It allows to expose variables and functions to be used in the editor. That is, the game creation tool will use a form of reflection (or similar) on the code provided by the developers, which then ...
Theraot's user avatar
  • 27.2k
8 votes
Accepted

How can I look up an object given only the name of its type?

Yes, this is possible. Because it's making heavy use of reflection and uncontrolled strings, it can be both slow and unsafe, so I would not recommend it for regular game behaviour. For a console use ...
DMGregory's user avatar
  • 135k
2 votes

How to support run-time shader modification/code execution?

This answer is about Godot. Since Godot games are running on the same core as the editor, they can do almost everything the editor can do. This also means that powerful modding and meta-programming is ...
Theraot's user avatar
  • 27.2k
2 votes
Accepted

How can I check if `call`, `callv` failed

Checking a method signature with reflection I believe Godot does not have a means to check if a call failed... But you can check your concerns before making the call. If you are going to call like ...
Theraot's user avatar
  • 27.2k
1 vote

How use inspector to select a System.Type (not an instance) of classes inheriting from a specific class?

Here's a demo of this working with a "Type Store" scriptable object storing two types: FooDerivedA which is a subclass of ...
DMGregory's user avatar
  • 135k
1 vote
Accepted

How to get vertices array from UIElements Label class (using reflection)?

I'm not familiar with these classes, so it's possible that something else is the probelm, but having worked with Reflection before my first instinct is that the ...
PepeOjeda's user avatar
  • 711
1 vote

Creating custom editor fields based on presence of custom attribute

I have a feeling there's a better way but this seems to work ...
arcadeperfect's user avatar
1 vote
Accepted

Getting info about the script a [PropertyAttribute] is attached to in Unity

You want the declaring type of the field that uses the attribute, not the declaring type of the attribute itself. (The attribute type is defined in its own class file, so it has no tie back to the ...
DMGregory's user avatar
  • 135k
1 vote
Accepted

Plugin system with AssemblyLoadContext and unloading

AppDomain The most established and bulletproof method for plugin isolation is to use AppDomain. Anything allocated withing one ...
Shadows In Rain's user avatar
1 vote
Accepted

Using Reflection to access an array from a ScriptableObject in Unity

The error identifies exactly what the problem is: TargetException: Non-static field requires a target System.Reflection.MonoField.GetValue (System.Object obj) Since the field isn't ...
DMGregory's user avatar
  • 135k
1 vote

Get component that has specified method by Reflection API

If you are looking for a certain method by a specific name, why don't you use interfaces instead? That way you can make any MonoBehaviour class implement that interface. Of course, this wouldn't let ...
LifGwaethrakindo's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible