void GetProperty(GameObject gameObject, Component component, string propertyName) { Type componentType = component.GetType(); PropertyInfo pInfo = componentType.GetProperty(propertyName); if (pInfo != null) { PrintToConsole(pInfo.GetValue(component, null).ToString()); } }