I'm trying to set a property of an object in a class, but the error says Object does not match target type
.
FieldInfo dControl = window.GetType().GetField("dControl", BindingFlags.NonPublic | BindingFlags.Instance);
if (dControl == null) { Debug.Log ("dControl is null"); return;}
Type typeDC = dControl.FieldType;
PropertyInfo inPreviewMode = typeDC.GetProperty("InPreviewMode", BindingFlags.Public | BindingFlags.Instance);
if (inPreviewMode == null) { Debug.Log ("dControl.InPreviewMode is null"); return;}
bool value = false;
inPreviewMode.SetValue(dControl, value, null);
This is the property I'm trying to access:
public class DControl : TimeArea
{
public bool InPreviewMode
{
get
{
return dState.IsInPreviewMode;
}
set
{
if (cutscene != null)
{
...
}
}
dState.IsInPreviewMode = value;
}
...
}
Help is appreciated.
Aucun commentaire:
Enregistrer un commentaire