- Home /
Question by
SeigneurNecron · May 10, 2018 at 01:15 AM ·
reflectionupdate problemoverride
Reflection code to test method override not working after updating Unity from 2017.1.0p4 to 2018.1.0f2
Hello,
I have the following code in my project :
// Extension Method :
public static bool IsOverride(this MethodInfo methodInfo) {
return methodInfo.GetBaseDefinition() != methodInfo;
}
// Methods in a class that most of my behaviors extend :
public virtual bool HasFixedUpdate() {
return this.GetType().GetMethod("Do1_FixedUpdate").IsOverride();
}
public virtual void Do1_FixedUpdate() {
Debug.LogWarning(string.Format("{0}.FixedUpdate: This method should not be executed unless overridden.", this.GetType().Name));
}
The problem is HasFixedUpdate()
always return true
since I updated Unity from 2017.1.0p4 to 2018.1.0f2, even when the method is not overridden.
Does someone know what's happening ?
Comment
Best Answer
Answer by SeigneurNecron · May 10, 2018 at 01:40 AM
Ok, it seems to work again if I change my extension method as follow :
// Extension Method :
public static bool IsOverride(this MethodInfo methodInfo) {
return methodInfo.GetBaseDefinition().DeclaringType != methodInfo.DeclaringType;
}
I'm curious about why the previous version behavior changed though.
Your answer
Follow this Question
Related Questions
How does Unity call Update() etc without override or reflection? 2 Answers
Projectile Ricochet Issue. Travels along the surface rather than reflecting off of it 2 Answers
When does texture max-size override take effect? 1 Answer
Can individual textures be told to ignore the Texture Quality setting? 2 Answers