Initial commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class AxialMoveBehavior : ToggleBehaviour
|
||||
{
|
||||
|
||||
private SelectionManager selectionManager;
|
||||
private GameObject currentGizmosMove;
|
||||
[SerializeField] private GameObject gizmosMovePrefab;
|
||||
private IInteractable CurrentSelection;
|
||||
|
||||
protected void Start()
|
||||
{
|
||||
selectionManager = SelectionManager.getInstance();
|
||||
selectionManager.SelectionEvent.AddListener(interactable => CurrentSelection = interactable);
|
||||
base.Start();
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
GizmoInit();
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
GizmoDeselect();
|
||||
}
|
||||
|
||||
private void GizmoInit()
|
||||
{
|
||||
if (selectionManager.HasOneSelection())
|
||||
{
|
||||
if (currentGizmosMove == null)
|
||||
{
|
||||
currentGizmosMove = Instantiate(gizmosMovePrefab, CurrentSelection.transform);
|
||||
currentGizmosMove.transform.parent = CurrentSelection.transform;
|
||||
currentGizmosMove.transform.localPosition = Vector3.zero;
|
||||
currentGizmosMove.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void GizmoDeselect()
|
||||
{
|
||||
if (currentGizmosMove != null)
|
||||
{
|
||||
Destroy(currentGizmosMove);
|
||||
currentGizmosMove = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user