private void LaunchAlphaProperty(EMMotionProperties properties, bool useCurrentState, bool reverse) { float start = startTransform.alpha; float end = properties.transform.alpha; float delay = 0; if (reverse) { start = end; end = startTransform.alpha; } if (useCurrentState) { start = cachedCanvasGroup.alpha; } else { delay = properties.alphaEasing.delay; } EMEasing.ValueTo(gameObject, motionId, properties.alphaEasing.easeType, start, end, properties.alphaEasing.time, delay, "On_StartMotion", "On_AlphaUI", "On_EndMotion"); cachedCanvasGroup.alpha = start; }
private void LaunchScaleProperty(EMMotionProperties properties, bool useCurrentState, bool reverse) { Vector3 start = startTransform.scale; Vector3 end = properties.transform.scale; float delay = 0; if (reverse) { start = end; end = startTransform.scale; } if (useCurrentState) { start = cachedTransform.localScale; } else { delay = properties.scaleEasing.delay; } EMEasing.ValueTo(gameObject, motionId, properties.scaleEasing.easeType, start, end, properties.scaleEasing.time, delay, "On_StartMotion", "On_ScaleUI", "On_EndMotion"); cachedTransform.localScale = start; }
private void LaunchRotateProperty(EMMotionProperties properties, bool useCurrentState, bool reverse) { Vector3 start = startTransform.rotation; Vector3 end = properties.transform.rotation; float delay = 0; if (reverse) { start = end; end = startTransform.rotation; } if (useCurrentState) { start = cachedTransform.localRotation.eulerAngles; } else { delay = properties.rotateEasing.delay; } EMEasing.ValueTo(gameObject, motionId, properties.rotateEasing.easeType, start, end, properties.rotateEasing.time, delay, "On_StartMotion", "On_RotateUI", "On_EndMotion"); cachedTransform.localRotation = Quaternion.Euler(start); }
private void LaunchMoveProperty(EMMotionProperties properties, bool useCurrentState, bool reverse) { EMTransform transform = GetTransformFromProperties(properties, useCurrentState); Vector3 start = Vector3.zero; Vector3 end = Vector3.zero; float delay = 0; if (!useCurrentState) { delay = properties.moveEasing.delay; } if (reverse) { start = transform.position; end = startTransform.position; if (useCurrentState) { start = cachedTransform.anchoredPosition; } if (properties.moveDirection == EMMotionProperties.MotionDirection.UserDefined && !useCurrentState) { start = GetPosition2NewAnchor(start, transform.anchorMin, startTransform.anchorMin); cachedTransform.anchorMin = startTransform.anchorMin; cachedTransform.anchorMax = startTransform.anchorMax; } else if (useCurrentState) { start = GetPosition2NewAnchor(start, cachedTransform.anchorMin, startTransform.anchorMin); cachedTransform.anchorMin = startTransform.anchorMin; cachedTransform.anchorMax = startTransform.anchorMax; } } else { start = startTransform.position; end = transform.position; if (useCurrentState) { start = cachedTransform.anchoredPosition; } if (cachedTransform.anchorMin != properties.transform.anchorMin && properties.moveDirection == EMMotionProperties.MotionDirection.UserDefined) { start = GetPosition2NewAnchor(start, cachedTransform.anchorMin, properties.transform.anchorMin); cachedTransform.anchorMin = properties.transform.anchorMin; cachedTransform.anchorMax = properties.transform.anchorMax; } } EMEasing.ValueTo(gameObject, motionId, properties.moveEasing.easeType, start, end, properties.moveEasing.time, delay, "On_StartMotion", "On_MoveUI", "On_EndMotion"); cachedTransform.anchoredPosition = start; }
protected void StopMotion() { EMEasing.StopTween(gameObject); currentPropertiesCounter = propertiesCounter; }
public static string ValueTo(GameObject obj, string id, EaseType easeType, object startValue, object endValue, float duration, float delaytToStart = 0, string startCallBack = "", string updateCallBack = "", string endCallBack = "") { EMEasing ee = obj.AddComponent <EMEasing>(); ee.hideFlags = HideFlags.HideInInspector; ee.target = obj; ee.easeType = easeType; ee.delayToStart = delaytToStart; ee.duration = duration; ee.isStart = false; ee.startCallBack = startCallBack; ee.updateCallBack = updateCallBack; ee.endCallBack = endCallBack; ee.id = System.Guid.NewGuid().ToString(); ee.motionId = id; if (startValue.GetType() == typeof(float)) { ee.variableType = VariableType.Float; ee.startValue1 = (float)startValue; ee.endValue1 = (float)endValue; } else if (startValue.GetType() == typeof(Vector2)) { ee.variableType = VariableType.V2; ee.startValue1 = ((Vector2)startValue).x; ee.startValue2 = ((Vector2)startValue).y; ee.endValue1 = ((Vector2)endValue).x; ee.endValue2 = ((Vector2)endValue).y; } else if (startValue.GetType() == typeof(Vector3)) { ee.variableType = VariableType.V3; ee.startValue1 = ((Vector3)startValue).x; ee.startValue2 = ((Vector3)startValue).y; ee.startValue3 = ((Vector3)startValue).z; ee.endValue1 = ((Vector3)endValue).x; ee.endValue2 = ((Vector3)endValue).y; ee.endValue3 = ((Vector3)endValue).z; } else if (startValue.GetType() == typeof(Color)) { ee.variableType = VariableType.Color; ee.startValue1 = ((Color)startValue).r; ee.startValue2 = ((Color)startValue).g; ee.startValue3 = ((Color)startValue).b; ee.startValue4 = ((Color)startValue).a; ee.endValue1 = ((Color)endValue).r; ee.endValue2 = ((Color)endValue).g; ee.endValue3 = ((Color)endValue).b; ee.endValue4 = ((Color)endValue).a; } tweens.Add(ee); if (delaytToStart > 0) { ee.StartEase(); } else { ee.isStart = true; ee.startTime = Time.realtimeSinceStartup; if (!string.IsNullOrEmpty(startCallBack)) { ee.target.SendMessage(startCallBack, ee.motionId, SendMessageOptions.DontRequireReceiver); } } return(ee.id); }