#
Reflection
Methods which can help you to call private methods, get and set values to/from private fields.
Fields
Methods
No fields
#
Constructors
No constructors
#
Fields
No fields
#
Methods
#
CallMethod(this o, methodName, params args): object
Call private method
Returns: object
Examples:
using ReflectionUtility;
//...
//Adding spawn effect to 'MapBox.instance.stackEffects' calling private method 'startSpawnEffect' with arguments 'newUnit.currentTile' and 'spawn'
MapBox.instance.stackEffects.CallMethod("startSpawnEffect", newUnit.currentTile, "spawn");
//...
//...
//Adding spawn effect to 'MapBox.instance.stackEffects' calling private method 'startSpawnEffect' with arguments 'newUnit.currentTile' and 'spawn'
ReflectionUtility.Reflection.CallMethod(MapBox.instance.stackEffects, "startSpawnEffect", newUnit.currentTile, "spawn");
//...
using ReflectionUtility;
//...
//Checking if '(Kingdom)kingdom' is enemy for '(Kingdom)pActor.kingdom' calling private method 'isEnemy' with argument '(Kingdom)kingdom', receiving 'bool'
var isEnemy = (bool)pActor.kingdom.CallMethod("isEnemy", kingdom);
//...
#
CallStaticMethod(type, methodName, params args): object
Call static private method
Returns: object
Examples:
using ReflectionUtility;
//...
//Checking for existance window with id 'inspect_unit'
Reflection.CallStaticMethod(typeof(ScrollWindow), "checkWindowExist", "inspect_unit");
//...
#
GetField(type, instance, fieldName): object
Get value from private field
Returns: object
Examples:
using ReflectionUtility;
//...
//Get private field '(Dictionary<string, string>)localizedText' from 'LocalizedTextManager' which contains translations texts
var texts = (Dictionary<string, string>)Reflection.GetField(LocalizedTextManager.instance.GetType(), LocalizedTextManager.instance, "localizedText");
//...
using ReflectionUtility;
//...
//Get static private field '(Dictionary<string, ScrollWindow>)allWindows' from 'ScrollWindow' which contains all ScrollWindow windows
Reflection.GetField(typeof(ScrollWindow), null, "allWindows") as Dictionary<string, ScrollWindow>;
//...
#
SetField(originalObject, fieldName, T newValue): void
void
Set value to private field
Returns: void
Examples:
using ReflectionUtility;
//...
//Set value '(Race)raceObj' to 'race' field in '(City)city' object
Reflection.SetField<Race>(city, "race", raceObj);
//...