Skip to content

Commit

Permalink
Resharper->Edit->Reformat Code (Actions)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewTHEManeri committed Oct 9, 2017
1 parent 44ce77c commit 12602be
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 176 deletions.
27 changes: 14 additions & 13 deletions Actions/BaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

namespace UnityEditor.Experimental.EditorVR.Actions
{
/// <summary>
/// A convenience class for simple action implementations
/// </summary>
abstract class BaseAction : MonoBehaviour, IAction
{
public Sprite icon
{
get { return m_Icon; }
}
/// <summary>
/// A convenience class for simple action implementations
/// </summary>
abstract class BaseAction : MonoBehaviour, IAction
{
public Sprite icon
{
get { return m_Icon; }
}

[SerializeField]
Sprite m_Icon;
[SerializeField]
Sprite m_Icon;

public abstract void ExecuteAction();
}
public abstract void ExecuteAction();
}
}

#endif
43 changes: 22 additions & 21 deletions Actions/Clone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("Clone", ActionMenuItemAttribute.DefaultActionSectionName, 3)]
sealed class Clone : BaseAction, IUsesSpatialHash, IUsesViewerScale
{
public override void ExecuteAction()
{
Unsupported.DuplicateGameObjectsUsingPasteboard();
var selection = Selection.transforms;
var bounds = ObjectUtils.GetBounds(selection);
foreach (var s in selection)
{
var clone = s.gameObject;
clone.hideFlags = HideFlags.None;
var cloneTransform = clone.transform;
var cameraTransform = CameraUtils.GetMainCamera().transform;
var viewDirection = cloneTransform.position - cameraTransform.position;
cloneTransform.position = cameraTransform.TransformPoint(Vector3.forward * viewDirection.magnitude / this.GetViewerScale())
+ cloneTransform.position - bounds.center;
this.AddToSpatialHash(clone);
}
}
}
[ActionMenuItem("Clone", ActionMenuItemAttribute.DefaultActionSectionName, 3)]
sealed class Clone : BaseAction, IUsesSpatialHash, IUsesViewerScale
{
public override void ExecuteAction()
{
Unsupported.DuplicateGameObjectsUsingPasteboard();
var selection = Selection.transforms;
var bounds = ObjectUtils.GetBounds(selection);
foreach (var s in selection)
{
var clone = s.gameObject;
clone.hideFlags = HideFlags.None;
var cloneTransform = clone.transform;
var cameraTransform = CameraUtils.GetMainCamera().transform;
var viewDirection = cloneTransform.position - cameraTransform.position;
cloneTransform.position = cameraTransform.TransformPoint(Vector3.forward * viewDirection.magnitude / this.GetViewerScale())
+ cloneTransform.position - bounds.center;
this.AddToSpatialHash(clone);
}
}
}
}

#endif
23 changes: 13 additions & 10 deletions Actions/Copy.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#if UNITY_EDITOR

#if UNITY_EDITOR

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("Copy", ActionMenuItemAttribute.DefaultActionSectionName, 5)]
sealed class Copy : BaseAction
{
public override void ExecuteAction()
{
Unsupported.CopyGameObjectsToPasteboard();
Paste.SetBufferDistance(Selection.transforms);
}
}
[ActionMenuItem("Copy", ActionMenuItemAttribute.DefaultActionSectionName, 5)]
sealed class Copy : BaseAction
{
public override void ExecuteAction()
{
Unsupported.CopyGameObjectsToPasteboard();
Paste.SetBufferDistance(Selection.transforms);
}
}
}

#endif
41 changes: 21 additions & 20 deletions Actions/Cut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("Cut", ActionMenuItemAttribute.DefaultActionSectionName, 4)]
sealed class Cut : BaseAction
{
public override void ExecuteAction()
{
var selection = Selection.transforms;
if (selection != null)
{
Unsupported.CopyGameObjectsToPasteboard();
Paste.SetBufferDistance(Selection.transforms);
[ActionMenuItem("Cut", ActionMenuItemAttribute.DefaultActionSectionName, 4)]
sealed class Cut : BaseAction
{
public override void ExecuteAction()
{
var selection = Selection.transforms;
if (selection != null)
{
Unsupported.CopyGameObjectsToPasteboard();
Paste.SetBufferDistance(Selection.transforms);

foreach (var transform in selection)
{
var go = transform.gameObject;
go.hideFlags = HideFlags.HideAndDontSave;
go.SetActive(false);
}
foreach (var transform in selection)
{
var go = transform.gameObject;
go.hideFlags = HideFlags.HideAndDontSave;
go.SetActive(false);
}

Selection.activeGameObject = null;
}
}
}
Selection.activeGameObject = null;
}
}
}
}

#endif
31 changes: 16 additions & 15 deletions Actions/Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("Delete", ActionMenuItemAttribute.DefaultActionSectionName, 7)]
sealed class Delete : BaseAction, IDeleteSceneObject
{
public Action<GameObject> addToSpatialHash { private get; set; }
public Action<GameObject> removeFromSpatialHash { private get; set; }
[ActionMenuItem("Delete", ActionMenuItemAttribute.DefaultActionSectionName, 7)]
sealed class Delete : BaseAction, IDeleteSceneObject
{
public Action<GameObject> addToSpatialHash { private get; set; }
public Action<GameObject> removeFromSpatialHash { private get; set; }

public override void ExecuteAction()
{
var gameObjects = Selection.gameObjects;
foreach (var go in gameObjects)
{
this.DeleteSceneObject(go);
}
public override void ExecuteAction()
{
var gameObjects = Selection.gameObjects;
foreach (var go in gameObjects)
{
this.DeleteSceneObject(go);
}

Selection.activeGameObject = null;
}
}
Selection.activeGameObject = null;
}
}
}

