public UserTransformableGhost CreateGhost(UserTransformableRecordable target) { GameObject ghostObject = GameObject.Instantiate(target, target.transform.parent).gameObject; ghostObject.transform.localPosition = localPosition; ghostObject.transform.localRotation = localRotation; OutputText.instance.text = OutputText.instance.text + localPosition.ToString("F3") + localRotation.ToString("F3") + "\n"; ghostObject.GetComponent <UserTransformableRecordable>().enabled = false; if (ghostObject.GetComponent <UserTransformableGhost>() == null) { ghostObject.AddComponent <UserTransformableGhost>(); } OutputText.instance.text = OutputText.instance.text + "point1\n"; UserTransformableGhost ghost = ghostObject.GetComponent <UserTransformableGhost>(); ghost.enabled = true; OutputText.instance.text = OutputText.instance.text + "point2\n"; ghost.GhostifyRenderer(); ghost.BindKeyframe(this); return(ghost); }
public void CreateSnapshot(Transform desiredTransform) { UserTransformKeyframe keyframe = recording.AddKeyframe(desiredTransform); UserTransformableGhost ghost = keyframe.CreateGhost(target); ghosts.Add(ghost); IncorporateGhost(ghosts.Count - 1); }
void IncorporateGhost(int index) { UserTransformableGhost ghost = ghosts[index]; if (index > 0) { UserTransformableGhost prevGhost = ghosts[index - 1]; prevGhost.MakePredecessorTo(ghost); ghost.MakeSuccessorTo(prevGhost); } if (index < ghosts.Count - 1) { UserTransformableGhost nextGhost = ghosts[index + 1]; ghost.MakePredecessorTo(nextGhost); nextGhost.MakeSuccessorTo(ghost); } }
public void MakeSuccessorTo(UserTransformableGhost newPredecessor) { predecessor = newPredecessor; if (predecessor == null) { if (arrow != null) { Destroy(arrow); arrow = null; } } else { if (arrow == null) { arrow = Instantiate(arrowPrefab, gameObject.transform.parent); } arrow.FromTo(newPredecessor.gameObject, gameObject); } }
public void DeleteSnapshot(GameObject objectToDelete) { UserTransformableGhost ghost = objectToDelete.GetComponent <UserTransformableGhost>(); if (ghost == null) { return; } int index = ghosts.FindIndex(delegate(UserTransformableGhost g) { return(g == ghost); }); if (index < 0) { return; } if (index > 0) { ghost.MakeSuccessorTo(null); if (index < ghosts.Count - 1) { ghosts[index - 1].MakePredecessorTo(ghosts[index + 1]); ghosts[index + 1].MakeSuccessorTo(ghosts[index - 1]); } else { ghosts[index - 1].MakePredecessorTo(null); } } else if (index < ghosts.Count - 1) { ghost.MakePredecessorTo(null); ghosts[index + 1].MakeSuccessorTo(null); } ghosts.RemoveAt(index); recording.RemoveKeyframe(index); UnityEngine.Object.Destroy(objectToDelete); }
public void MakePredecessorTo(UserTransformableGhost newSuccessor) { successor = newSuccessor; }