public void VerifyCustomSmoothing() { if (SerializedObjectUtils.IsPropertiesEqual(m_lastCustomSmoothingParameters, m_customSmoothingParameters) == false) { editedPointerManagement.ApplyCustomSmoothingParams(); } }
public void VerifyTrapezoidConfigurationsChange() { if (SerializedObjectUtils.IsPropertiesEqual(m_lastTrapezoidConfigurations, m_trapezoidConfigurations) == false || SerializedObjectUtils.IsPropertiesEqual(m_lastTrapezoidConfigurtaionIndex, m_currentTrapezoidConfigurationIndex) == false) { editedPlayerManagement.ApplyCurrentTrapezoidsConfiguration(); } }
public void SimpleObject() { var so = new SerializedObject(ScriptableObject.CreateInstance <SimpleObjectFixture>()); var prop = so.FindProperty(nameof(SimpleObjectFixture.value)); var type = SerializedObjectUtils.FindPropertyType(so, prop.propertyPath); Assert.AreEqual(typeof(string), type); }
public void VerifyMovementBoxConfigurationsChange() { if (SerializedObjectUtils.IsPropertiesEqual(m_lastLeftHandMovementBox, m_leftHandMovementBox) == false) { editedPointerManagement.ApplyLeftHandMovementBox(); } if (SerializedObjectUtils.IsPropertiesEqual(m_lastRightHandMovementBox, m_rightHandMovementBox) == false) { editedPointerManagement.ApplyRightHandMovementBox(); } }
public void ListObject() { var so = new SerializedObject(ScriptableObject.CreateInstance <ListObjectFixture>()); var prop = so.FindProperty(nameof(ListObjectFixture.items)); prop = prop.GetArrayElementAtIndex(0); prop = prop.FindPropertyRelative("test"); var type = SerializedObjectUtils.FindPropertyType(prop); Assert.AreEqual(typeof(float), type); }
public void ArrayObject() { var so = new SerializedObject(ScriptableObject.CreateInstance <ArrayObjectFixture>()); var prop = so.FindProperty(nameof(ArrayObjectFixture.children)); prop = prop.GetArrayElementAtIndex(0); prop = prop.FindPropertyRelative(nameof(ArrayObjectEntry.value)); var type = SerializedObjectUtils.FindPropertyType(so, prop.propertyPath); Assert.AreEqual(typeof(int), type); }
public override void OnInspectorGUI() { if (!MixedRealityToolkit.IsInitialized) { return; } RenderProfileHeader(ProfileTitle, ProfileDescription, target); MixedRealityInspectorUtility.CheckMixedRealityConfigured(true); serializedObject.Update(); MixedRealitySceneSystemProfile profile = (MixedRealitySceneSystemProfile)target; RenderFoldout(ref showEditorProperties, "Editor Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(editorManageBuildSettings); EditorGUILayout.PropertyField(editorManageLoadedScenes); EditorGUILayout.PropertyField(editorEnforceSceneOrder); EditorGUILayout.PropertyField(editorEnforceLightingSceneTypes); if (editorEnforceLightingSceneTypes.boolValue) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Below are the component types that will be allowed in lighting scenes. Types not found in this list will be moved to another scene.", MessageType.Info); EditorGUIUtility.labelWidth = LightingSceneTypesLabelWidth; EditorGUILayout.PropertyField(permittedLightingSceneComponentTypes, true); EditorGUIUtility.labelWidth = 0; } } }, ShowSceneSystem_Editor_PreferenceKey); RenderFoldout(ref showManagerProperties, "Manager Scene Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.HelpBox(managerSceneContent, MessageType.Info); // Disable the tag field since we're drawing manager scenes SceneInfoDrawer.DrawTagProperty = false; EditorGUILayout.PropertyField(useManagerScene); if (useManagerScene.boolValue && profile.ManagerScene.IsEmpty && !Application.isPlaying) { EditorGUILayout.HelpBox("You haven't created a manager scene yet. Click the button below to create one.", MessageType.Warning); var buttonRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(new GUILayoutOption[] { })); if (GUI.Button(buttonRect, "Create Manager Scene", EditorStyles.miniButton)) { // Create a new manager scene and add it to build settings SceneInfo newManagerScene = EditorSceneUtils.CreateAndSaveScene("ManagerScene"); SerializedObjectUtils.SetStructValue <SceneInfo>(managerScene, newManagerScene); EditorSceneUtils.AddSceneToBuildSettings(newManagerScene, EditorBuildSettings.scenes, EditorSceneUtils.BuildIndexTarget.First); } EditorGUILayout.Space(); } if (useManagerScene.boolValue) { EditorGUILayout.PropertyField(managerScene, includeChildren: true); } } }, ShowSceneSystem_Manager_PreferenceKey); RenderFoldout(ref showLightingProperties, "Lighting Scene Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.HelpBox(lightingSceneContent, MessageType.Info); EditorGUILayout.PropertyField(useLightingScene); if (useLightingScene.boolValue && profile.NumLightingScenes < 1 && !Application.isPlaying) { EditorGUILayout.HelpBox("You haven't created a lighting scene yet. Click the button below to create one.", MessageType.Warning); var buttonRect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(new GUILayoutOption[] { })); if (GUI.Button(buttonRect, "Create Lighting Scene", EditorStyles.miniButton)) { // Create a new lighting scene and add it to build settings SceneInfo newLightingScene = EditorSceneUtils.CreateAndSaveScene("LightingScene"); // Create an element in the array lightingScenes.arraySize = 1; serializedObject.ApplyModifiedProperties(); SerializedObjectUtils.SetStructValue <SceneInfo>(lightingScenes.GetArrayElementAtIndex(0), newLightingScene); EditorSceneUtils.AddSceneToBuildSettings(newLightingScene, EditorBuildSettings.scenes, EditorSceneUtils.BuildIndexTarget.Last); } EditorGUILayout.Space(); } if (useLightingScene.boolValue) { // Disable the tag field since we're drawing lighting scenes SceneInfoDrawer.DrawTagProperty = false; if (profile.NumLightingScenes > 0) { string[] lightingSceneNames = profile.LightingScenes.Select(l => l.Name).ToArray <string>(); defaultLightingSceneIndex.intValue = EditorGUILayout.Popup("Default Lighting Scene", defaultLightingSceneIndex.intValue, lightingSceneNames); } EditorGUILayout.PropertyField(lightingScenes, includeChildren: true); //DrawSceneInfoDragAndDrop(lightingScenes); EditorGUILayout.Space(); if (profile.NumLightingScenes > 0) { if (profile.EditorLightingCacheOutOfDate) { EditorGUILayout.HelpBox("Your cached lighting settings may be out of date. This could result in unexpected appearances at runtime.", MessageType.Warning); } if (InspectorUIUtility.RenderIndentedButton(new GUIContent("Update Cached Lighting Settings"), EditorStyles.miniButton)) { profile.EditorLightingCacheUpdateRequested = true; } } EditorGUILayout.Space(); } } }, ShowSceneSystem_Lighting_PreferenceKey); RenderFoldout(ref showContentProperties, "Content Scene Settings", () => { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.HelpBox(contentSceneContent, MessageType.Info); // Enable the tag field since we're drawing content scenes SceneInfoDrawer.DrawTagProperty = true; EditorGUILayout.PropertyField(contentScenes, includeChildren: true); //DrawSceneInfoDragAndDrop(contentScenes); } }, ShowSceneSystem_Content_PreferenceKey); serializedObject.ApplyModifiedProperties(); // Keep this inspector perpetually refreshed EditorUtility.SetDirty(target); }
/// <summary> /// Loads all lighting scenes, extracts their lighting data, then caches that data in the profile. /// </summary> private async Task EditorUpdateCachedLighting() { // Clear out our lighting cache profile.ClearLightingCache(); profile.EditorLightingCacheUpdateRequested = false; SceneInfo defaultLightingScene = profile.DefaultLightingScene; foreach (SceneInfo lightingScene in profile.LightingScenes) { // Load all our lighting scenes Scene scene; EditorSceneUtils.LoadScene(lightingScene, false, out scene); } // Wait for a moment so all loaded scenes have time to get set up await Task.Delay(100); foreach (SceneInfo lightingScene in profile.LightingScenes) { Scene scene; EditorSceneUtils.GetSceneIfLoaded(lightingScene, out scene); EditorSceneUtils.SetActiveScene(scene); SerializedObject lightingSettingsObject; SerializedObject renderSettingsObject; EditorSceneUtils.GetLightingAndRenderSettings(out lightingSettingsObject, out renderSettingsObject); // Copy the serialized objects into new structs RuntimeLightingSettings lightingSettings = default(RuntimeLightingSettings); RuntimeRenderSettings renderSettings = default(RuntimeRenderSettings); RuntimeSunlightSettings sunlightSettings = default(RuntimeSunlightSettings); lightingSettings = SerializedObjectUtils.CopySerializedObjectToStruct <RuntimeLightingSettings>(lightingSettingsObject, lightingSettings, "m_"); renderSettings = SerializedObjectUtils.CopySerializedObjectToStruct <RuntimeRenderSettings>(renderSettingsObject, renderSettings, "m_"); // Extract sunlight settings based on sunlight object SerializedProperty sunProperty = renderSettingsObject.FindProperty("m_Sun"); if (sunProperty == null) { Debug.LogError("Sun settings may not be available in this version of Unity."); } else { Light sunLight = (Light)sunProperty.objectReferenceValue; if (sunLight != null) { sunlightSettings.UseSunlight = true; sunlightSettings.Color = sunLight.color; sunlightSettings.Intensity = sunLight.intensity; Vector3 eulerAngles = sunLight.transform.eulerAngles; sunlightSettings.XRotation = eulerAngles.x; sunlightSettings.YRotation = eulerAngles.y; sunlightSettings.ZRotation = eulerAngles.z; } } profile.SetLightingCache(lightingScene, lightingSettings, renderSettings, sunlightSettings); } }