#endif
17 changes: 9 additions & 8 deletions Actions/OpenScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("OpenScene", "Scene")]
sealed class OpenScene : BaseAction
{
public override void ExecuteAction()
{
Debug.LogError("ExecuteAction Action should open a sub-panel showing available scenes to open, if any are found");
}
}
[ActionMenuItem("OpenScene", "Scene")]
sealed class OpenScene : BaseAction
{
public override void ExecuteAction()
{
Debug.LogError("ExecuteAction Action should open a sub-panel showing available scenes to open, if any are found");
}
}
}

#endif
63 changes: 32 additions & 31 deletions Actions/Paste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,40 @@

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("Paste", ActionMenuItemAttribute.DefaultActionSectionName, 6)]
sealed class Paste : BaseAction, IUsesSpatialHash, IUsesViewerScale
{
static float s_BufferDistance;
[ActionMenuItem("Paste", ActionMenuItemAttribute.DefaultActionSectionName, 6)]
sealed class Paste : BaseAction, IUsesSpatialHash, IUsesViewerScale
{
static float s_BufferDistance;

public static void SetBufferDistance(Transform[] transforms)
{
if (transforms != null)
{
var bounds = ObjectUtils.GetBounds(transforms);
public static void SetBufferDistance(Transform[] transforms)
{
if (transforms != null)
{
var bounds = ObjectUtils.GetBounds(transforms);

s_BufferDistance = bounds.size != Vector3.zero ? (bounds.center - CameraUtils.GetMainCamera().transform.position).magnitude : 1f;
s_BufferDistance /= IUsesViewerScaleMethods.getViewerScale(); // Normalize this value in case viewer scale changes before paste happens
}
}
s_BufferDistance = bounds.size != Vector3.zero ? (bounds.center - CameraUtils.GetMainCamera().transform.position).magnitude : 1f;
s_BufferDistance /= IUsesViewerScaleMethods.getViewerScale(); // Normalize this value in case viewer scale changes before paste happens
}
}

public override void ExecuteAction()
{
Unsupported.PasteGameObjectsFromPasteboard();
var transforms = Selection.transforms;
var bounds = ObjectUtils.GetBounds(transforms);
foreach (var transform in transforms)
{
var pasted = transform.gameObject;
var pastedTransform = pasted.transform;
pasted.hideFlags = HideFlags.None;
var cameraTransform = CameraUtils.GetMainCamera().transform;
pastedTransform.position = cameraTransform.TransformPoint(Vector3.forward * s_BufferDistance)
+ pastedTransform.position - bounds.center;
pasted.SetActive(true);
this.AddToSpatialHash(pasted);
}
}
}
public override void ExecuteAction()
{
Unsupported.PasteGameObjectsFromPasteboard();
var transforms = Selection.transforms;
var bounds = ObjectUtils.GetBounds(transforms);
foreach (var transform in transforms)
{
var pasted = transform.gameObject;
var pastedTransform = pasted.transform;
pasted.hideFlags = HideFlags.None;
var cameraTransform = CameraUtils.GetMainCamera().transform;
pastedTransform.position = cameraTransform.TransformPoint(Vector3.forward * s_BufferDistance)
+ pastedTransform.position - bounds.center;
pasted.SetActive(true);
this.AddToSpatialHash(pasted);
}
}
}
}

#endif
23 changes: 13 additions & 10 deletions Actions/Play.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#if UNITY_EDITOR

#if UNITY_EDITOR

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("Play")]
sealed class Play : BaseAction
{
public override void ExecuteAction()
{
[ActionMenuItem("Play")]
sealed class Play : BaseAction
{
public override void ExecuteAction()
{
#if UNITY_EDITOR
EditorApplication.isPlaying = true;
EditorApplication.isPlaying = true;
#endif
}
}
}
}
}
#endif

#endif
21 changes: 12 additions & 9 deletions Actions/Redo.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#if UNITY_EDITOR

#if UNITY_EDITOR

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("Redo", ActionMenuItemAttribute.DefaultActionSectionName, 1)]
sealed class Redo : BaseAction
{
public override void ExecuteAction()
{
[ActionMenuItem("Redo", ActionMenuItemAttribute.DefaultActionSectionName, 1)]
sealed class Redo : BaseAction
{
public override void ExecuteAction()
{
#if UNITY_EDITOR
UnityEditor.Undo.PerformRedo();
UnityEditor.Undo.PerformRedo();
#endif
}
}
}
}
}

#endif
17 changes: 9 additions & 8 deletions Actions/SaveScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

namespace UnityEditor.Experimental.EditorVR.Actions
{
[ActionMenuItem("SaveScene", "Scene")]
sealed class SaveScene : BaseAction
{
public override void ExecuteAction()
{
Debug.LogError("ExecuteAction Action should save a scene here");
}
}
[ActionMenuItem("SaveScene", "Scene")]
sealed class SaveScene : BaseAction
{
public override void ExecuteAction()
{
Debug.LogError("ExecuteAction Action should save a scene here");
}
}
}

#endif
Loading

0 comments on commit 12602be

Please sign in to comment.