Example #1
0
        /// <summary>
        /// Subscribe to PushToGrid events.
        /// </summary>
        /// <param name="listener"></param>
        public static void SubscribePushToGridEvent(Action <float> listener)
        {
            if (GetProGridsType() == null)
            {
                return;
            }

            if (s_SubscribePushToGridEventDelegate == null)
            {
                s_SubscribePushToGridEventDelegate = (Action <Action <float> >)ReflectionUtility.GetOpenDelegate <Action <Action <float> > >(GetProGridsType(), "AddPushToGridListener");
            }

            if (s_SubscribePushToGridEventDelegate != null)
            {
                s_SubscribePushToGridEventDelegate(listener);
            }
        }
Example #2
0
        /// <summary>
        /// Remove subscription from extendo/retracto tooblar events.
        /// </summary>
        /// <param name="listener"></param>
        public static void UnsubscribeToolbarEvent(Action <bool> listener)
        {
            if (GetProGridsType() == null)
            {
                return;
            }

            if (s_UnsubscribeToolbarEventDelegate == null)
            {
                s_UnsubscribeToolbarEventDelegate = (Action <Action <bool> >)ReflectionUtility.GetOpenDelegate <Action <Action <bool> > >(GetProGridsType(), "RemoveToolbarEventSubscriber");
            }

            if (s_UnsubscribeToolbarEventDelegate != null)
            {
                s_UnsubscribeToolbarEventDelegate(listener);
            }
        }
Example #3
0
        /// <summary>
        /// Tell ProGrids that a non-Unity handle has moved in some direction (in world space).
        /// </summary>
        /// <param name="worldDirection"></param>
        public static void OnHandleMove(Vector3 worldDirection)
        {
            if (GetProGridsType() == null)
            {
                return;
            }

            if (s_OnHandleMoveDelegate == null)
            {
                s_OnHandleMoveDelegate = (Action <Vector3>)ReflectionUtility.GetOpenDelegate <Action <Vector3> >(GetProGridsType(), "OnHandleMove");
            }

            if (s_OnHandleMoveDelegate != null)
            {
                s_OnHandleMoveDelegate(worldDirection);
            }
        }
        /// <summary>
        /// Return the last known grid pivot point.
        /// </summary>
        /// <param name="pivot"></param>
        /// <returns></returns>
        public static bool GetPivot(out Vector3 pivot)
        {
            pivot = Vector3.zero;

            if (s_GetPivotDelegate == null)
                s_GetPivotDelegate = (Func<Vector3>)ReflectionUtility.GetOpenDelegate<Func<Vector3>>(GetProGridsType(), "GetPivot");

            if (s_GetPivotDelegate != null)
            {
                pivot = s_GetPivotDelegate();

                // earlier version of progrids return a non-snapped pivot point
                pivot = Snapping.SnapValue(pivot, SnapValue());
                return true;
            }

            return false;
        }
        /// <summary>
        /// Return the last known snap value setting from ProGrids.
        /// </summary>
        /// <returns></returns>
        public static float SnapValue()
        {
            if (GetProGridsType() == null)
            {
                return(0f);
            }

            if (s_SnapValueDelegate == null)
            {
                s_SnapValueDelegate = (Func <float>)ReflectionUtility.GetOpenDelegate <Func <float> >(GetProGridsType(), "SnapValue");
            }

            if (s_SnapValueDelegate != null)
            {
                return(s_SnapValueDelegate());
            }

            return(0f);
        }
        /// <summary>
        /// If ProGrids is open and snap enabled, return true.  False otherwise.
        /// </summary>
        /// <returns></returns>
        public static bool SnapEnabled()
        {
            if (GetProGridsType() == null || !IsActive())
            {
                return(false);
            }

            if (s_SnapEnabledDelegate == null)
            {
                s_SnapEnabledDelegate = (Func <bool>)ReflectionUtility.GetOpenDelegate <Func <bool> >(GetProGridsType(), "SnapEnabled");
            }

            if (s_SnapEnabledDelegate != null)
            {
                return(s_SnapEnabledDelegate());
            }

            return(false);
        }
        /// <summary>
        /// Returns the current UseAxisConstraints value from ProGrids.
        /// </summary>
        /// <returns></returns>
        public static bool UseAxisConstraints()
        {
            if (GetProGridsType() == null)
            {
                return(true);
            }

            if (s_UseAxisConstraintDelegate == null)
            {
                s_UseAxisConstraintDelegate = (Func <bool>)ReflectionUtility.GetOpenDelegate <Func <bool> >(GetProGridsType(), "UseAxisConstraints");
            }

            if (s_UseAxisConstraintDelegate != null)
            {
                return(s_UseAxisConstraintDelegate());
            }

            return(true);
        }
        /// <summary>
        /// Is the scene toolbar extended or collapsed? Also check ProGridsActive to see if ProGrids is open in the first place.
        /// </summary>
        /// <returns>True if ProGrids scene toolbar is open and extended, false if not extended or not active in scene.</returns>
        public static bool SceneToolbarIsExtended()
        {
            if (GetProGridsType() == null)
            {
                return(false);
            }

            if (s_SceneToolbarIsExtendedDelegate == null)
            {
                s_SceneToolbarIsExtendedDelegate = (Func <bool>)ReflectionUtility.GetOpenDelegate <Func <bool> >(GetProGridsType(), "SceneToolbarIsExtended");
            }

            if (s_SceneToolbarIsExtendedDelegate != null)
            {
                return(s_SceneToolbarIsExtendedDelegate());
            }

            return(false);
        }
        /// <summary>
        /// True if ProGrids is open in scene.
        /// </summary>
        /// <returns></returns>
        public static bool IsActive()
        {
            if (GetProGridsType() == null)
            {
                return(false);
            }

            if (s_ProGridsActiveDelegate == null)
            {
                s_ProGridsActiveDelegate = (Func <bool>)ReflectionUtility.GetOpenDelegate <Func <bool> >(GetProGridsType(), "SceneToolbarActive");
            }

            if (s_ProGridsActiveDelegate != null)
            {
                return(s_ProGridsActiveDelegate());
            }

            return(false);
        }