Pose mode preparation.

Pose serialization, deserialization (no face)
UI handle system
This commit is contained in:
Katboi01
2023-12-14 01:42:30 +01:00
parent 28549bd653
commit f928a802d7
102 changed files with 8678 additions and 45 deletions
@@ -0,0 +1,113 @@
using System;
using CommandUndoRedo;
using UnityEngine;
using System.Collections.Generic;
namespace RuntimeGizmos
{
public abstract class SelectCommand : ICommand
{
protected Transform target;
protected TransformGizmo transformGizmo;
public SelectCommand(TransformGizmo transformGizmo, Transform target)
{
this.transformGizmo = transformGizmo;
this.target = target;
}
public abstract void Execute();
public abstract void UnExecute();
}
public class AddTargetCommand : SelectCommand
{
List<Transform> targetRoots = new List<Transform>();
public AddTargetCommand(TransformGizmo transformGizmo, Transform target, List<Transform> targetRoots) : base(transformGizmo, target)
{
//Since we might have had a child selected and then selected the parent, the child would have been removed from the selected,
//so we store all the targetRoots before we add so that if we undo we can properly have the children selected again.
this.targetRoots.AddRange(targetRoots);
}
public override void Execute()
{
transformGizmo.AddTarget(target, false);
}
public override void UnExecute()
{
transformGizmo.RemoveTarget(target, false);
for(int i = 0; i < targetRoots.Count; i++)
{
transformGizmo.AddTarget(targetRoots[i], false);
}
}
}
public class RemoveTargetCommand : SelectCommand
{
public RemoveTargetCommand(TransformGizmo transformGizmo, Transform target) : base(transformGizmo, target) {}
public override void Execute()
{
transformGizmo.RemoveTarget(target, false);
}
public override void UnExecute()
{
transformGizmo.AddTarget(target, false);
}
}
public class ClearTargetsCommand : SelectCommand
{
List<Transform> targetRoots = new List<Transform>();
public ClearTargetsCommand(TransformGizmo transformGizmo, List<Transform> targetRoots) : base(transformGizmo, null)
{
this.targetRoots.AddRange(targetRoots);
}
public override void Execute()
{
transformGizmo.ClearTargets(false);
}
public override void UnExecute()
{
for(int i = 0; i < targetRoots.Count; i++)
{
transformGizmo.AddTarget(targetRoots[i], false);
}
}
}
public class ClearAndAddTargetCommand : SelectCommand
{
List<Transform> targetRoots = new List<Transform>();
public ClearAndAddTargetCommand(TransformGizmo transformGizmo, Transform target, List<Transform> targetRoots) : base(transformGizmo, target)
{
this.targetRoots.AddRange(targetRoots);
}
public override void Execute()
{
transformGizmo.ClearTargets(false);
transformGizmo.AddTarget(target, false);
}
public override void UnExecute()
{
transformGizmo.RemoveTarget(target, false);
for(int i = 0; i < targetRoots.Count; i++)
{
transformGizmo.AddTarget(targetRoots[i], false);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0049ee060d2e7ed4d94301c1c6d74154
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,53 @@
using System;
using CommandUndoRedo;
using UnityEngine;
namespace RuntimeGizmos
{
public class TransformCommand : ICommand
{
TransformValues newValues;
TransformValues oldValues;
Transform transform;
TransformGizmo transformGizmo;
public TransformCommand(TransformGizmo transformGizmo, Transform transform)
{
this.transformGizmo = transformGizmo;
this.transform = transform;
oldValues = new TransformValues() {position=transform.position, rotation=transform.rotation, scale=transform.localScale};
}
public void StoreNewTransformValues()
{
newValues = new TransformValues() {position=transform.position, rotation=transform.rotation, scale=transform.localScale};
}
public void Execute()
{
transform.position = newValues.position;
transform.rotation = newValues.rotation;
transform.localScale = newValues.scale;
transformGizmo.SetPivotPoint();
}
public void UnExecute()
{
transform.position = oldValues.position;
transform.rotation = oldValues.rotation;
transform.localScale = oldValues.scale;
transformGizmo.SetPivotPoint();
}
struct TransformValues
{
public Vector3 position;
public Quaternion rotation;
public Vector3 scale;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d257cdf8c9d53a4459c0c1187ac05feb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: