Skip to content

Commit

Permalink
Merge branch 'release/v4.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
VaLiuM09 committed May 21, 2024
2 parents 9e19dbb + c34a264 commit 2897da6
Show file tree
Hide file tree
Showing 46 changed files with 800 additions and 577 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Changelog - VR Builder

**v4.0.0 (2024/04/18 - Current)**
**v4.1.0 (2024/05/17 - Current)**

*[Added]*
- Significantly improved runtime performance for processes with many steps. Now the number of steps in a process has no impact on the performance.
- New multiline text drawer contributed by LEFX - thank you! The drawer is currently used in the Text To Speech behavior but can be manually set for fields in other behaviors/conditions.
- Added `ForceLockControllerState` and `UnlockControllerState` public methods to `ActionBasedControllerManager`. These can be used to externally lock the controllers e.g. in UI mode or teleport mode, which can be useful if the user is required to perform a specific action.

*[Changed]*
- The `UserSceneObject` component does not inherit from `ProcessSceneObject` anymore. This allows you to use the rig in a scene without scene object registry without getting errors - for example when loading additively scenes with processes in them. As a result, `BaseRuntimeConfiguration.User` does not work anymore. You can still use `BaseRuntimeConfiguration.LocalUser` which provides the same functionality while returning a `UserSceneObject` component. Note that nothing stops you from manually adding `ProcessSceneObject` components to parts of the rig you want to interact with the process.

*[Fixed]*
- A `link.xml` file is now automatically created before Android builds in order to prevent managed stripping from removing behavior/condition code which is actually in use, and thus resulting in a non-functional process in a standalone headset.
- Fixed tags on game objects not being converted to groups when upgrading from version 3 to 4.
- Fixed bug in the automatic updater of the Enable/Disable Object by Tag behaviors. Now these should be replaced by a correctly configured non-obsolete behavior.
- Scene property extensions will not be added multiple times when selecting the `Add Scene Property Extension` menu entry in a scene where they have already been added.

**v4.0.0 (2024/04/18)**

*[Added]*
- Added upgrade tool for updating processes to the new referencing system (see below). If you open an old process in VR Builder 4.0.0, all object references will be null because the system has changed. You can attempt to update the process by opening its scene, then selecting Tools > VR Builder > Developer > Update Process in Scene. Note it's important that the correct scene is loaded, as the updater will have to search for the correct game objects in order to update the references.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public override Rect Draw(Rect rect, object currentValue, Action<object> changeV
height += nextPosition.height;
height += EditorDrawingHelper.VerticalSpacing;
nextPosition.y = rect.y + height;
nextPosition.height = EditorDrawingHelper.SingleLineHeight;

List<Component> components = new List<Component>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public string Name
{
string behaviors = "";

if(Behaviors.Count == 0)
if (Behaviors.Count == 0)
{
behaviors = "no behavior";
}
Expand All @@ -82,6 +82,9 @@ public string Name

/// <inheritdoc />
public bool IsBlocking { get; set; }

/// <inheritdoc />
IEntity IEntitySequenceData.Current => Current;
}

private class IteratingProcess : EntityIteratingProcess<IEntitySequenceDataWithMode<IBehavior>, IBehavior>
Expand Down
100 changes: 51 additions & 49 deletions Source/Core/Editor/BuilderProjectSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,77 @@
// Licensed under the Apache License, Version 2.0
// Modifications copyright (c) 2021-2024 MindPort GmbH

using System.Collections.Generic;
using System.IO;
using VRBuilder.Editor;
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using VRBuilder.Editor.XRUtils;

