Pose mode improvements
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -10,11 +11,57 @@ public class PoseManager : MonoBehaviour
|
||||
|
||||
public UIPoseContainer Pfb_PoseContainer;
|
||||
|
||||
private bool _isPoseMode = false;
|
||||
public TMPro.TMP_Text[] TooltipLabels;
|
||||
|
||||
public void LoadPoses()
|
||||
[NonSerialized]
|
||||
public bool PoseModeOn = false;
|
||||
|
||||
[SerializeField]
|
||||
[Header("Toggles")]
|
||||
private Toggle
|
||||
_loadRoot;
|
||||
|
||||
[SerializeField]
|
||||
private Toggle
|
||||
_loadPosition,
|
||||
_loadRotation,
|
||||
_loadScale,
|
||||
_loadMorphs,
|
||||
_loadFaceBones,
|
||||
_loadPhysics;
|
||||
|
||||
public List<UIPoseContainer> SavedPoses = new List<UIPoseContainer>();
|
||||
|
||||
public GameObject HandleCanvas;
|
||||
public GameObject HelpPanel;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
foreach(var file in Directory.GetFiles($"{Application.dataPath}/../Poses/"))
|
||||
if (Input.GetKeyDown(KeyCode.H))
|
||||
{
|
||||
HelpPanel.SetActive(!HelpPanel.activeSelf);
|
||||
}
|
||||
}
|
||||
|
||||
public static PoseLoadOptions GetLoadOptions()
|
||||
{
|
||||
var pm = UmaViewerUI.Instance.PoseManager;
|
||||
return new PoseLoadOptions()
|
||||
{
|
||||
Root = pm._loadRoot.isOn,
|
||||
Position = pm._loadPosition.isOn,
|
||||
Rotation = pm._loadRotation.isOn,
|
||||
Scale = pm._loadScale.isOn,
|
||||
Morphs = pm._loadMorphs.isOn,
|
||||
FaceBones = pm._loadFaceBones.isOn,
|
||||
Physics = pm._loadPhysics.isOn
|
||||
};
|
||||
}
|
||||
|
||||
public void LoadLocalPoseFiles()
|
||||
{
|
||||
Directory.CreateDirectory(Application.dataPath + "/../Poses");
|
||||
foreach (var file in Directory.GetFiles($"{Application.dataPath}/../Poses/"))
|
||||
{
|
||||
Debug.Log(file);
|
||||
try
|
||||
@@ -33,20 +80,62 @@ public class PoseManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetPoseModeStatic(bool value)
|
||||
{
|
||||
UmaViewerUI.Instance.PoseManager.SetPoseMode(value);
|
||||
}
|
||||
|
||||
/// <summary> Used on UI buttons </summary>
|
||||
public void SetPoseMode(bool value)
|
||||
{
|
||||
if (value == _isPoseMode) return;
|
||||
if (UmaViewerBuilder.Instance.CurrentUMAContainer == null) return;
|
||||
if (value == PoseModeOn) return;
|
||||
|
||||
if (value)
|
||||
{
|
||||
_isPoseMode = true;
|
||||
UmaViewerBuilder.Instance.CurrentUMAContainer.UmaAnimator.enabled = false;
|
||||
EnablePoseMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
_isPoseMode = false;
|
||||
UmaViewerBuilder.Instance.CurrentUMAContainer.UmaAnimator.enabled = true;
|
||||
DisablePoseMode();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetTooltip(int panelId, string text)
|
||||
{
|
||||
UmaViewerUI.Instance.PoseManager.TooltipLabels[panelId].text = text;
|
||||
}
|
||||
|
||||
public void EnablePoseMode()
|
||||
{
|
||||
var ui = UmaViewerUI.Instance;
|
||||
var builder = UmaViewerBuilder.Instance;
|
||||
ui.SetEyeTrackingEnable(false);
|
||||
ui.SetDynamicBoneEnable(false);
|
||||
HandleCanvas.SetActive(true);
|
||||
|
||||
if (builder.CurrentUMAContainer != null && builder.CurrentUMAContainer.UmaAnimator != null)
|
||||
{
|
||||
builder.CurrentUMAContainer.UmaAnimator.enabled = false;
|
||||
}
|
||||
|
||||
PoseModeOn = true;
|
||||
}
|
||||
|
||||
public void DisablePoseMode()
|
||||
{
|
||||
UIPoseContainer.CreateBackupFromScene();
|
||||
|
||||
var ui = UmaViewerUI.Instance;
|
||||
var builder = UmaViewerBuilder.Instance;
|
||||
ui.SetEyeTrackingEnable(true);
|
||||
ui.SetDynamicBoneEnable(true);
|
||||
HandleCanvas.SetActive(false);
|
||||
|
||||
if (builder.CurrentUMAContainer != null && builder.CurrentUMAContainer.UmaAnimator != null)
|
||||
{
|
||||
builder.CurrentUMAContainer.UmaAnimator.enabled = true;
|
||||
}
|
||||
|
||||
PoseModeOn = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user