Questions tagged [code-reflection]

Reflection is the ability of a computer program to examine, introspect, and modify its own structure and behavior at runtime. Use this tag for programming features that need to reason about the code itself. For questions about rendering visual reflections, use the Reflection-Rendering tag instead.

Filter by
Sorted by
Tagged with
3 votes
1 answer
49 views

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

In Godot, how can I check whether e.g. Call(...) or Callv(...) succeeded or failed? By failed I mean due to e.g. missing method, ...
geekley's user avatar
  • 133
0 votes
1 answer
695 views

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

I have an abstract class, call it FooClass. And there are two classes that inherit from it, call 'em BazClass and ...
osman doluca's user avatar
1 vote
1 answer
61 views

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

I am trying to access the per letter vertices array in the UIElements (UI Toolkit) Label Unity class. Background A Label of this type can be created for example with: ...
mike's user avatar
  • 481
0 votes
2 answers
871 views

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

I would like to create an educational game, part of which involves allowing the user to modify code for procedurally generating geometry on the CPU and modify shader code and see the changes they make ...
TomKern's user avatar
  • 101
0 votes
0 answers
322 views

Using reflection to find custom attribute declarations in all assemblies

In the Unity documentation section Overview of .NET in Unity (https://docs.unity3d.com/2022.1/Documentation/Manual/overview-of-dot-net-in-unity.html), it states: ...
FICHEKK's user avatar
  • 179
1 vote
1 answer
226 views

Creating custom editor fields based on presence of custom attribute

I'm creating a manager object that controls a bunch of other objects at once. I want to be able to restrict / expose parameters in the target object to the manager via a custom attribute. I have the ...
arcadeperfect's user avatar
0 votes
1 answer
287 views

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

Is there a way to access info about the script that a PropertyAttribute is part of in Unity? In my case: getting the memberInfos of the script: ...
Charly's user avatar
  • 742
0 votes
1 answer
797 views

Plugin system with AssemblyLoadContext and unloading

I'm building a game engine from scratch and trying to implement a basic plugin system within my engine. Using AssemblyLoadContext to load the target dll dynamicly ...
Roveldo's user avatar
  • 50
2 votes
0 answers
94 views

How to get struct layouts from vertex shader input using ID3D12Reflection

I am attempting to write a code generator that builds C++ structs/classes from D3D12 reflection data built using DXC. Given a simple vertex shader signature: ...
MSinger's user avatar
  • 21
1 vote
0 answers
155 views

Skyrim:Papyrus Possible Conflict Error [18+?]

I am working with a friend of mine to create a mod that relies on a mod called Devious devices, which would allow BDSM be utilized in Skyrim's combat by allowing the assailants to have special weapons ...
garret Lennelluc's user avatar
43 votes
1 answer
15k views

Why code reflection became a must in game engines?

I'm currently doing some research on programming languages(compile time reflection area, if you ask) and I found that on the game engine area the reflection feature becomes a must, an engine either ...
ravenisadesk's user avatar
0 votes
1 answer
1k views

Using Reflection to access an array from a ScriptableObject in Unity

I am trying to get access to a set of stored variables inside a scriptible object in Unity. This class (SectorDeclaration) has a method to pull a variable with a string of the variables name from it: ...
TartanKavuJr's user avatar
2 votes
1 answer
91 views

Dynamic object creation from data

I want to write somewhat randomized object activation effects, like when you step on a trap, you can be tepelorted, damaged, cursed and so on. I applied strategy pattern for this: damage/healing ...
Swhad's user avatar
  • 23
0 votes
2 answers
163 views

Get component that has specified method by Reflection API

Let's say that I have a component like this: ...
modernator's user avatar
  • 1,183
-1 votes
1 answer
51 views

Can't access object parent type if some parent object along the way was in array

I use this method to get type of the object the field was declared via reflection. (f.e.) this time it's field at index [5] - ...
Candid Moon _Max_'s user avatar
3 votes
0 answers
688 views

Making generic type T method as a layer of abstraction for Unty3D's EditorGUI field draw methods

I am making a visual tool for Editor Window on Unity3D, and I am just recently using System.Reflection methods to get class's assembly data, to get information about properties, fields and methods (...
LifGwaethrakindo's user avatar
5 votes
1 answer
439 views

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

This question came from a fellow developer on Twitter, and I figured StackExchange would be a better format for explaining & sharing the answer. To paraphrase the question: I'm setting up an in-...
DMGregory's user avatar
  • 130k
4 votes
3 answers
1k views

Object-oriented Ability System?

For my RTS game's ability system, I need an efficient ability system where each ability is its own class that implements certain functions from an inherited abstract base class, Ability. Every ability ...
JPtheK9's user avatar
  • 2,021
4 votes
2 answers
5k views

C++ property system interface for game editors (reflection system)

I have designed an reusable game engine for an project, and their functionality is like this: Is a completely scripted game engine instead of the usual scripting languages as Lua or Python, this uses ...
Cristopher Sosa's user avatar
4 votes
3 answers
2k views

How do I add a method to a class without editing the source file?

I am trying to add a method to a Minecraft source file, but I have to figure out how to do it without actually editing the source files, as it would be illegal to redistribute Minecraft's source files ...
Andrew Graber's user avatar
2 votes
1 answer
745 views

Is it important for reflection-based serialization maintain consistent field ordering?

I just finished writing a packet builder that dynamically loads data into a data stream for eventual network transmission. Each builder operates by finding fields in a given class (and its ...
Matchlighter's user avatar
0 votes
1 answer
1k views

C++ formatted serialization [closed]

I've decided it's time to implement serialization in my simple engine but this has caused me many headaches for the past couple of days/weeks. My engine uses an entity/component based approach similar ...
Grieverheart's user avatar
  • 1,195
6 votes
5 answers
8k views

Input/Output console window in XNA

I am currently making a simple game in XNA but am at a point where testing various aspect gets a bit tricky, especially when you have to wait till you have 1000 score to see if your animation is ...
Will Bagley's user avatar
4 votes
1 answer
476 views

How do I check if a key is down in XNA when I'm only given a string that has the key's name?

I'm trying to get access to the keyboard state in XNA from an embedded JavaScript runtime. I'd like to do something similar to the following, but I can't seem to figure out how to get from "Left" to ...
Daniel X Moore's user avatar