/// <summary>
/// Settings for a VR Builder Unity project.
/// </summary>
public partial class BuilderProjectSettings : ScriptableObject
namespace VRBuilder.Editor.Settings
{
/// <summary>
/// Was VR Builder imported and therefore started for the first time.
/// Settings for a VR Builder Unity project.
/// </summary>
[HideInInspector]
public bool IsFirstTimeStarted = true;
public partial class BuilderProjectSettings : ScriptableObject
{
/// <summary>
/// Was VR Builder imported and therefore started for the first time.
/// </summary>
[HideInInspector]
public bool IsFirstTimeStarted = true;

/// <summary>
/// Builder version used last time this was checked.
/// </summary>
[HideInInspector]
public string ProjectBuilderVersion = null;
/// <summary>
/// Builder version used last time this was checked.
/// </summary>
[HideInInspector]
public string ProjectBuilderVersion = null;

[HideInInspector, SerializeField]
public List<string> OpenXRControllerProfiles = new List<string>();
[HideInInspector, SerializeField]
public List<string> OpenXRControllerProfiles = new List<string>();

[HideInInspector, SerializeField]
public List<XRLoaderHelper.XRSDK> XRSDKs = new List<XRLoaderHelper.XRSDK>();
[HideInInspector, SerializeField]
public List<XRLoaderHelper.XRSDK> XRSDKs = new List<XRLoaderHelper.XRSDK>();

/// <summary>
/// Loads the VR Builder settings for this Unity project from Resources.
/// </summary>
/// <returns>Settings</returns>
public static BuilderProjectSettings Load()
{
BuilderProjectSettings settings = Resources.Load<BuilderProjectSettings>("BuilderProjectSettings");
if (settings == null)
/// <summary>
/// Loads the VR Builder settings for this Unity project from Resources.
/// </summary>
/// <returns>Settings</returns>
public static BuilderProjectSettings Load()
{
if (!Directory.Exists("Assets/MindPort/VR Builder/Resources"))
BuilderProjectSettings settings = Resources.Load<BuilderProjectSettings>("BuilderProjectSettings");
if (settings == null)
{
Directory.CreateDirectory("Assets/MindPort/VR Builder/Resources");
}
// Create an instance
settings = CreateInstance<BuilderProjectSettings>();
AssetDatabase.CreateAsset(settings, "Assets/MindPort/VR Builder/Resources/BuilderProjectSettings.asset");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
if (!Directory.Exists("Assets/MindPort/VR Builder/Resources"))
{
Directory.CreateDirectory("Assets/MindPort/VR Builder/Resources");
}
// Create an instance
settings = CreateInstance<BuilderProjectSettings>();
AssetDatabase.CreateAsset(settings, "Assets/MindPort/VR Builder/Resources/BuilderProjectSettings.asset");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

return settings;
}
return settings;
}
return settings;
}

private void OnEnable()
{
if (string.IsNullOrEmpty(ProjectBuilderVersion))
private void OnEnable()
{
ProjectBuilderVersion = EditorUtils.GetCoreVersion();
if (string.IsNullOrEmpty(ProjectBuilderVersion))
{
ProjectBuilderVersion = EditorUtils.GetCoreVersion();
}
}
}

/// <summary>
/// Saves the VR Builder settings.
/// </summary>
public void Save()
{
EditorUtility.SetDirty(this);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
/// <summary>
/// Saves the VR Builder settings.
/// </summary>
public void Save()
{
EditorUtility.SetDirty(this);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}
}
26 changes: 15 additions & 11 deletions Source/Core/Editor/InputSystemChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@
// Modifications copyright (c) 2021-2024 MindPort GmbH

using UnityEditor;
using VRBuilder.Editor.Settings;

[InitializeOnLoad]
public static class InputSystemChecker
namespace VRBuilder.Editor.Setup
{
private const string message =
"VR Builder requires Unity's new Input System." +
"\n\nTo switch from the legacy input system to the new one, open the 'Player Settings' and set the " +
"option 'Active Input Handling' to 'Both' or 'Input System Package (New)'.";

/// <summary>
/// This is a check if the new input system is active OR another concrete implementation of the InputController exists.
/// </summary>
static InputSystemChecker()
[InitializeOnLoad]
public static class InputSystemChecker
{
private const string message =
"VR Builder requires Unity's new Input System." +
"\n\nTo switch from the legacy input system to the new one, open the 'Player Settings' and set the " +
"option 'Active Input Handling' to 'Both' or 'Input System Package (New)'.";

/// <summary>
/// This is a check if the new input system is active OR another concrete implementation of the InputController exists.
/// </summary>
static InputSystemChecker()
{
#if !INPUT_SYSTEM_PACKAGE || !ENABLE_INPUT_SYSTEM
if (BuilderProjectSettings.Load().IsFirstTimeStarted == false)
{
EditorUtility.DisplayDialog("Attention required!", message, "Understood");
}
#endif

}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using VRBuilder.Core.Behaviors;
using VRBuilder.Core.SceneObjects;

namespace VRBuilder.Editor.ProcessUpgradeTool
{
Expand All @@ -16,7 +17,16 @@ protected override SetObjectsEnabledBehavior PerformConversion(SetObjectsWithTag

SetObjectsEnabledBehavior newBehavior = new SetObjectsEnabledBehavior();
newBehavior.Data.SetEnabled = oldBehavior.Data.SetEnabled;
newBehavior.Data.TargetObjects = oldBehavior.Data.TargetObjects;
if (oldBehavior.Data.TargetObjects.HasValue())
{
newBehavior.Data.TargetObjects = oldBehavior.Data.TargetObjects;
}
else
{
#pragma warning disable CS0618 // Type or member is obsolete
newBehavior.Data.TargetObjects = new MultipleSceneObjectReference(oldBehavior.Data.Tag.Guid);
#pragma warning restore CS0618 // Type or member is obsolete
}
newBehavior.Data.RevertOnDeactivation = oldBehavior.Data.RevertOnDeactivation;

return newBehavior;
Expand Down
43 changes: 43 additions & 0 deletions Source/Core/Editor/ProcessUpgradeTool/ProcessUpgradeTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using VRBuilder.Core.Configuration;
using VRBuilder.Core.EntityOwners;
using VRBuilder.Core.SceneObjects;
using VRBuilder.Core.Settings;
using VRBuilder.Core.Utils;
using VRBuilder.Unity;

Expand Down Expand Up @@ -58,6 +59,38 @@ public static IEnumerable<IConverter> Converters
}
}

[MenuItem("Tools/VR Builder/Developer/Update Object Groups", false, 75)]
private static void UpdateObjectGroupsMenuEntry()
{
if (EditorUtility.DisplayDialog("Update Object Groups", "If this project contains any legacy tags, these will be added to the list of object groups.\n" +
"Proceed?", "Yes", "No"))
{
UpdateObjectGroups();
}
}

private static void UpdateObjectGroups()
{
int counter = 0;
#pragma warning disable CS0618 // Type or member is obsolete
foreach (SceneObjectTags.Tag tag in SceneObjectTags.Instance.Tags)
{
if (SceneObjectGroups.Instance.GroupExists(tag.Guid) == false)
{
SceneObjectGroups.Instance.CreateGroup(tag.Label, tag.Guid);
counter++;
}
}
#pragma warning restore CS0618 // Type or member is obsolete

if (counter > 0)
{
EditorUtility.SetDirty(SceneObjectGroups.Instance);
}

Debug.Log($"Converted {counter} tags to object groups.");
}

[MenuItem("Tools/VR Builder/Developer/Update Process in Scene", false, 70)]
private static void UpdateProcessMenuEntry()
{
Expand Down Expand Up @@ -85,10 +118,20 @@ private static void UpdateProcessMenuEntry()
return;
}

UpdateObjectGroups();

IEnumerable<ProcessSceneObject> processSceneObjects = SceneUtils.GetActiveAndInactiveComponents<ProcessSceneObject>();
foreach (ProcessSceneObject sceneObject in processSceneObjects)
{
sceneObject.ResetUniqueId();
#pragma warning disable CS0618 // Type or member is obsolete
foreach (Guid guid in sceneObject.Tags)
{
sceneObject.AddGuid(guid);
}
#pragma warning restore CS0618 // Type or member is obsolete

EditorUtility.SetDirty(sceneObject);
}

UpdateDataOwnerRecursively(process);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,21 @@ public abstract class PropertyUpdater<TNew, TOld> : IUpdater
public void Update(MemberInfo memberInfo, object owner)
{
TNew propertyValue = (TNew)ReflectionUtils.GetValueFromPropertyOrField(owner, memberInfo);
string ownerName = owner is INamedData ? ((INamedData)owner).Name : owner.ToString();

if (ShouldBeUpdated(propertyValue) == false)
{
string ownerName = owner is INamedData ? ((INamedData)owner).Name : owner.ToString();
Debug.Log($"Skipped <i>{memberInfo.Name}</i> in <i>{ownerName}</i>: does not need updating.");
return;
}

if (AttemptToUpdateProperty(memberInfo, owner))
{
string ownerName = owner is INamedData ? ((INamedData)owner).Name : owner.ToString();
TNew updatedValue = (TNew)ReflectionUtils.GetValueFromPropertyOrField(owner, memberInfo);
Debug.Log($"Successfully updated <i>{memberInfo.Name}</i> to <b>{updatedValue}</b> in <i>{ownerName}</i>.");
}
else
{
string ownerName = owner is INamedData ? ((INamedData)owner).Name : owner.ToString();
Debug.LogWarning($"Failed to update <i>{memberInfo.Name}</i> in <i>{ownerName}</i>.");
}
}
Expand Down
32 changes: 17 additions & 15 deletions Source/Core/Editor/ProcessValidation/DisabledValidationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
// Copyright (c) 2013-2019 Innoactive GmbH
// Copyright (c) 2013-2019 Innoactive GmbH
// Licensed under the Apache License, Version 2.0
// Modifications copyright (c) 2021-2024 MindPort GmbH

using VRBuilder.Core;
using VRBuilder.Editor.ProcessValidation;

/// <summary>
/// Does not validate, used to disabled the validation system.
/// </summary>
internal class DisabledValidationHandler : IValidationHandler
namespace VRBuilder.Editor.ProcessValidation
{
public IContextResolver ContextResolver { get; set; } = null;
/// <summary>
/// Does not validate, used to disabled the validation system.
/// </summary>
internal class DisabledValidationHandler : IValidationHandler
{
public IContextResolver ContextResolver { get; set; } = null;

public IValidationReport LastReport { get; } = null;
public IValidationReport LastReport { get; } = null;

public bool IsAllowedToValidate()
{
return false;
}
public bool IsAllowedToValidate()
{
return false;
}

public IValidationReport Validate(IData data, IProcess process, IContext context = null)
{
return null;
public IValidationReport Validate(IData data, IProcess process, IContext context = null)
{
return null;
}
}
}
Loading

0 comments on commit 2897da6

Please sign in to comment.