You've already forked UniversalViewer
Eversoul support WIP
Updated line renderer material for handles Handle fixes Fixes
This commit is contained in:
@@ -6,6 +6,9 @@ using System.Collections;
|
||||
using CommandUndoRedo;
|
||||
using System.Linq;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEditor.PackageManager;
|
||||
using static UnityEngine.Rendering.VirtualTexturing.Debugging;
|
||||
using static UnityEngine.GraphicsBuffer;
|
||||
|
||||
namespace RuntimeGizmos
|
||||
{
|
||||
@@ -160,6 +163,8 @@ namespace RuntimeGizmos
|
||||
|
||||
ModelViewerInterface.SetTooltip(0, $"H - show/hide this\r\n\r\nUndo:\t\t{ActionKey} + {UndoAction}\r\nRedo:\t\t{ActionKey} + {RedoAction}\r\n\r\nMove only: \t{changeModeHotkey} + {SetMoveType}\r\nRotate only: {changeModeHotkey} + {SetRotateType}\r\nScale only: \t{changeModeHotkey} + {SetScaleType}\r\nAll:\t \t{changeModeHotkey} + {SetAllTransformType}");
|
||||
ModelViewerInterface.SetTooltip(1, $"\r\n\r\nSpace Toggle:\t{changeModeHotkey} + {SetSpaceToggle}\r\nPivot Toggle:\t{changeModeHotkey} + {SetPivotModeToggle}\r\nScale type toggle: \t{changeModeHotkey} + {SetScaleTypeToggle}\r\nCenter type toggle:{changeModeHotkey} + {SetCenterTypeToggle}");
|
||||
|
||||
ModelViewerMain.OnObjectDeleteEvent.AddListener((_) => ClearTargets());
|
||||
}
|
||||
|
||||
private void RenderPipelineManager_endFrameRendering(ScriptableRenderContext context, Camera[] camera)
|
||||
@@ -706,30 +711,38 @@ namespace RuntimeGizmos
|
||||
bool isAdding = Input.GetKey(AddSelection);
|
||||
bool isRemoving = Input.GetKey(RemoveSelection);
|
||||
|
||||
RaycastHit hitInfo;
|
||||
if (Physics.Raycast(myCamera.ScreenPointToRay(Input.mousePosition), out hitInfo, Mathf.Infinity, selectionMask))
|
||||
RaycastHit[] hits = Physics.RaycastAll(myCamera.ScreenPointToRay(Input.mousePosition), Mathf.Infinity, selectionMask);
|
||||
if (hits.Length > 0)
|
||||
{
|
||||
Transform target = hitInfo.transform;
|
||||
UIHandle handle = target.GetComponent<UIHandle>();
|
||||
|
||||
if (rightClick)
|
||||
{
|
||||
HandleManager.CloseAllPopups();
|
||||
handle.TogglePopup(0);
|
||||
}
|
||||
else if (leftClick)
|
||||
if (!isAdding && !isRemoving)
|
||||
{
|
||||
if (isAdding)
|
||||
ClearTargets();
|
||||
}
|
||||
|
||||
for (int i = 0; i < hits.Length; i++)
|
||||
{
|
||||
var hitInfo = hits[i];
|
||||
Transform target = hitInfo.transform;
|
||||
UIHandle handle = target.GetComponent<UIHandle>();
|
||||
|
||||
if (rightClick)
|
||||
{
|
||||
AddTarget(target);
|
||||
handle.TogglePopup(i);
|
||||
}
|
||||
else if (isRemoving)
|
||||
else if (leftClick)
|
||||
{
|
||||
RemoveTarget(target);
|
||||
}
|
||||
else if (!isAdding && !isRemoving)
|
||||
{
|
||||
ClearAndAddTarget(target);
|
||||
if (isRemoving)
|
||||
{
|
||||
RemoveTarget(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTarget(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -793,6 +806,7 @@ namespace RuntimeGizmos
|
||||
targetRootsOrdered.Clear();
|
||||
children.Clear();
|
||||
ModelViewerMain.GetInstance().SelectionClear();
|
||||
UpdateModelViewerHandleSelection();
|
||||
}
|
||||
|
||||
void ClearAndAddTarget(Transform target)
|
||||
@@ -890,7 +904,10 @@ namespace RuntimeGizmos
|
||||
targetRootsOrdered.Add(targetRoot);
|
||||
|
||||
AddAllChildren(targetRoot);
|
||||
|
||||
UpdateModelViewerHandleSelection();
|
||||
}
|
||||
|
||||
void RemoveTargetRoot(Transform targetRoot)
|
||||
{
|
||||
if (targetRoots.Remove(targetRoot))
|
||||
@@ -898,6 +915,8 @@ namespace RuntimeGizmos
|
||||
targetRootsOrdered.Remove(targetRoot);
|
||||
|
||||
RemoveAllChildren(targetRoot);
|
||||
|
||||
UpdateModelViewerHandleSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,6 +935,7 @@ namespace RuntimeGizmos
|
||||
|
||||
childrenBuffer.Clear();
|
||||
}
|
||||
|
||||
void RemoveAllChildren(Transform target)
|
||||
{
|
||||
childrenBuffer.Clear();
|
||||
@@ -1499,5 +1519,28 @@ namespace RuntimeGizmos
|
||||
isTransforming = value;
|
||||
HandleManager.InteractionInProgress = value;
|
||||
}
|
||||
|
||||
public void UpdateModelViewerHandleSelection()
|
||||
{
|
||||
if(_applicationQuitting) return;
|
||||
|
||||
var ui = ModelViewerInterface.GetInstance();
|
||||
for (int i = ui.SelectedHandlesPanel.content.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(ui.SelectedHandlesPanel.content.GetChild(i).gameObject);
|
||||
}
|
||||
|
||||
foreach (var transform in targetRootsOrdered)
|
||||
{
|
||||
SliderPanel.CreateToggle(transform.name, true, ui.SelectedHandlesPanel.content, (_) => RemoveTargetRoot(transform));
|
||||
}
|
||||
}
|
||||
|
||||
private bool _applicationQuitting = false;
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
_applicationQuitting = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user