#pragma warning restore CS0618 // Type or member is obsolete private void ShowAntialiasingDropdown() { bool deferred = false; #if !UNITY_5_5_OR_NEWER deferred = PlayerSettings.renderingPath == RenderingPath.DeferredLighting; #else var settings = UnityEditor.Rendering.EditorGraphicsSettings. GetTierSettings(EditorUserBuildSettings.selectedBuildTargetGroup, Graphics.activeTier); deferred = settings.renderingPath == RenderingPath.DeferredLighting || settings.renderingPath == RenderingPath.DeferredShading; #endif if (deferred) { GUILayout.Label(DeferredNotSupportedLabel); if (_controller.AntiAliasing != 1) { _controller.AntiAliasing = 1; } return; } var values = AntiAliasingHelper.Values; var previousIndex = values.ToList().IndexOf(_controller.AntiAliasing); var stringOptions = AntiAliasingHelper.NamedValues; UndoableInputFieldUtils.PopupLabeled(index => _controller.AntiAliasing = values[index], AntiAliasingLabel, previousIndex, stringOptions, _controller.Settings); }
private void ShowDecoratorsControls() { var decorators = _controller.Decorators; if (PlayerSettings.defaultInterfaceOrientation == UIOrientation.AutoRotation) { EditorGUI.BeginDisabledGroup(true); } UndoableInputFieldUtils.BoolFieldWithTooltip(() => decorators.ParallaxAutoRotation, v => { decorators.ParallaxAutoRotation = v; #if UNITY_EDITOR && UNITY_ANDROID if (PlayerSettings.defaultInterfaceOrientation == UIOrientation.AutoRotation && v) { this.Warning(EnabledParallaxWarning); } #endif } , ParallaxFieldLabel, "Only accessible when Player Settings -> Android -> Resolution and presentation -> Default orientation is not AutoRotation", _controller.Settings); if (PlayerSettings.defaultInterfaceOrientation == UIOrientation.AutoRotation) { EditorGUI.EndDisabledGroup(); } if (Application.isPlaying) { EditorGUI.BeginDisabledGroup(true); } UndoableInputFieldUtils.BoolFieldWithTooltip(() => decorators.AlphaBlending, v => decorators.AlphaBlending = v, AlphaBlendingLabel, alphaBlendingTooltip, _controller.Settings); if (Application.isPlaying) { EditorGUI.EndDisabledGroup(); } // Edit > Project Settings > Player settings > Other > Scripting define symbols #if LEIA_ADVANCED_USER // for ShowTiles param on LeiaDisplay decorator // setting does not persist between runs if (Application.isEditor && Application.isPlaying) { UndoableInputFieldUtils.BoolField(() => _controller.Decorators.ShowTiles, (bool b) => { decorators.ShowTiles = b; _controller.IsDirty = true; }, ShowTilesFieldLabel); } #endif _controller.Decorators = decorators; }
private void ShowLookAtTarget() { bool lookAt = _controller.LookAtTarget; UndoableInputFieldUtils.BoolField(() => lookAt, v => { _controller.LookAtTarget = v; }, "Look at Target"); }
public void OnGUI() { if (window == null) { Init(); } EditorWindowUtils.TitleTexture(_bannerImage); if (issueCount == 0) { EditorWindowUtils.Space(2); var style = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold }; EditorWindowUtils.Label("Fantastic! You're good to go!", style); } else { EditorWindowUtils.HelpBox("Recommended Unity Editor settings for LeiaLoft SDK:", MessageType.Warning); } scrollPosition = EditorWindowUtils.BeginScrollView(scrollPosition); EditorWindowUtils.Space(5); if (recommendations != null) { for (int i = 0; i < recommendations.Count; i++) { recommendations[i].CheckRecommendation(); } } EditorWindowUtils.EndScrollView(); EditorWindowUtils.BeginHorizontal(); UndoableInputFieldUtils.BoolFieldWithTooltip(() => { forceShow = EditorPrefs.GetBool(editor_Recommendation_ForcePopUp, false); return(forceShow); }, b => { forceShow = b; EditorPrefs.SetBool(editor_Recommendation_ForcePopUp, b); }, " Automatically Pop-up", "Display this window when LeiaLoft detects unrecommended Unity Settings. Alternatively, this widow can be opened from LeiaLoft-> Recommended Unity Settings", window); if (ignoreCount > 0) { EditorWindowUtils.Button(() => { for (int i = 0; i < recommendations.Count; i++) { if (EditorPrefs.HasKey(recommendations[i].IgnoreKey)) { EditorPrefs.DeleteKey(recommendations[i].IgnoreKey); recommendations[i].IsIgnored = false; } } }, string.Format("Reset Ignores ({0})", ignoreCount)); } EditorWindowUtils.EndHorizontal(); EditorWindowUtils.Space(2); }
private void ShowRaycastFields() { UndoableInputFieldUtils.LayerField(() => _controller.TargetCollisionLayer, v => _controller.TargetCollisionLayer = v, "Raycast Layer", _controller); UndoableInputFieldUtils.EnumField(() => _controller.RaycastType, v => _controller.RaycastType = (LeiaAutoFocus.RaycastTypes)v, "Raycast Type", _controller); if (_controller.RaycastType == LeiaAutoFocus.RaycastTypes.Sphere) { EditorGUI.indentLevel = 2; ShowSphereRadius(); EditorGUI.indentLevel = 1; } }
private void ShowLightfieldModeControl() { LeiaDisplay.LightfieldMode[] modes = new[] { LeiaDisplay.LightfieldMode.Off, LeiaDisplay.LightfieldMode.On }; string[] options = new[] { modes[0].ToString(), modes[1].ToString() }; int previousIndex = _controller.DesiredLightfieldValue; UndoableInputFieldUtils.PopupLabeled(index => { _controller.DesiredLightfieldMode = modes[index]; } , LightfieldModeLabel, previousIndex, options, _controller); }
public override void OnInspectorGUI() { // User can begin "recording" in editor, but LateUpdate() will only be called during play EditorGUILayout.HelpBox("Recording will be saved at Assets/StreamingAssets after finishing capture and then unfocusing and refocusing Unity as an app", MessageType.Info); if (!UnityEditor.EditorApplication.isPlaying) { EditorGUILayout.HelpBox("Recording is only recommended during editor play mode", MessageType.Info); } #if !UNITY_2017_3_OR_NEWER EditorGUILayout.HelpBox("Use Unity 2017.3+ to record video", MessageType.Warning); #endif EditorGUILayout.PropertyField(lmr_recordingCondition); EditorGUILayout.PropertyField(lmr_recordingFormat); EditorGUILayout.PropertyField(lmr_frameRate); // since we convert value to string, we do not have to worry about pre-2017.3 vs post-2017.3 issues string condition = ((LeiaLoft.LeiaMediaRecorder.RecordingCondition)lmr_recordingCondition.enumValueIndex).ToString(); if (lmr != null && lmr_recordingFormat.enumValueIndex == -1) { Debug.LogWarningFormat("Project was rolled back to version predating MediaEncoder. Change {0}.LeiaMediaRecorder.recordingCondition to be png or jpg", lmr.transform.name); } if (lmr != null && condition.Equals("frame")) { UndoableInputFieldUtils.ImmediateFloatField( () => { return(lmr.startTime); }, (float f) => { lmr.startTime = f; }, "Start time (sec)" ); UndoableInputFieldUtils.ImmediateFloatField( () => { return(lmr.endTime); }, (float f) => { lmr.endTime = f; }, "End time (sec)" ); } // inactive: offer to start recording if (lmr != null && !lmr.GetActive() && condition.Equals("button_click") && GUILayout.Button("Start recording")) { lmr.BeginRecording(); } // active: offer to stop recording if (lmr != null && lmr.GetActive() && condition.Equals("button_click") && GUILayout.Button("Stop recording")) { lmr.EndRecording(); } serializedObject.ApplyModifiedProperties(); }
private void ShowRenderTechniqueControl() { if (_controller.DesiredLightfieldMode != LeiaDisplay.LightfieldMode.On) { return; } LeiaDisplay.RenderTechnique[] renderTechniques = new[] { LeiaDisplay.RenderTechnique.Default, LeiaDisplay.RenderTechnique.Stereo }; string[] options = new[] { string.Format("{0}", renderTechniques[0]), string.Format("{0}", renderTechniques[1]) }; int previousIndex = (int)_controller.DesiredRenderTechnique; UndoableInputFieldUtils.PopupLabeled(index => { _controller.DesiredRenderTechnique = renderTechniques[index]; }, RenderTechniqueLabel, previousIndex, options, _controller.Settings); }
private void ShowTrackingTypes() { UndoableInputFieldUtils.EnumField(() => _controller.TrackingMode, v => _controller.TrackingMode = (LeiaAutoFocus.TrackingModes)v, "Tracking Mode", _controller); if (_controller.TrackingMode == LeiaAutoFocus.TrackingModes.Target) { EditorGUI.indentLevel = 1; _controller.Target = (GameObject)EditorGUILayout.ObjectField("Target", _controller.Target, typeof(GameObject), true); ShowLookAtTarget(); EditorGUI.indentLevel = 0; } else if (_controller.TrackingMode == LeiaAutoFocus.TrackingModes.Raycast) { EditorGUI.indentLevel = 1; ShowRaycastFields(); ShowMaxFocusDistance(); EditorGUI.indentLevel = 0; } }
#pragma warning disable CS0618 // Type or member is obsolete private void ShowRenderModeControl() { List <string> leiaModes = _controller.GetDisplayConfig().RenderModes; var list = leiaModes.ToList().Beautify(); var previousIndex = list.IndexOf(_controller.DesiredLeiaStateID, ignoreCase: true); if (previousIndex < 0) { LogUtil.Log(LogLevel.Error, "Did not recognize renderMode {0}", _controller.DesiredLeiaStateID); list.Add(_controller.DesiredLeiaStateID); previousIndex = list.Count - 1; } EditorGUI.BeginDisabledGroup(true); UndoableInputFieldUtils.PopupLabeled(index => { if (list[index] == LeiaDisplay.TWO_D) { _controller.DesiredLightfieldMode = LeiaDisplay.LightfieldMode.Off; } else if (list[index] == LeiaDisplay.THREE_D || list[index] == LeiaDisplay.HPO) { _controller.DesiredLightfieldMode = LeiaDisplay.LightfieldMode.On; } else { LogUtil.Log(LogLevel.Error, "Could not match RenderMode {0} at index {1} to LightfieldMode", list[index], index); } } , RenderModeLabel, previousIndex, list.ToArray(), _controller.Settings); EditorGUI.EndDisabledGroup(); if (_controller.DesiredLeiaStateID == LeiaDisplay.TWO_D && _controller.IsLightfieldModeDesiredOn() || _controller.DesiredLeiaStateID == LeiaDisplay.HPO && !_controller.IsLightfieldModeDesiredOn()) { Debug.LogErrorFormat("On GameObject {0}: state mismatch between legacy RenderMode DesiredLeiaStateID {1} and LightfieldMode {2}\n" + "Please update the {0}'s LightfieldMode", _controller.gameObject.name, _controller.DesiredLeiaStateID, _controller.DesiredLightfieldMode); } }
private void ShowMaxFocusDistance() { UndoableInputFieldUtils.ImmediateFloatField(() => _controller.MaxFocusDistance, v => _controller.MaxFocusDistance = v, "Max Focus Distance", _controller); }
private void ShowFocusSmoothing() { UndoableInputFieldUtils.ImmediateFloatField(() => _controller.FocusSpeed, v => _controller.FocusSpeed = v, "Focus Speed", _controller); }
private void ShowFocalOffset() { UndoableInputFieldUtils.ImmediateFloatField(() => _controller.FocusOffset, v => _controller.FocusOffset = v, "Focus Offset", _controller); }
private void ShowSphereRadius() { UndoableInputFieldUtils.ImmediateFloatField(() => _controller.SphereRadius, v => _controller.SphereRadius = v, "Sphere Radius", _controller); }
/// <summary> /// User needs to be able to set DisplayConfig once and have setting persist through play/edit process. /// /// Dev needs to be able to retrieve DisplayConfig data without chaining through LeiaDisplay -> DeviceFactory -> OfflineEmulationLeiaDevice. /// These objects may be reconstructed and drop pointers on play, or some code which we want to be editor-only would have to be included in builds. /// </summary> void ShowDisplayConfigDropdown() { // build a path to subfolder where display config files are found string searchPath = Application.dataPath; foreach (string subfolder in new[] { "LeiaLoft", "Resources" }) { searchPath = System.IO.Path.Combine(searchPath, subfolder); } string fileSearchString = "DisplayConfiguration_"; string fileTerminalString = ".json"; // convert file paths into short names which can be displayed to user string[] displayConfigPathMatches = System.IO.Directory.GetFiles(searchPath, fileSearchString + "*.json"); List <string> displayConfigFilenames = new List <string>(); for (int i = 0; i < displayConfigPathMatches.Length; i++) { displayConfigFilenames.Add(System.IO.Path.GetFileName(displayConfigPathMatches[i])); } // write user-selection into editor prefs int ind = Mathf.Max(0, displayConfigFilenames.IndexOf(OfflineEmulationLeiaDevice.EmulatedDisplayConfigFilename)); if (ind >= displayConfigFilenames.Count) { LogUtil.Log(LogLevel.Error, "No DisplayConfiguration files found in Assets/LeiaLoft/Resources! Please reinstall your LeiaLoft Unity SDK"); return; } string[] trimmedDisplayConfigFilenameArray = displayConfigFilenames.Select(x => x.Replace(fileSearchString, "").Replace(fileTerminalString, "")).ToArray(); // suppress DisplayConfig dropdown selection when build player window is open. This avoids a bug where selecting a new build target, // not switching platform, and then changing emulated device profile would cause Unity to throw a GUI error bool isBuildPlayerWindowOpen = IsWindowOpen <BuildPlayerWindow>(); EditorGUI.BeginDisabledGroup(Application.isPlaying || isBuildPlayerWindowOpen); UndoableInputFieldUtils.PopupLabeled( (int i) => { OfflineEmulationLeiaDevice.EmulatedDisplayConfigFilename = displayConfigFilenames[i]; }, "Editor Emulated Device", ind, trimmedDisplayConfigFilenameArray); if (isBuildPlayerWindowOpen) { EditorGUILayout.LabelField("Close build player window before changing emulated device profile"); } UndoableInputFieldUtils.BoolFieldWithTooltip( () => { return(LeiaPreferenceUtil.GetUserPreferenceBool(true, OfflineEmulationLeiaDevice.updateGameViewResOnDisplayProfileChange, Application.dataPath)); }, (bool b) => { LeiaPreferenceUtil.SetUserPreferenceBool(OfflineEmulationLeiaDevice.updateGameViewResOnDisplayProfileChange, b, Application.dataPath); }, "Set game view resolution when Editor Emulated Device changes", "", null); EditorGUILayout.LabelField(""); EditorGUI.EndDisabledGroup(); }
public override void OnInspectorGUI() { if (_controller == null) { _controller = (LeiaCamera)target; } if (!_controller.enabled) { return; } EditorGUI.BeginChangeCheck(); // allow multi-object editing // display object properties in sequence when multiple objects selected for (int i = 0; i < targets.Length; i++) { _controller = (LeiaCamera)targets[i]; if (targets.Length > 1) { EditorGUILayout.Separator(); EditorGUILayout.ObjectField(_controller, typeof(LeiaCamera), true); } UndoableInputFieldUtils.ImmediateFloatField(() => _controller.ConvergenceDistance, v => _controller.ConvergenceDistance = v, ConvergenceDistanceFieldLabel, _controller); UndoableInputFieldUtils.ImmediateFloatField(() => _controller.BaselineScaling, v => _controller.BaselineScaling = v, BaselineScalingFieldLabel, _controller); UndoableInputFieldUtils.BoolField(() => _controller.DrawCameraBounds, v => _controller.DrawCameraBounds = v, DrawCameraBoundsFieldLabel, _controller); EditorGUILayout.Separator(); if (EditorApplication.isPlaying) { if (!LeiaDisplay.InstanceIsNull) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(UpdateEffectsButtonLabel)) { _controller.UpdateEffects(); } EditorGUILayout.HelpBox(UpdateEffectsHelpText, MessageType.Info); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox(NoEffectsControllerHelpText, MessageType.Info); } } if (targets.Length > 1) { EditorGUILayout.Separator(); } } if (EditorGUI.EndChangeCheck()) { foreach (Object obj in targets) { EditorUtility.SetDirty(obj); } } }