Skip to content

Commit

Permalink
Convert IUsesGameObjectLocking to IProvides/UsesGameObjectLocking
Browse files Browse the repository at this point in the history
  • Loading branch information
mtschoen committed Jun 9, 2019
1 parent 9938ac1 commit 910daf9
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 45 deletions.
24 changes: 24 additions & 0 deletions Interfaces/Providers/IProvidesGameObjectLocking.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Unity.Labs.ModuleLoader;
using UnityEngine;

namespace Unity.Labs.EditorXR.Interfaces
{
/// <summary>
/// Provide access to grouping
/// </summary>
public interface IProvidesGameObjectLocking : IFunctionalityProvider
{
/// <summary>
/// Set a GameObject's locked status
/// </summary>
/// <param name="go">The GameObject to set locked or unlocked</param>
/// <param name="locked">Locked or unlocked status</param>
void SetLocked(GameObject go, bool locked);

/// <summary>
/// Check whether a GameObject is locked
/// </summary>
/// <param name="go">GameObject locked status to test</param>
bool IsLocked(GameObject go);
}
}
12 changes: 12 additions & 0 deletions Interfaces/Providers/IProvidesGameObjectLocking.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions Interfaces/Subscribers/IUsesGameObjectLocking.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Unity.Labs.ModuleLoader;
using UnityEngine;

namespace Unity.Labs.EditorXR.Interfaces
{
/// <summary>
/// Gives decorated class access to grouping
/// </summary>
public interface IUsesGameObjectLocking : IFunctionalitySubscriber<IProvidesGameObjectLocking>
{
}

public static class UsesGameObjectLocking
{
/// <summary>
/// Set a GameObject's locked status
/// </summary>
/// <param name="user">The functionality user</param>
/// <param name="go">The GameObject to set locked or unlocked</param>
/// <param name="locked">Locked or unlocked status</param>
public static void SetLocked(this IUsesGameObjectLocking user, GameObject go, bool locked)
{
{
#if !FI_AUTOFILL
user.provider.SetLocked(go, locked);
#endif
}
}

/// <summary>
/// Check whether a GameObject is locked
/// </summary>
/// <param name="user">The functionality user</param>
/// <param name="go">GameObject locked status to test</param>
public static bool IsLocked(this IUsesGameObjectLocking user, GameObject go)
{
#if FI_AUTOFILL
return default(bool);
#else
return user.provider.IsLocked(go);
#endif
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

4 changes: 4 additions & 0 deletions Runtime/Scripts/Modules/HighlightModule/HighlightModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ struct HighlightData
Material m_RayHighlightMaterialCopy;
Transform m_ModuleParent;

#if !FI_AUTOFILL
IProvidesGameObjectLocking IFunctionalitySubscriber<IProvidesGameObjectLocking>.provider { get; set; }
#endif

// Local method use only -- created here to reduce garbage collection
static readonly List<KeyValuePair<Material, GameObject>> k_HighlightsToRemove = new List<KeyValuePair<Material, GameObject>>();
static readonly List<MeshFilter> k_MeshFilters = new List<MeshFilter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class DirectIntersection

SpatialHashModule m_SpatialHashModule;

#if !FI_AUTOFILL
IProvidesGameObjectLocking IFunctionalitySubscriber<IProvidesGameObjectLocking>.provider { get; set; }
#endif

// Local method use only -- created here to reduce garbage collection
readonly List<Renderer> m_Intersections = new List<Renderer>();
readonly List<SortableRenderer> m_SortedIntersections = new List<SortableRenderer>();
Expand Down
20 changes: 16 additions & 4 deletions Runtime/Scripts/Modules/LockModule/LockModule.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
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;
using UnityEngine;

namespace UnityEditor.Experimental.EditorVR.Modules
{
sealed class LockModule : ScriptableSettings<LockModule>, IModuleDependency<EditorXRMenuModule>, IActions, ISelectionChanged
sealed class LockModule : ScriptableSettings<LockModule>, IModuleDependency<EditorXRMenuModule>, IActions,
ISelectionChanged, IProvidesGameObjectLocking
{
class LockModuleAction : IAction, ITooltip
{
Expand Down Expand Up @@ -54,9 +56,6 @@ public void LoadModule()
UpdateAction(null);

actions = new List<IAction> { m_LockModuleAction };

IUsesGameObjectLockingMethods.setLocked = SetLocked;
IUsesGameObjectLockingMethods.isLocked = IsLocked;
}

public void UnloadModule() { }
Expand Down Expand Up @@ -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<IProvidesGameObjectLocking>;
if (lockingSubscriber != null)
lockingSubscriber.provider = this;
#endif
}

public void UnloadProvider() { }
}
}
4 changes: 4 additions & 0 deletions Runtime/Scripts/Modules/SelectionModule/SelectionModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ sealed class SelectionModule : ScriptableSettings<SelectionModule>, IModule, IUs

public event Action<Transform> selected;

#if !FI_AUTOFILL
IProvidesGameObjectLocking IFunctionalitySubscriber<IProvidesGameObjectLocking>.provider { get; set; }
#endif

// Local method use only -- created here to reduce garbage collection
static readonly HashSet<Object> k_SelectedObjects = new HashSet<Object>();
static readonly List<GameObject> k_SingleObjectList = new List<GameObject>();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -91,6 +93,10 @@ public override List<HierarchyData> data
public Func<string, bool> matchesFilter { private get; set; }
public Func<string> getSearchQuery { private get; set; }

#if !FI_AUTOFILL
IProvidesGameObjectLocking IFunctionalitySubscriber<IProvidesGameObjectLocking>.provider { get; set; }
#endif

protected override void Start()
{
base.Start();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -59,6 +60,10 @@ public override List<InspectorData> data

public event Action<List<InspectorData>, PropertyData> arraySizeChanged;

#if !FI_AUTOFILL
IProvidesGameObjectLocking IFunctionalitySubscriber<IProvidesGameObjectLocking>.provider { get; set; }
#endif

protected override void Start()
{
base.Start();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,6 +20,10 @@ class LockedObjectsWorkspace : HierarchyWorkspace, IUsesGameObjectLocking
string m_BaseSearchQuery;
string m_CachedSearchQuery;

#if !FI_AUTOFILL
IProvidesGameObjectLocking IFunctionalitySubscriber<IProvidesGameObjectLocking>.provider { get; set; }
#endif

public override string searchQuery
{
get
Expand Down

0 comments on commit 910daf9

Please sign in to comment.