protected virtual void Update() { var finalTransform = Target != null ? Target : transform; // Store smoothed position var smoothPosition = finalTransform.localPosition; // Snap to target finalTransform.localPosition += remainingDelta; // Store old position var oldPosition = finalTransform.localPosition; // Update to new position UpdateTranslation(); // Shift delta by old new delta remainingDelta += finalTransform.localPosition - oldPosition; // Get t value var factor = LeanHelper.GetDampenFactor(Damping, Time.deltaTime); // Dampen remainingDelta var newDelta = Vector3.Lerp(remainingDelta, Vector3.zero, factor); // Shift this position by the change in delta finalTransform.localPosition = smoothPosition + remainingDelta - newDelta; // Update remainingDelta with the dampened value remainingDelta = newDelta; }
protected virtual void LateUpdate() { // Cache var finalTransform = FinalTransform; // Update position and delta var currentPosition = finalTransform.position; if (Position == PositionType.PreviousPosition && Vector3.Distance(previousPosition, currentPosition) > Threshold) { SetDelta(currentPosition - previousPosition); previousPosition = currentPosition; } // Update rotation var currentRotation = finalTransform.localRotation; var factor = LeanHelper.DampenFactor(Damping, Time.deltaTime); if (previousDelta.sqrMagnitude > 0.0f) { UpdateRotation(finalTransform, previousDelta); } finalTransform.localRotation = Quaternion.Slerp(currentRotation, finalTransform.localRotation, factor); }
protected virtual void Update() { // Make sure the camera exists cachedCamera = LeanHelper.GetCamera(Camera, gameObject); if (cachedCamera != null) { // Get the fingers we want to use var fingers = Use.GetFingers(); if (fingers.Count > 0) { // If it's the first frame the fingers are down, grab the current screen point of this GameObject if (targetSet == false) { targetSet = true; targetScreenPoint = cachedCamera.WorldToScreenPoint(transform.position); } // Shift target point based on finger deltas // NOTE: targetScreenPoint.z already stores the depth targetScreenPoint += (Vector3)LeanGesture.GetScreenDelta(fingers); } // Unset if no fingers are down else { targetSet = false; } } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component.", this); } }
protected virtual void LateUpdate() { if (disableWith != null && disableWith.Dragging == true) { return; } var anchoredPosition = cachedRectTransform.anchoredPosition; var rect = cachedRectTransform.rect; var parentSize = ParentSize; var intervalX = horizontalIntervalPixel + horizontalIntervalRect * rect.width + horizontalIntervalParent * parentSize.x; var intervalY = verticalIntervalPixel + verticalIntervalRect * rect.width + verticalIntervalParent * parentSize.y; if (horizontal == true && intervalX != 0.0f) { var target = Mathf.Round((anchoredPosition.x - horizontalOffset) / intervalX) * intervalX + horizontalOffset; var factor = LeanHelper.DampenFactor(horizontalSpeed, Time.deltaTime); anchoredPosition.x = Mathf.Lerp(anchoredPosition.x, target, factor); } if (vertical == true && intervalY != 0.0f) { var target = Mathf.Round((anchoredPosition.y - verticalOffset) / intervalY) * intervalY + verticalOffset; var factor = LeanHelper.DampenFactor(verticalSpeed, Time.deltaTime); anchoredPosition.y = Mathf.Lerp(anchoredPosition.y, target, factor); } cachedRectTransform.anchoredPosition = anchoredPosition; }
public void UpdateSwap() { var prefab = GetPrefab(); if (clone != null) { if (clonePrefab == prefab) { return; } LeanHelper.Destroy(clone.gameObject); clone = null; clonePrefab = null; } if (Prefabs != null && Prefabs.Count > 0) { clone = Instantiate(prefab); clone.transform.SetParent(transform, false); clonePrefab = prefab; } }
protected virtual void Translate(float twistDegrees, Vector2 twistScreenCenter) { // Make sure the camera exists var camera = LeanHelper.GetCamera(Camera, gameObject); if (camera != null) { // Screen position of the transform var screenPoint = camera.WorldToScreenPoint(transform.position); // Twist screen point around the twistScreenCenter by twistDegrees var twistRotation = Quaternion.Euler(0.0f, 0.0f, twistDegrees); var screenDelta = twistRotation * ((Vector2)screenPoint - twistScreenCenter); screenPoint.x = twistScreenCenter.x + screenDelta.x; screenPoint.y = twistScreenCenter.y + screenDelta.y; // Convert back to world space transform.position = camera.ScreenToWorldPoint(screenPoint); } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component.", this); } }
protected virtual void LateUpdate() { var currentPosition = transform.position; var newVector = (Vector2)(currentPosition - previousPosition); if (newVector.sqrMagnitude > 0.0f) { vector = newVector; } var currentRotation = transform.localRotation; var factor = LeanHelper.DampenFactor(Damping, Time.deltaTime); if (vector.sqrMagnitude > 0.0f) { var angle = Mathf.Atan2(vector.x, vector.y) * Mathf.Rad2Deg; var directionB = (Vector2)transform.up; var angleB = Mathf.Atan2(directionB.x, directionB.y) * Mathf.Rad2Deg; var delta = Mathf.DeltaAngle(angle, angleB); var angularVelocity = delta / Time.fixedDeltaTime; angularVelocity *= LeanTouch.GetDampenFactor(Damping, Time.fixedDeltaTime); cachedRigidbody2D.angularVelocity = angularVelocity; } transform.localRotation = Quaternion.Slerp(currentRotation, transform.localRotation, factor); previousPosition = currentPosition; }
protected virtual void LateUpdate() { if (disableWith != null && disableWith.Dragging == true) { return; } var anchoredPosition = cachedRectTransform.anchoredPosition; var rect = cachedRectTransform.rect; if (horizontal == true && horizontalInterval != 0.0f) { var target = Mathf.Round((anchoredPosition.x - horizontalOffset) / horizontalInterval) * horizontalInterval + horizontalOffset; var factor = LeanHelper.DampenFactor(horizontalSpeed, Time.deltaTime); anchoredPosition.x = Mathf.Lerp(anchoredPosition.x, target, factor); } if (vertical == true && verticalInterval != 0.0f) { var target = Mathf.Round((anchoredPosition.y - verticalOffset) / verticalInterval) * verticalInterval + verticalOffset; var factor = LeanHelper.DampenFactor(verticalSpeed, Time.deltaTime); anchoredPosition.y = Mathf.Lerp(anchoredPosition.y, target, factor); } cachedRectTransform.anchoredPosition = anchoredPosition; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var player = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(property.serializedObject.targetObject, property); var sObject = property.serializedObject; var sEntries = property.FindPropertyRelative("entries"); DrawPlay(position, sObject); color = GUI.color; position.height = height; title = label.text; tooltip = label.tooltip; for (var i = 0; i < sEntries.arraySize; i++) { var entry = player.Entries[i]; var sEntry = sEntries.GetArrayElementAtIndex(i); var sRoot = sEntry.FindPropertyRelative("root"); var sSpeed = sEntry.FindPropertyRelative("speed"); var sAliases = sEntry.FindPropertyRelative("aliases"); var rectL = position; rectL.width = EditorGUIUtility.labelWidth - 16.0f; var rectR = position; rectR.xMin += EditorGUIUtility.labelWidth; if (Event.current.isMouse == true && Event.current.button == 1 && rectL.Contains(Event.current.mousePosition) == true) { Event.current.Use(); ShowMenu(sObject, sEntries, i, sRoot, sSpeed, title); } EditorGUI.PropertyField(position, sRoot, new GUIContent(title, tooltip)); position.y += heightStep; EditorGUI.indentLevel++; if (sSpeed.floatValue >= 0.0f) { EditorGUI.PropertyField(position, sSpeed); position.y += heightStep; } for (var j = 0; j < sAliases.arraySize; j++) { var alias = entry.Aliases[j]; var sAlias = sAliases.GetArrayElementAtIndex(j); var sKey = sAlias.FindPropertyRelative("Key"); var sObj = sAlias.FindPropertyRelative("Obj"); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = sObj.hasMultipleDifferentValues; var obj = EditorGUI.ObjectField(position, new GUIContent(sKey.stringValue, ""), alias.Obj, alias.Type, true); position.y += heightStep; EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck() == true) { sObj.objectReferenceValue = obj; } } EditorGUI.indentLevel--; } GUI.color = color; }
protected virtual void Update() { // Is this selected and has a selecting finger? if (Selectable != null && Selectable.IsSelected == true) { var finger = Selectable.SelectingFinger; if (finger != null) { // Camera exists? var camera = LeanHelper.GetCamera(null); if (camera != null) { // Find the screen point of the finger using the depth of this block var screenPoint = new Vector3(finger.ScreenPosition.x, finger.ScreenPosition.y, camera.WorldToScreenPoint(transform.position).z); // Find the world space point under the finger var worldPoint = camera.ScreenToWorldPoint(screenPoint); // Find the block coordinate at this point var dragX = Mathf.RoundToInt(worldPoint.x / BlockSize); var dragY = Mathf.RoundToInt(worldPoint.y / BlockSize); // Is this block right next to this one? var distX = Mathf.Abs(X - dragX); var distY = Mathf.Abs(Y - dragY); if (distX + distY == 1) { // Swap blocks if one exists at this coordinate var block = FindBlock(dragX, dragY); if (block != null) { Swap(this, block); if (DeselectOnSwap == true) { Selectable.Deselect(); } } } } } } // Smoothly move to new position var targetPosition = Vector3.zero; var factor = LeanHelper.GetDampenFactor(Damping, Time.deltaTime); targetPosition.x = X * BlockSize; targetPosition.y = Y * BlockSize; transform.localPosition = Vector3.Lerp(transform.localPosition, targetPosition, factor); }
protected virtual void Update() { var factor = LeanHelper.DampenFactor(dampening, Time.deltaTime); var position = default(Vector3); var rotation = default(Vector3); strength = Mathf.Lerp(strength, 0.0f, factor); strength = Mathf.MoveTowards(strength, 0.0f, reduction * Time.deltaTime); position.x = Sample(ref offsetPosition.x, 29.0f) * shakePosition.x; position.y = Sample(ref offsetPosition.y, 31.0f) * shakePosition.y; position.z = Sample(ref offsetPosition.z, 37.0f) * shakePosition.z; rotation.x = Sample(ref offsetRotation.x, 41.0f) * shakeRotation.x; rotation.y = Sample(ref offsetRotation.y, 43.0f) * shakeRotation.y; rotation.z = Sample(ref offsetRotation.z, 47.9f) * shakeRotation.z; var finalTransform = transform; var finalRectTransform = transform as RectTransform; // Rotation var currentRotation = finalTransform.localRotation; if (currentRotation != expectedRotation) { localRotation = currentRotation; } finalTransform.localRotation = expectedRotation = localRotation * Quaternion.Euler(rotation * strength * multiplier); // Position if (finalRectTransform != null) { var currentPosition = finalRectTransform.anchoredPosition3D; if (currentPosition != expectedPosition) { localPosition = currentPosition; } finalRectTransform.anchoredPosition3D = expectedPosition = localPosition + position * strength * multiplier; } else { var currentPosition = finalTransform.localPosition; if (currentPosition != expectedPosition) { localPosition = currentPosition; } finalTransform.localPosition = expectedPosition = localPosition + position * strength * multiplier; } }
private void DrawAliases(Rect position, SerializedObject sObject, SerializedProperty property) { var sAliases = property.FindPropertyRelative("aliases"); var sTargets = property.FindPropertyRelative("targets"); var aliasCount = System.Math.Min(sAliases.arraySize, sTargets.arraySize); var aliasTypes = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(sObject.targetObject, property).Types; for (var i = 0; i < aliasCount; i++) { DrawAliasTarget(position, sAliases.GetArrayElementAtIndex(i), sTargets.GetArrayElementAtIndex(i), aliasTypes[i]); position.y += height; } }
public void ContinuouslyZoom(float direction) { var factor = LeanHelper.GetDampenFactor(Mathf.Abs(direction), Time.deltaTime); if (direction > 0.0f) { zoom = Mathf.Lerp(zoom, ClampMax, factor); } else if (direction <= 0.0f) { zoom = Mathf.Lerp(zoom, ClampMin, factor); } }
/// <summary>This returns a smooth point between the previous and current screen position based on a 0..1 progress value.</summary> public Vector2 GetSmoothScreenPosition(float t) { if (Snapshots.Count > 0 && Set == true) { var d = Snapshots[Mathf.Max(0, Snapshots.Count - 4)].ScreenPosition; var c = Snapshots[Mathf.Max(0, Snapshots.Count - 3)].ScreenPosition; var b = Snapshots[Mathf.Max(0, Snapshots.Count - 2)].ScreenPosition; var a = Snapshots[Mathf.Max(0, Snapshots.Count - 1)].ScreenPosition; return(LeanHelper.Hermite(d, c, b, a, t)); } return(Vector2.LerpUnclamped(LastScreenPosition, ScreenPosition, t)); }
private void UpdateTranslation() { var finalTransform = Target != null ? Target : transform; // Get the fingers we want to use var fingers = Use.GetFingers(); // Calculate the screenDelta value based on these fingers var screenDelta = LeanGesture.GetScreenDelta(fingers); // Make sure the camera exists var camera = LeanHelper.GetCamera(ScreenDepth.Camera, gameObject); if (fingers.Count == 0) { deltaDifference = Vector2.zero; } if (camera != null) { var worldPosition = finalTransform.position; var oldScreenPoint = camera.WorldToScreenPoint(worldPosition); if (TrackScreenPosition == true) { if (ScreenDepth.TryConvert(ref worldPosition, oldScreenPoint + (Vector3)(screenDelta + deltaDifference), gameObject) == true) { finalTransform.position = worldPosition; } var newScreenPoint = camera.WorldToScreenPoint(worldPosition); var oldNewDelta = (Vector2)(newScreenPoint - oldScreenPoint); deltaDifference += screenDelta - oldNewDelta; } else { if (ScreenDepth.TryConvert(ref worldPosition, oldScreenPoint + (Vector3)screenDelta, gameObject) == true) { finalTransform.position = worldPosition; } } } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component.", this); } }
protected virtual void Update() { // Get the fingers we want to use var fingers = Use.GetFingers(); // Calculate the rotation values based on these fingers var twistDegrees = -LeanGesture.GetTwistDegrees(fingers); // Store var oldPosition = transform.localPosition; var oldRotation = transform.localRotation; // Rotate if (Relative == true) { var screenPoint = default(Vector2); if (LeanGesture.TryGetScreenCenter(fingers, ref screenPoint) == true) { var worldPoint = ScreenDepth.Convert(screenPoint); transform.RotateAround(worldPoint, transform.forward, twistDegrees); } } else { transform.Rotate(transform.forward, twistDegrees); } // Increment remainingTranslation += transform.localPosition - oldPosition; remainingRotation *= Quaternion.Inverse(oldRotation) * transform.localRotation; // Get t value var factor = LeanHelper.GetDampenFactor(Damping, Time.deltaTime); // Dampen remainingDelta var newRemainingTranslation = Vector3.Lerp(remainingTranslation, Vector3.zero, factor); var newRemainingRotation = Quaternion.Slerp(remainingRotation, Quaternion.identity, factor); // Shift this transform by the change in delta transform.localPosition = oldPosition + remainingTranslation - newRemainingTranslation; transform.localRotation = oldRotation * Quaternion.Inverse(newRemainingRotation) * remainingRotation; // Update remainingDelta with the dampened value remainingTranslation = newRemainingTranslation; remainingRotation = newRemainingRotation; }
/// <summary>This will return the ray of the finger's start position relative to the specified camera (none/null = Main Camera).</summary> public Ray GetStartRay(Camera camera = null) { // Make sure the camera exists camera = LeanHelper.GetCamera(camera); if (camera != null) { return(camera.ScreenPointToRay(StartScreenPosition)); } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component."); } return(default(Ray)); }
protected virtual void Rotate(float twistDegrees) { // Make sure the camera exists var camera = LeanHelper.GetCamera(Camera, gameObject); if (camera != null) { var axis = transform.InverseTransformDirection(camera.transform.forward); transform.rotation *= Quaternion.AngleAxis(twistDegrees, axis); } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component.", this); } }
/// <summary>This will return the change in world position of this finger based on the last and current distance from the camera.</summary> public Vector3 GetWorldDelta(float lastDistance, float distance, Camera camera = null) { // Make sure the camera exists camera = LeanHelper.GetCamera(camera); if (camera != null) { return(GetWorldPosition(distance, camera) - GetLastWorldPosition(lastDistance, camera)); } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component."); } return(default(Vector3)); }
protected virtual void FixedUpdate() { // Make sure the camera exists and the targetScreenPoint is set if (cachedCamera != null && targetSet == true) { // Calculate required velocity to arrive in one FixedUpdate var oldPosition = transform.position; var newPosition = cachedCamera.ScreenToWorldPoint(targetScreenPoint); var velocity = (newPosition - oldPosition) / Time.fixedDeltaTime; var factor = LeanHelper.GetDampenFactor(Damping, Time.fixedDeltaTime); // Apply the velocity cachedRigidbody.velocity = velocity * factor; } }
private void ValidateAndUpdate(SerializedObject sObject, SerializedProperty sPlayer) { sObject.ApplyModifiedProperties(); foreach (var targetObject in sObject.targetObjects) { var player = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(targetObject, sPlayer); if (player != null) { player.Validate(true); } } sObject.Update(); }
protected virtual void Update() { // Store var oldScale = transform.localPosition; // Get the fingers we want to use var fingers = Use.UpdateAndGetFingers(); // Calculate pinch scale, and make sure it's valid var pinchScale = LeanGesture.GetPinchScale(fingers); if (pinchScale != 1.0f) { pinchScale = Mathf.Pow(pinchScale, sensitivity); // Perform the translation if this is a relative scale if (relative == true) { var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers); if (transform is RectTransform) { TranslateUI(pinchScale, pinchScreenCenter); } else { Translate(pinchScale, pinchScreenCenter); } } transform.localScale *= pinchScale; remainingScale += transform.localPosition - oldScale; } // Get t value var factor = LeanHelper.GetDampenFactor(damping, Time.deltaTime); // Dampen remainingDelta var newRemainingScale = Vector3.Lerp(remainingScale, Vector3.zero, factor); // Shift this transform by the change in delta transform.localPosition = oldScale + remainingScale - newRemainingScale; // Update remainingDelta with the dampened value remainingScale = newRemainingScale; }
protected virtual void Update() { counter += Time.deltaTime; if (counter >= PulseInterval) { counter %= PulseInterval; Size += PulseSize; } var factor = LeanHelper.GetDampenFactor(Damping, Time.deltaTime); Size = Mathf.Lerp(Size, 1.0f, factor); transform.localScale = Vector3.Lerp(transform.localScale, BaseScale * Size, factor); }
/// <summary>This will return the world position of this finger based on the distance from the camera.</summary> public Vector3 GetWorldPosition(float distance, Camera camera = null) { // Make sure the camera exists camera = LeanHelper.GetCamera(camera); if (camera != null) { var point = new Vector3(ScreenPosition.x, ScreenPosition.y, distance); return(camera.ScreenToWorldPoint(point)); } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component."); } return(default(Vector3)); }
protected virtual void Update() { // Store var oldPosition = transform.localPosition; // Get the fingers we want to use var fingers = Use.UpdateAndGetFingers(); // Calculate the screenDelta value based on these fingers var screenDelta = LeanGesture.GetScreenDelta(fingers); if (screenDelta != Vector2.zero) { // Perform the translation if (transform is RectTransform) { TranslateUI(screenDelta); } else { Translate(screenDelta); } } // Increment remainingTranslation += transform.localPosition - oldPosition; // Get t value var factor = LeanHelper.GetDampenFactor(Damping, Time.deltaTime); // Dampen remainingDelta var newRemainingTranslation = Vector3.Lerp(remainingTranslation, Vector3.zero, factor); // Shift this transform by the change in delta transform.localPosition = oldPosition + remainingTranslation - newRemainingTranslation; if (fingers.Count == 0 && Inertia > 0.0f && Damping > 0.0f) { newRemainingTranslation = Vector3.Lerp(newRemainingTranslation, remainingTranslation, Inertia); } // Update remainingDelta with the dampened value remainingTranslation = newRemainingTranslation; }
private void MagnetPosition(ref Vector2 anchoredPosition) { #if UNITY_EDITOR if (Application.isPlaying == false) { return; } #endif if (dragging == false) { if (horizontal == true && horizontalClamp == true && horizontalMagnet >= 0.0f) { var factor = LeanHelper.DampenFactor(horizontalMagnet, Time.deltaTime); var middle = (horizontalMin + horizontalMax) * 0.5f; var targetPos = horizontalMin; if (anchoredPosition.x > middle) { targetPos = horizontalMax; } anchoredPosition.x = Mathf.Lerp(anchoredPosition.x, targetPos, factor); target.anchoredPosition = anchoredPosition; } if (vertical == true && verticalClamp == true && verticalMagnet >= 0.0f) { var factor = LeanHelper.DampenFactor(verticalMagnet, Time.deltaTime); var middle = (verticalMin + verticalMax) * 0.5f; var targetPos = verticalMin; if (anchoredPosition.y > middle) { targetPos = verticalMax; } anchoredPosition.y = Mathf.Lerp(anchoredPosition.y, targetPos, factor); target.anchoredPosition = anchoredPosition; } } }
private void Validate(SerializedProperty property) { property.serializedObject.ApplyModifiedProperties(); var sRoots = property.FindPropertyRelative("roots"); if (sRoots.arraySize == 0) { sRoots.arraySize = 1; sRoots.serializedObject.ApplyModifiedProperties(); } foreach (var targetObject in property.serializedObject.targetObjects) { var transitions = LeanHelper.GetObjectFromSerializedProperty <LeanPlayer>(targetObject, property); transitions.Rebuild(); } property.serializedObject.Update(); }
protected void SetZoom(float current) { // Make sure the camera exists var camera = LeanHelper.GetCamera(Camera, gameObject); if (camera != null) { if (camera.orthographic == true) { camera.orthographicSize = current; } else { camera.fieldOfView = current; } } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component.", this); } }
private void Translate(Vector2 screenDelta) { // Make sure the camera exists var camera = LeanHelper.GetCamera(this._camera, gameObject); if (camera != null) { // Screen position of the transform var screenPoint = camera.WorldToScreenPoint(transform.position); // Add the deltaPosition screenPoint += (Vector3)screenDelta * Sensitivity; // Convert back to world space transform.position = camera.ScreenToWorldPoint(screenPoint); } else { Debug.LogError("Failed to find camera. Either tag your camera as MainCamera, or set one in this component.", this); } }
protected virtual void Update() { // Is this GameObject selected? if (Selectable != null && Selectable.IsSelected == true) { // Does it have a selected finger? var finger = Selectable.SelectingFinger; if (finger != null) { // Make sure the camera exists var camera = LeanHelper.GetCamera(Camera, gameObject); if (camera != null) { var newScaledDelta = finger.ScaledDelta; if (oldScaledDelta != Vector2.zero && newScaledDelta != Vector2.zero) { var angleA = Mathf.Atan2(oldScaledDelta.y, oldScaledDelta.x) * Mathf.Rad2Deg; var angleB = Mathf.Atan2(newScaledDelta.y, newScaledDelta.x) * Mathf.Rad2Deg; var torque = Mathf.DeltaAngle(angleA, angleB) * (oldScaledDelta.magnitude + newScaledDelta.magnitude); if (cachedRigidbody == null) { cachedRigidbody = GetComponent <Rigidbody>(); } cachedRigidbody.AddTorque(camera.transform.forward * torque * Force, ForceMode.Acceleration); } oldScaledDelta = newScaledDelta; } else { Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component.", this); } } } }