You've already forked UniversalViewer
Eversoul support WIP
Updated line renderer material for handles Handle fixes Fixes
This commit is contained in:
@@ -80,7 +80,7 @@ public class UIHandle : MonoBehaviour
|
||||
|
||||
if (Collider.transform.localScale.x != 0 && transform.lossyScale.x != 0)
|
||||
{
|
||||
Collider.radius = 35 /* magic number */ * (1 / transform.lossyScale.x) * GetRadiusOnScreen(camera, Collider.transform.position, Handle.transform.localScale.x);
|
||||
Collider.radius = Mathf.Abs(35 /* magic number */ * (1 / transform.lossyScale.x) * GetRadiusOnScreen(camera, Collider.transform.position, Handle.transform.localScale.x));
|
||||
Collider.radius = Mathf.Clamp(Collider.radius, 0.001f, 2);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class UIHandle : MonoBehaviour
|
||||
/// <summary> For future, `offset` param will allow popups to be spaced out when selecting more than 1 handle at a time. </summary>
|
||||
public void TogglePopup(int offset = 0)
|
||||
{
|
||||
Popup.Offset = offset * Popup.GetComponent<RectTransform>().sizeDelta.x;
|
||||
Popup.Offset = offset * (Popup.transform as RectTransform).sizeDelta.x * ModelViewerInterface.GetInstance().MainCanvas.scaleFactor;
|
||||
ModelViewerInterface.ToggleVisible(Popup.gameObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIHandleMain : UIHandle
|
||||
@@ -17,9 +18,26 @@ public class UIHandleMain : UIHandle
|
||||
Popup.AddButton("Reset Position", TransformResetPosition);
|
||||
Popup.AddButton("Reset Rotation", TransformResetRotation);
|
||||
Popup.AddButton("Reset Scale", TransformResetScale);
|
||||
Popup.AddButton("Reset Children", ResetBones);
|
||||
Popup.AddButton("Delete", () => Destroy(Owner));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void ResetBones()
|
||||
{
|
||||
using (var context = new KeyframeToggleContext(Owner, false))
|
||||
{
|
||||
foreach (var bone in Owner.GetComponentsInChildren<UIHandle>())
|
||||
{
|
||||
bone.TransformResetAll();
|
||||
}
|
||||
}
|
||||
Owner.SetKeyframe();
|
||||
}
|
||||
|
||||
protected override bool ShouldBeHidden()
|
||||
{
|
||||
return _forceDisplayOff || !HandleManager.Instance.EnabledHandles.Contains(SerializableBone.BoneTags.Root);
|
||||
}
|
||||
}
|
||||
|
||||
32
Assets/Scripts/ModelViewerBase/UI/ProgressBar.cs
Normal file
32
Assets/Scripts/ModelViewerBase/UI/ProgressBar.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ProgressBar : MonoBehaviour
|
||||
{
|
||||
public TMPro.TMP_Text Label;
|
||||
public Slider Progress;
|
||||
|
||||
public void SetProgress(string task, float progress)
|
||||
{
|
||||
bool active = gameObject.activeSelf;
|
||||
|
||||
if(progress == 0 || progress == 1)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!active)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
Label.text = task;
|
||||
Progress.value = progress;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ModelViewerBase/UI/ProgressBar.cs.meta
Normal file
11
Assets/Scripts/ModelViewerBase/UI/ProgressBar.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f95da0c1d0b9a5042a41865b5d0b3e60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -102,7 +102,8 @@ public class UIElementDragger : MonoBehaviour, IDragHandler, IEndDragHandler, IP
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
var rectTsf = GetComponent<RectTransform>();
|
||||
var rectTsf = transform as RectTransform;
|
||||
var canvas = ModelViewerInterface.GetInstance().MainCanvas;
|
||||
|
||||
switch (LastDragAction)
|
||||
{
|
||||
@@ -116,9 +117,9 @@ public class UIElementDragger : MonoBehaviour, IDragHandler, IEndDragHandler, IP
|
||||
{
|
||||
var mousePos = (Vector2)Input.mousePosition;
|
||||
mousePos.y = -(Screen.height - mousePos.y); //convert anchor from bottom-left to top-left
|
||||
var sizeDelta = mousePos - rectTsf.anchoredPosition;
|
||||
sizeDelta.x = Mathf.Clamp(sizeDelta.x, SizeMin.x, Mathf.Min(Screen.width, SizeMax.x));
|
||||
sizeDelta.y = Mathf.Clamp(-sizeDelta.y, SizeMin.y, Mathf.Min(Screen.height, SizeMax.y));
|
||||
var sizeDelta = mousePos / canvas.scaleFactor - (Vector2)rectTsf.anchoredPosition;
|
||||
sizeDelta.x = Mathf.Clamp(sizeDelta.x, SizeMin.x, Mathf.Min(Screen.width / canvas.scaleFactor, SizeMax.x));
|
||||
sizeDelta.y = Mathf.Clamp(-sizeDelta.y, SizeMin.y, Mathf.Min(Screen.height / canvas.scaleFactor, SizeMax.y));
|
||||
if (currentScale > 0)
|
||||
{
|
||||
sizeDelta *= currentScale;
|
||||
|
||||
20
Assets/Scripts/ModelViewerBase/UI/UITimelineObjectEntry.cs
Normal file
20
Assets/Scripts/ModelViewerBase/UI/UITimelineObjectEntry.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class UITimelineObjectEntry : MonoBehaviour
|
||||
{
|
||||
public TMPro.TMP_Text NameLabel;
|
||||
public ObjectContainer Container;
|
||||
|
||||
public static UITimelineObjectEntry Create(ObjectContainer container)
|
||||
{
|
||||
var entry = Instantiate(SharedResources.Instance.TimelineObjectEntry, TimelineController.Instance.ObjectsList.content);
|
||||
entry.NameLabel.text = container.name;
|
||||
entry.Container = container;
|
||||
return entry;
|
||||
}
|
||||
|
||||
public void Select()
|
||||
{
|
||||
ModelViewerMain.GetInstance().SelectObject(Container);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b539eb155d38c7544aee424d21367c5a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user