void CacheABunchOfStuff(SerializedProperty property) { object lens = SerializedPropertyHelper.GetPropertyValue(property); IsOrtho = AccessProperty <bool>(typeof(LensSettings), lens, "Orthographic"); IsPhysical = AccessProperty <bool>(typeof(LensSettings), lens, "IsPhysicalCamera"); SensorSize = AccessProperty <Vector2>(typeof(LensSettings), lens, "SensorSize"); List <GUIContent> options = new List <GUIContent>(); CinemachineLensPresets presets = CinemachineLensPresets.InstanceIfExists; if (presets != null) { for (int i = 0; i < presets.m_Presets.Length; ++i) { options.Add(new GUIContent(presets.m_Presets[i].m_Name)); } } options.Add(new GUIContent("Edit Presets...")); m_PresetOptions = options.ToArray(); options.Clear(); if (presets != null) { for (int i = 0; i < presets.m_PhysicalPresets.Length; ++i) { options.Add(new GUIContent(presets.m_PhysicalPresets[i].m_Name)); } } options.Add(new GUIContent("Edit Presets...")); m_PhysicalPresetOptions = options.ToArray(); }
LensSettings def = new LensSettings(); // to access name strings public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) { float height = EditorGUIUtility.singleLineHeight; rect.height = height; mExpanded = EditorGUI.Foldout(rect, mExpanded, label); if (mExpanded) { bool ortho = false; PropertyInfo pi = typeof(LensSettings).GetProperty( "Orthographic", BindingFlags.NonPublic | BindingFlags.Instance); if (pi != null) { ortho = bool.Equals(true, pi.GetValue(SerializedPropertyHelper.GetPropertyValue(property), null)); } ++EditorGUI.indentLevel; rect.y += height + vSpace; if (ortho) { EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.OrthographicSize)); } else { EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.FieldOfView)); } rect.y += height + vSpace; EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.NearClipPlane)); rect.y += height + vSpace; EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.FarClipPlane)); rect.y += height + vSpace; EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.Dutch)); --EditorGUI.indentLevel; } }
public void SnapshotCameraShadowValues(SerializedProperty property, Camera camera) { ModeOverrideProperty = property.FindPropertyRelative(() => m_LensSettingsDef.ModeOverride); // Assume lens is up-to-date UseHorizontalFOV = false; object lensObject = SerializedPropertyHelper.GetPropertyValue(property); IsOrtho = AccessProperty <bool>(typeof(LensSettings), lensObject, "Orthographic"); IsPhysical = AccessProperty <bool>(typeof(LensSettings), lensObject, "IsPhysicalCamera"); SensorSize = AccessProperty <Vector2>(typeof(LensSettings), lensObject, "SensorSize"); // Then pull from actual camera if appropriate if (camera != null) { #if UNITY_2019_1_OR_NEWER // This should really be a global setting, but for now there is no better way than this! var p = new SerializedObject(camera).FindProperty("m_FOVAxisMode"); if (p != null && p.intValue == (int)Camera.FieldOfViewAxis.Horizontal) { UseHorizontalFOV = true; } #endif // It's possible that the lens isn't synched with its camera - fix that here if (ModeOverrideProperty.intValue == (int)LensSettings.OverrideModes.None) { IsOrtho = camera.orthographic; IsPhysical = camera.usePhysicalProperties; SensorSize = IsPhysical ? camera.sensorSize : new Vector2(camera.aspect, 1f); } } }
bool ValueRangeIsLocked(SerializedProperty property) { bool locked = false; PropertyInfo pi = typeof(AxisState).GetProperty( "ValueRangeLocked", BindingFlags.NonPublic | BindingFlags.Instance); if (pi != null) { locked = bool.Equals(true, pi.GetValue(SerializedPropertyHelper.GetPropertyValue(property), null)); } return(locked); }
bool HasInputProvider(SerializedProperty property) { bool value = false; PropertyInfo pi = typeof(AxisState).GetProperty( "HasInputProvider", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (pi != null) { value = bool.Equals(true, pi.GetValue(SerializedPropertyHelper.GetPropertyValue(property), null)); } return(value); }