Topic: Playmaker Action: Get Center Point And Best Zoom between Coords

Hi I added a new playmaker action  Get Center Point And Best Zoom between Coords, I include here for the community.

using System.Collections.Generic;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
    [ActionCategory(OnlineMapsCategories.UTILS)]
    [Tooltip("Get Center Point And Best Zoom between Coords")]
    public class GetCenterPointAndBestZoomForCoords : FsmStateAction
    {
        [RequiredField]
        [Tooltip("Coord 1")]
        public FsmVector2 coord1;

        [RequiredField]
        [Tooltip("Coord 2")]
        public FsmVector2 coord2;

        [RequiredField]
        [UIHint(UIHint.Variable)]
        [Tooltip("Center coint coordinate (X - Lng, Y - Lat)")]
        public FsmVector2 storeCenterPoint;

        [UIHint(UIHint.Variable)]
        [Tooltip("Best zoom")]
        public FsmInt storeZoom;

        public override void Reset()
        {
            coord1 = null;
            coord2 = null;
            storeCenterPoint = null;
            storeZoom = null;
        }

        public override void OnEnter()
        {
            DoEnter();
            Finish();
        }

        private void DoEnter()
        {
            if (OnlineMaps.instance == null)
            {
                Debug.LogError("Online Maps not found.");
                return;
            }

            Vector2 center;
            int zoom;
            OnlineMapsUtils.GetCenterPointAndZoom(new[] {coord2.Value, coord1.Value}, out center, out zoom);

            storeCenterPoint.Value = center;
            storeZoom.Value = zoom;
        }
    }
}

Re: Playmaker Action: Get Center Point And Best Zoom between Coords

Hello.

Many thanks.
We have slightly modified it to work with 2+ coordinates.
Online Maps v2.4.0.33+ will have this action.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.