Esempio n. 1
0
 public Crop(DecimalListParameter parameter) : this(
         new Vector2(
             parameter?.ElementAtOrDefault(0) ?? 0.0f,
             parameter?.ElementAtOrDefault(1) ?? 0.0f),
         new Vector2(
             parameter?.ElementAtOrDefault(2) ?? 0.0f,
             parameter?.ElementAtOrDefault(3) ?? 0.0f))
 {
 }
Esempio n. 2
0
        public override async UniTask ExecuteAsync(CancellationToken cancellationToken = default)
        {
            var easingType = CameraManager.Configuration.DefaultEasing;

            if (Assigned(EasingTypeName) && !Enum.TryParse(EasingTypeName, true, out easingType))
            {
                LogWarningWithPosition($"Failed to parse `{EasingTypeName}` easing.");
            }

            if (Assigned(Orthographic))
            {
                CameraManager.Camera.orthographic = Orthographic;
            }

            if (Assigned(ToggleTypeNames))
            {
                foreach (var name in ToggleTypeNames)
                {
                    ToggleComponent(name, CameraManager.Camera.gameObject);
                }
            }

            var tasks = new List <UniTask>();

            if (Assigned(Offset))
            {
                tasks.Add(CameraManager.ChangeOffsetAsync(ArrayUtils.ToVector3(Offset, Vector3.zero), Duration, easingType, cancellationToken));
            }
            if (Assigned(Rotation))
            {
                tasks.Add(CameraManager.ChangeRotationAsync(Quaternion.Euler(
                                                                Rotation.ElementAtOrDefault(0) ?? CameraManager.Rotation.eulerAngles.x,
                                                                Rotation.ElementAtOrDefault(1) ?? CameraManager.Rotation.eulerAngles.y,
                                                                Rotation.ElementAtOrDefault(2) ?? CameraManager.Rotation.eulerAngles.z), Duration, easingType, cancellationToken));
            }
            else if (Assigned(Roll))
            {
                tasks.Add(CameraManager.ChangeRotationAsync(Quaternion.Euler(
                                                                CameraManager.Rotation.eulerAngles.x,
                                                                CameraManager.Rotation.eulerAngles.y,
                                                                Roll), Duration, easingType, cancellationToken));
            }
            if (Assigned(Zoom))
            {
                tasks.Add(CameraManager.ChangeZoomAsync(Zoom, Duration, easingType, cancellationToken));
            }

            await UniTask.WhenAll(tasks);
        }
Esempio n. 3
0
        public override async UniTask ExecuteAsync(CancellationToken cancellationToken = default)
        {
            var cameraManager = Engine.GetService <ICameraManager>();

            var easingType = cameraManager.Configuration.DefaultEasing;

            if (Assigned(EasingTypeName) && !Enum.TryParse(EasingTypeName, true, out easingType))
            {
                LogWarningWithPosition($"Failed to parse `{EasingTypeName}` easing.");
            }

            if (Assigned(Orthographic))
            {
                cameraManager.Camera.orthographic = Orthographic;
            }

            if (Assigned(ToggleTypeNames))
            {
                foreach (var name in ToggleTypeNames)
                {
                    DoForComponent(name, c => c.enabled = !c.enabled);
                }
            }

            if (Assigned(SetTypeNames))
            {
                foreach (var kv in SetTypeNames)
                {
                    if (kv.HasValue && !string.IsNullOrWhiteSpace(kv.Name) && kv.NamedValue.HasValue)
                    {
                        DoForComponent(kv.Name, c => c.enabled = kv.Value?.Value ?? false);
                    }
                }
            }

            var tasks = new List <UniTask>();

            if (Assigned(Offset))
            {
                tasks.Add(cameraManager.ChangeOffsetAsync(ArrayUtils.ToVector3(Offset, Vector3.zero), Duration, easingType, cancellationToken));
            }
            if (Assigned(Rotation))
            {
                tasks.Add(cameraManager.ChangeRotationAsync(Quaternion.Euler(
                                                                Rotation.ElementAtOrDefault(0) ?? cameraManager.Rotation.eulerAngles.x,
                                                                Rotation.ElementAtOrDefault(1) ?? cameraManager.Rotation.eulerAngles.y,
                                                                Rotation.ElementAtOrDefault(2) ?? cameraManager.Rotation.eulerAngles.z), Duration, easingType, cancellationToken));
            }
            else if (Assigned(Roll))
            {
                tasks.Add(cameraManager.ChangeRotationAsync(Quaternion.Euler(
                                                                cameraManager.Rotation.eulerAngles.x,
                                                                cameraManager.Rotation.eulerAngles.y,
                                                                Roll), Duration, easingType, cancellationToken));
            }
            if (Assigned(Zoom))
            {
                tasks.Add(cameraManager.ChangeZoomAsync(Zoom, Duration, easingType, cancellationToken));
            }

            await UniTask.WhenAll(tasks);

            void DoForComponent(string componentName, Action <MonoBehaviour> action)
            {
                var cmp = cameraManager.Camera.gameObject.GetComponent(componentName) as MonoBehaviour;

                if (!cmp)
                {
                    LogWithPosition($"Failed to toggle `{componentName}` camera component; the component is not found on the camera's game object.");
                    return;
                }
                action.Invoke(cmp);
            }
        }