Soo this is a very weird issue that I have no explanation for. So here is the code :
private void Update(){
GetAnimationCon();
}
private void GetAnimationCon(){
var AnimPreviewInspector=Resources.FindObjectsOfTypeAll(typeof(Editor).Assembly.GetType("UnityEditor.AnimationClipEditor"));
System.Reflection.FieldInfo[] fields = AnimPreviewInspector[0].GetType().GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var AnimPreview = new object();
var AnimCon= new object();
foreach (System.Reflection.FieldInfo f in fields){
if(f.name == "m_AvatarPreview")
{
AnimPreview = f.GetValue(AnimPreviewInspector[0];
System.Reflection.PropertyInfo[] props = AnimPreview.GetType().GetProperties(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
foreach(System.Reflection.PropertyInfo p in props){
if(p.GetIndexParameters().Length==0&&p.Name == "Animator")
{
AnimCon = p.GetValue(AnimPreview);
}
}
}
The above code compiles fine in Visual Studio, no complaints. It is done exactly like the examples shown in the C# docs. Now when I look at Unity it tries to tell me that there is no overload for method GetValue that takes 1 arguments. The line numbers are corresponding to wherever I am trying to get the value of a property. I’m like what the hell because it doesn’t compile in Visual Studio without an argument. Please help. Maybe its a bug and I can’t do anything about it? Below is a link to the documentation for the get value function. Also it doesn’t complain about me trying to get fields and that works just fine.
https://msdn.microsoft.com/en-us/library/hh194385(v=vs.110).aspx