diff --git a/Interfaces/Providers/IProvidesGameObjectLocking.cs b/Interfaces/Providers/IProvidesGameObjectLocking.cs new file mode 100644 index 000000000..755d21d16 --- /dev/null +++ b/Interfaces/Providers/IProvidesGameObjectLocking.cs @@ -0,0 +1,24 @@ +using Unity.Labs.ModuleLoader; +using UnityEngine; + +namespace Unity.Labs.EditorXR.Interfaces +{ + /// + /// Provide access to grouping + /// + public interface IProvidesGameObjectLocking : IFunctionalityProvider + { + /// + /// Set a GameObject's locked status + /// + /// The GameObject to set locked or unlocked + /// Locked or unlocked status + void SetLocked(GameObject go, bool locked); + + /// + /// Check whether a GameObject is locked + /// + /// GameObject locked status to test + bool IsLocked(GameObject go); + } +} diff --git a/Interfaces/Providers/IProvidesGameObjectLocking.cs.meta b/Interfaces/Providers/IProvidesGameObjectLocking.cs.meta new file mode 100644 index 000000000..ddadfeb97 --- /dev/null +++ b/Interfaces/Providers/IProvidesGameObjectLocking.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0421c0d89ad324a45ae7960a4fa65fff +timeCreated: 1501022830 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Interfaces/Subscribers/IUsesGameObjectLocking.cs b/Interfaces/Subscribers/IUsesGameObjectLocking.cs new file mode 100644 index 000000000..cef95c763 --- /dev/null +++ b/Interfaces/Subscribers/IUsesGameObjectLocking.cs @@ -0,0 +1,44 @@ +using Unity.Labs.ModuleLoader; +using UnityEngine; + +namespace Unity.Labs.EditorXR.Interfaces +{ + /// + /// Gives decorated class access to grouping + /// + public interface IUsesGameObjectLocking : IFunctionalitySubscriber + { + } + + public static class UsesGameObjectLocking + { + /// + /// Set a GameObject's locked status + /// + /// The functionality user + /// The GameObject to set locked or unlocked + /// Locked or unlocked status + public static void SetLocked(this IUsesGameObjectLocking user, GameObject go, bool locked) + { + { +#if !FI_AUTOFILL + user.provider.SetLocked(go, locked); +#endif + } + } + + /// + /// Check whether a GameObject is locked + /// + /// The functionality user + /// GameObject locked status to test + public static bool IsLocked(this IUsesGameObjectLocking user, GameObject go) + { +#if FI_AUTOFILL + return default(bool); +#else + return user.provider.IsLocked(go); +#endif + } + } +} diff --git a/Runtime/Scripts/Interfaces/FunctionalityInjection/IUsesGameObjectLocking.cs.meta b/Interfaces/Subscribers/IUsesGameObjectLocking.cs.meta similarity index 69% rename from Runtime/Scripts/Interfaces/FunctionalityInjection/IUsesGameObjectLocking.cs.meta rename to Interfaces/Subscribers/IUsesGameObjectLocking.cs.meta index 38c68f75a..e9ffad188 100644 --- a/Runtime/Scripts/Interfaces/FunctionalityInjection/IUsesGameObjectLocking.cs.meta +++ b/Interfaces/Subscribers/IUsesGameObjectLocking.cs.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: bc6748f88a54f6f45ad10e83e5b93a85 -timeCreated: 1475232652 -licenseType: Pro +guid: e0ed1eb8a68e2524998687441dd8d1e2 +timeCreated: 1501022830 +licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Runtime/Scripts/Interfaces/FunctionalityInjection/IUsesGameObjectLocking.cs b/Runtime/Scripts/Interfaces/FunctionalityInjection/IUsesGameObjectLocking.cs deleted file mode 100644 index 89fe03bca..000000000 --- a/Runtime/Scripts/Interfaces/FunctionalityInjection/IUsesGameObjectLocking.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using UnityEngine; - -namespace UnityEditor.Experimental.EditorVR -{ - /// - /// Get access to locking features - /// - public interface IUsesGameObjectLocking - { - } - - public static class IUsesGameObjectLockingMethods - { - internal static Action setLocked { get; set; } - internal static Func isLocked { get; set; } - - /// - /// Set a GameObject's locked status - /// - /// The GameObject to set locked or unlocked - /// Locked or unlocked status - public static void SetLocked(this IUsesGameObjectLocking obj, GameObject go, bool locked) - { - setLocked(go, locked); - } - - /// - /// Check whether a GameObject is locked - /// - /// GameObject locked status to test - public static bool IsLocked(this IUsesGameObjectLocking obj, GameObject go) - { - return isLocked(go); - } - } -} diff --git a/Runtime/Scripts/Modules/HighlightModule/HighlightModule.cs b/Runtime/Scripts/Modules/HighlightModule/HighlightModule.cs index 49e552064..6133cf752 100644 --- a/Runtime/Scripts/Modules/HighlightModule/HighlightModule.cs +++ b/Runtime/Scripts/Modules/HighlightModule/HighlightModule.cs @@ -40,6 +40,10 @@ struct HighlightData Material m_RayHighlightMaterialCopy; Transform m_ModuleParent; +#if !FI_AUTOFILL + IProvidesGameObjectLocking IFunctionalitySubscriber.provider { get; set; } +#endif + // Local method use only -- created here to reduce garbage collection static readonly List> k_HighlightsToRemove = new List>(); static readonly List k_MeshFilters = new List(); diff --git a/Runtime/Scripts/Modules/IntersectionModule/IntersectionModule.cs b/Runtime/Scripts/Modules/IntersectionModule/IntersectionModule.cs index cf70ca4d9..3df4d5662 100644 --- a/Runtime/Scripts/Modules/IntersectionModule/IntersectionModule.cs +++ b/Runtime/Scripts/Modules/IntersectionModule/IntersectionModule.cs @@ -54,6 +54,10 @@ class DirectIntersection SpatialHashModule m_SpatialHashModule; +#if !FI_AUTOFILL + IProvidesGameObjectLocking IFunctionalitySubscriber.provider { get; set; } +#endif + // Local method use only -- created here to reduce garbage collection readonly List m_Intersections = new List(); readonly List m_SortedIntersections = new List(); diff --git a/Runtime/Scripts/Modules/LockModule/LockModule.cs b/Runtime/Scripts/Modules/LockModule/LockModule.cs index 4ee4b9736..d2c319286 100644 --- a/Runtime/Scripts/Modules/LockModule/LockModule.cs +++ b/Runtime/Scripts/Modules/LockModule/LockModule.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Unity.Labs.EditorXR.Interfaces; using Unity.Labs.ModuleLoader; using Unity.Labs.Utils; using UnityEditor.Experimental.EditorVR.Core; @@ -8,7 +9,8 @@ namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class LockModule : ScriptableSettings, IModuleDependency, IActions, ISelectionChanged + sealed class LockModule : ScriptableSettings, IModuleDependency, IActions, + ISelectionChanged, IProvidesGameObjectLocking { class LockModuleAction : IAction, ITooltip { @@ -54,9 +56,6 @@ public void LoadModule() UpdateAction(null); actions = new List { m_LockModuleAction }; - - IUsesGameObjectLockingMethods.setLocked = SetLocked; - IUsesGameObjectLockingMethods.isLocked = IsLocked; } public void UnloadModule() { } @@ -158,5 +157,18 @@ public void OnSelectionChanged() { UpdateAction(Selection.activeGameObject); } + + public void LoadProvider() { } + + public void ConnectSubscriber(object obj) + { +#if !FI_AUTOFILL + var lockingSubscriber = obj as IFunctionalitySubscriber; + if (lockingSubscriber != null) + lockingSubscriber.provider = this; +#endif + } + + public void UnloadProvider() { } } } diff --git a/Runtime/Scripts/Modules/SelectionModule/SelectionModule.cs b/Runtime/Scripts/Modules/SelectionModule/SelectionModule.cs index 1315450d4..979809f09 100644 --- a/Runtime/Scripts/Modules/SelectionModule/SelectionModule.cs +++ b/Runtime/Scripts/Modules/SelectionModule/SelectionModule.cs @@ -25,6 +25,10 @@ sealed class SelectionModule : ScriptableSettings, IModule, IUs public event Action selected; +#if !FI_AUTOFILL + IProvidesGameObjectLocking IFunctionalitySubscriber.provider { get; set; } +#endif + // Local method use only -- created here to reduce garbage collection static readonly HashSet k_SelectedObjects = new HashSet(); static readonly List k_SingleObjectList = new List(); diff --git a/Runtime/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs b/Runtime/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs index 247b2a4ff..921ad8386 100644 --- a/Runtime/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs +++ b/Runtime/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using Unity.Labs.EditorXR.Interfaces; +using Unity.Labs.ModuleLoader; using Unity.Labs.Utils; using UnityEditor.Experimental.EditorVR.Handles; using UnityEditor.Experimental.EditorVR.UI; @@ -91,6 +93,10 @@ public override List data public Func matchesFilter { private get; set; } public Func getSearchQuery { private get; set; } +#if !FI_AUTOFILL + IProvidesGameObjectLocking IFunctionalitySubscriber.provider { get; set; } +#endif + protected override void Start() { base.Start(); diff --git a/Runtime/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs b/Runtime/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs index 7428853a4..6fb82b551 100644 --- a/Runtime/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs +++ b/Runtime/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; +using Unity.Labs.EditorXR.Interfaces; using Unity.Labs.ListView; +using Unity.Labs.ModuleLoader; using Unity.Labs.Utils; using UnityEditor.Experimental.EditorVR.Data; using UnityEditor.Experimental.EditorVR.UI; -using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Workspaces @@ -59,6 +60,10 @@ public override List data public event Action, PropertyData> arraySizeChanged; +#if !FI_AUTOFILL + IProvidesGameObjectLocking IFunctionalitySubscriber.provider { get; set; } +#endif + protected override void Start() { base.Start(); diff --git a/Runtime/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs b/Runtime/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs index 25a1b208e..af0537408 100644 --- a/Runtime/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs +++ b/Runtime/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs @@ -1,5 +1,6 @@ #if UNITY_EDITOR using System.Collections.Generic; +using Unity.Labs.EditorXR.Interfaces; using Unity.Labs.ModuleLoader; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -19,6 +20,10 @@ class LockedObjectsWorkspace : HierarchyWorkspace, IUsesGameObjectLocking string m_BaseSearchQuery; string m_CachedSearchQuery; +#if !FI_AUTOFILL + IProvidesGameObjectLocking IFunctionalitySubscriber.provider { get; set; } +#endif + public override string searchQuery { get