Initial files

This commit is contained in:
2024-04-21 16:38:26 +02:00
parent c69c668ae6
commit cf04700131
554 changed files with 131197 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using RuntimeGizmos;
using UnityEngine;
public class HandleTransformCommand : TransformCommand
{
protected UIHandle _handle;
protected int _frame;
public HandleTransformCommand(TransformGizmo transformGizmo, Transform transform) : base(transformGizmo, transform.GetComponent<UIHandle>().Target)
{
_frame = TimelineController.Instance.CurrentFrame;
_handle = transform.GetComponent<UIHandle>();
}
public HandleTransformCommand(TransformGizmo transformGizmo, HandleUndoData data) : base(transformGizmo, data.NewPosition)
{
_frame = TimelineController.Instance.CurrentFrame;
_handle = data.Handle;
oldValues = new TransformValues() { position = data.OldPosition.Position, rotation = Quaternion.Euler(data.OldPosition.Rotation), scale = data.OldPosition.Scale };
newValues = new TransformValues() { position = transform.position, rotation = transform.rotation, scale = transform.localScale };
}
public override void Execute()
{
TimelineController.SetCurrentFrame(_frame);
base.Execute();
_handle.Owner.SetKeyframe();
}
public override void UnExecute()
{
TimelineController.SetCurrentFrame(_frame);
base.UnExecute();
_handle.Owner.SetKeyframe();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b6522c7e3fe81b46a7a6678202ebdc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c7e15ab509fd7e468b6efb165919591
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using System;
using CommandUndoRedo;
using UnityEngine;
namespace RuntimeGizmos
{
public class TransformCommand : ICommand
{
protected TransformValues newValues;
protected TransformValues oldValues;
protected Transform transform;
protected 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 virtual void StoreNewTransformValues()
{
newValues = new TransformValues() {position=transform.position, rotation=transform.rotation, scale=transform.localScale};
}
public virtual void Execute()
{
transform.position = newValues.position;
transform.rotation = newValues.rotation;
transform.localScale = newValues.scale;
transformGizmo.SetPivotPoint();
}
public virtual void UnExecute()
{
transform.position = oldValues.position;
transform.rotation = oldValues.rotation;
transform.localScale = oldValues.scale;
transformGizmo.SetPivotPoint();
}
protected struct TransformValues
{
public Vector3 position;
public Quaternion rotation;
public Vector3 scale;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a8e7983a7bcbf194e9a14d9a1df46550
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: