public void ExitRecordMode(GameObject gObject, AnimationShowOrHide showOrHide) { rectTransform = gObject.GetComponent <RectTransform>(); graphic = gObject.GetComponent <Graphic>(); ReturnValuesAfterRecord(gObject, showOrHide); }
public void Record(GameObject gObject, AnimationShowOrHide showOrHide) { rectTransform = gObject.GetComponent <RectTransform>(); graphic = gObject.GetComponent <Graphic>(); RecordValues(showOrHide, false); }
private void ReturnValuesAfterRecord(GameObject gObject, AnimationShowOrHide showOrHide) { ComponentsToAnimate componentsToAnimate = (showOrHide == AnimationShowOrHide.Show) ? componentsToAnimate_SHOW : componentsToAnimate_HIDE; switch (componentsToAnimate) { case (ComponentsToAnimate.Transform): rectTransform.anchoredPosition = transformRecord_beforeRecrod.Position; rectTransform.localScale = transformRecord_beforeRecrod.Scale; rectTransform.pivot = transformRecord_beforeRecrod.Pivot; rectTransform.anchorMin = transformRecord_beforeRecrod.AnchorMin; rectTransform.anchorMax = transformRecord_beforeRecrod.AnchorMax; rectTransform.rotation = Quaternion.Euler(transformRecord_beforeRecrod.RotationEuler); break; case (ComponentsToAnimate.Graphic): graphic.color = graphicRecord_beforeRecrod.Color; if (graphic is Image) { gObject.GetComponent <Image>().sprite = graphicRecord_beforeRecrod.Sprite; } else if (graphic is Text) { gObject.GetComponent <Text>().text = graphicRecord_beforeRecrod.Text; } break; case (ComponentsToAnimate.Both): rectTransform.anchoredPosition = transformAndGraphicRecord_beforeRecrod.Position; rectTransform.localScale = transformAndGraphicRecord_beforeRecrod.Scale; rectTransform.pivot = transformAndGraphicRecord_beforeRecrod.Pivot; rectTransform.anchorMin = transformAndGraphicRecord_beforeRecrod.AnchorMin; rectTransform.anchorMax = transformAndGraphicRecord_beforeRecrod.AnchorMax; rectTransform.rotation = Quaternion.Euler(transformAndGraphicRecord_beforeRecrod.RotationEuler); graphic.color = transformAndGraphicRecord_beforeRecrod.Color; if (graphic is Image) { gObject.GetComponent <Image>().sprite = transformAndGraphicRecord_beforeRecrod.Sprite; } else if (graphic is Text) { gObject.GetComponent <Text>().text = transformAndGraphicRecord_beforeRecrod.Text; } break; } transformRecord_beforeRecrod = null; graphicRecord_beforeRecrod = null; transformAndGraphicRecord_beforeRecrod = null; }
public void EnterRecordMode(GameObject gObject, AnimationShowOrHide showOrHide) { rectTransform = gObject.GetComponent <RectTransform>(); graphic = gObject.GetComponent <Graphic>(); transformRecord_beforeRecrod = null; graphicRecord_beforeRecrod = null; transformAndGraphicRecord_beforeRecrod = null; RecordValues(showOrHide, true); }
private void RecordValues(AnimationShowOrHide showOrHide, bool recordModeActive) { ComponentsToAnimate componentsToAnimate = (showOrHide == AnimationShowOrHide.Show) ? componentsToAnimate_SHOW : componentsToAnimate_HIDE; switch (componentsToAnimate) { case (ComponentsToAnimate.Transform): TransformAnimationRecord transformRecord = new TransformAnimationRecord() { Duration = currentRecordDuration, Delay = currentRecordDelay, //Position = rectTransform.position, Position = rectTransform.anchoredPosition, Scale = rectTransform.localScale, RotationEuler = rectTransform.eulerAngles, Pivot = rectTransform.pivot, AnchorMin = rectTransform.anchorMin, AnchorMax = rectTransform.anchorMax, }; if (recordModeActive) { transformRecord_beforeRecrod = transformRecord; return; } if (showOrHide == AnimationShowOrHide.Show) { TransformAnimationRecords_SHOW.Add(transformRecord); } else { TransformAnimationRecords_HIDE.Add(transformRecord); } break; case (ComponentsToAnimate.Graphic): if (graphic is Image) { img = graphic as Image; graphicType = GraphicType.Image; } else if (graphic is Text) { txt = graphic as Text; graphicType = GraphicType.Text; } GraphicAnimationRecord graphicRecord = new GraphicAnimationRecord() { Duration = currentRecordDuration, Delay = currentRecordDelay, Color = graphic.color, Sprite = (graphicType == GraphicType.Image) ? img.sprite : null, Text = (graphicType == GraphicType.Text) ? txt.text : "" }; if (recordModeActive) { graphicRecord_beforeRecrod = graphicRecord; return; } if (showOrHide == AnimationShowOrHide.Show) { GraphicAnimationRecords_SHOW.Add(graphicRecord); } else { GraphicAnimationRecords_HIDE.Add(graphicRecord); } break; case (ComponentsToAnimate.Both): if (graphic is Image) { img = graphic as Image; graphicType = GraphicType.Image; } else if (graphic is Text) { txt = graphic as Text; graphicType = GraphicType.Text; } TransformAndGraphicAnimationRecord transformAndGrapihcRecord = new TransformAndGraphicAnimationRecord() { Duration = currentRecordDuration, Delay = currentRecordDelay, //Position = rectTransform.position, Position = rectTransform.anchoredPosition, Scale = rectTransform.localScale, RotationEuler = rectTransform.eulerAngles, Pivot = rectTransform.pivot, AnchorMin = rectTransform.anchorMin, AnchorMax = rectTransform.anchorMax, Color = graphic.color, Sprite = (graphicType == GraphicType.Image) ? img.sprite : null, Text = (graphicType == GraphicType.Text) ? txt.text : "" }; if (recordModeActive) { transformAndGraphicRecord_beforeRecrod = transformAndGrapihcRecord; return; } if (showOrHide == AnimationShowOrHide.Show) { TransformAndGraphicAnimationRecords_SHOW.Add(transformAndGrapihcRecord); } else { TransformAndGraphicAnimationRecords_HIDE.Add(transformAndGrapihcRecord); } break; } }