Exemplo n.º 1
0
        /**
         * @api {C# - Method} RecordKeyword() RecordKeyword()
         * @apiName RecordKeyword()
         * @apiDescription RecordKeyword() records what keywords are being used in the application.
         *
         * @apiParam (Parameters) {string} keyword Records keyword use in application.
         * @apiParam (Parameters) {string} gazedObject References the GameObject being gazed while stat is being recorded. (AutoGenerated)
         * @apiParamExample {json} Description:
         * Records what keywords are being used in the application.
         *
         * Can be used to track:
         * - Command keywords used in your application.
         * - Requests for help from user.
         * - Interaction keywords used with UI or other GameObjects.
         * @apiParamExample {json} Example:
         * "// This example shows how to record when a user speaks the keyword Help."
         * PracticalAPI.Instance.RecordKeyword(“Help”);
         * @apiParamExample {json} Structure:
         * PracticalAPI.Instance.RecordKeyword(string keyword);
         * @apiGroup PracticalAPI
         * @apiPermission Beta
         * @apiVersion 0.1.0
         */

        public void RecordKeyword(string keyword, string interactObject = "")
        {
            if (logSummary)
            {
                Debug.Log("Keyword recorded: " + keyword + "\n");

                if (gazeManager.HitObject != null)
                {
                    var objName = gazeManager.HitObject.gameObject.name;
                    Debug.Log("Target: " + objName + "\n");
                }
            }

            if (gazeManager.HitObject != null)
            {
                var objName = gazeManager.HitObject.gameObject.name;
#if WINDOWS_UWP
                int ret = PracticalDLL.RecordKeyword(keyword, "1.0", objName);

                if (ret > 0)
                {
                    Debug.Log(GetErrorMessage(ret));
                }
            }
            else
            {
                int ret = PracticalDLL.RecordKeyword(keyword, "1.0", interactObject);

                if (ret > 0)
                {
                    Debug.Log(GetErrorMessage(ret));
                }
#endif
            }
        }
Exemplo n.º 2
0
        private void RecordGaze(float gazeLength)
        {
            if (logSummary)
            {
                Debug.Log("Object Viewed: " + viewedObject + " for " + gazeLength + " seconds. \n");
            }
#if WINDOWS_UWP
            int ret = PracticalDLL.RecordGaze(viewedObject, gazeLength.ToString());

            if (ret > 0)
            {
                Debug.Log(GetErrorMessage(ret));
            }
#endif
        }
Exemplo n.º 3
0
        /**
         * @api {C# - Method} RecordLoss() RecordLoss()
         * @apiName RecordLoss()
         * @apiDescription RecordLoss() records when user experiences a loss behavior.
         *
         * @apiParam (Parameters) {string} uniqueIdentifier Reference identification of stat.
         * @apiParam (Parameters) {float} value Referencese the stat value.
         *
         * @apiParamExample {json} Description:
         * RecordLoss can be used to track when a user loses:
         * - Health
         * - Points
         * - Lives
         * - Currency
         *
         * RecordLoss can also be used to track when the user fails:
         * - MissionFailed
         * - TimeUp
         * - Wipeout
         * - GameOver
         *
         * @apiParamExample {json} Example:
         * "// This example shows how to record a player losing health."
         * PracticalAPI.Instance.RecordLoss("HealthLoss", 25);
         *
         * "// This example shows how to record a player failing a wave."
         * PracticalAPI.Instance.RecordLoss("WaiveFailed", 1);
         *
         * "// This example shows how to record a player losing a life."
         * PracticalAPI.Instance.RecordLoss("LifeLost", 1);
         * @apiParamExample {json} Structure:
         * PracticalAPI.Instance.RecordLoss(string uniqueIdentifier, float value)
         * @apiGroup PracticalAPI
         * @apiPermission Beta
         * @apiVersion 0.1.0
         */

        public void RecordLoss(string uniqueIdentifier, float value)
        {
            if (logSummary)
            {
                Debug.Log("Loss recorded \n");
                Debug.Log("Loss Unique Identifier: " + uniqueIdentifier + "\n");
                Debug.Log("Value: " + value + "\n");
            }
#if WINDOWS_UWP
            int ret = PracticalDLL.RecordLoss(uniqueIdentifier, value.ToString());

            if (ret > 0)
            {
                Debug.Log(GetErrorMessage(ret));
            }
#endif
        }
Exemplo n.º 4
0
        /**
         * @api {C# - Method} RecordCustomStat() RecordCustomStat()
         * @apiName RecordCustomStat()
         * @apiDescription RecordCustomStat() records a custom metric/stat. Custom stats can be used in variety of ways.
         *
         *
         * @apiParam (Parameters) {string} uniqueIdentifier References identification of customized metric/stat.
         * @apiParam (Parameters) {float} value References value of customized metric/stat.
         * @apiParam (Parameters) {Measurment} measurement References measurement of customized metric/stat. Count, Second, Feet, or Meter. (optional)
         * @apiParam (Parameters) {Formula} formula References formula of customized metric/stat. Total or Average. (optional)
         * @apiParam (Parameters) {string} gazedObject References the GameObject being gazed while stat is being recorded. (AutoGenerated)
         * @apiParamExample {json} Description:
         * This method provides the utility to:
         * - Create custom defined stats.
         * - Control how the stats will be measured.
         * - Calculate the total or average of stats collected.
         *
         * Measurment and Formula are optional parameters.
         *
         * If they are not provided:
         * - Measurement defaults to count.
         * - Formula defaults to total.
         *
         * @apiParamExample {json} Examples:
         * "// This example shows how to record a player completing a wave."
         * PracticalAPI.Instance.RecordCustomStat("WavesCompleted", 1);
         *
         * "// This example shows how to record a user success streak."
         * PracticalAPI.Instance.RecordCustomStat("Combo", 1, Measurement.Count, Formula.Total);
         *
         * "// This example shows how to record the average of seconds remaining of a timed event."
         * PracticalAPI.Instance.RecordCustomStat("SecondsRemaining", 32, Measurement.Count, Formula.Average);
         * @apiParamExample {json} Structure:
         * PracticalAPI.Instance.RecordCustomStat(string uniqueIdentifier, float value);
         * PracticalAPI.Instance.RecordCustomStat(string uniqueIdentifier, float value, Measurement measurement, Formula formula);
         * @apiGroup PracticalAPI
         * @apiPermission Beta
         * @apiVersion 0.1.0
         */

        public void RecordCustomStat(string uniqueIdentifier, float value, Measurement measurement = Measurement.Count,
                                     Formula formula = Formula.Total, string gazedObject = "")
        {
            if (logSummary)
            {
                Debug.Log("Custom stat recorded: " + uniqueIdentifier + "\n");
                Debug.Log("Value: " + value + "\n");

                if (gazeManager.HitObject != null)
                {
                    var objName = gazeManager.HitObject.gameObject.name;
                    Debug.Log("Object name: " + objName + "\n");
                }

                Debug.Log("Measurement: " + measurement);
                Debug.Log("Formula: " + formula);
            }

#if WINDOWS_UWP
            if (gazeManager.HitObject != null)
            {
                var objName = gazeManager.HitObject.gameObject.name;

                int ret = PracticalDLL.RecordCustomStat(uniqueIdentifier, value.ToString(), ((int)measurement).ToString(), ((int)formula).ToString(), objName);

                if (ret > 0)
                {
                    Debug.Log(GetErrorMessage(ret));
                }
            }
            else
            {
                int ret = PracticalDLL.RecordCustomStat(uniqueIdentifier, value.ToString(), ((int)measurement).ToString(), ((int)formula).ToString(), gazedObject);

                if (ret > 0)
                {
                    Debug.Log(GetErrorMessage(ret));
                }
            }
#endif
        }
Exemplo n.º 5
0
        /**
         * @api {C# - Method} RecordGesture() RecordGesture()
         * @apiName RecordGesture()
         * @apiDescription RecordGesture() tracks gestures and the GameObjects being interacted with. GestureType defaults to Tap.
         *
         * @apiParam (Parameters) {string} uniqueIdentifier Records name of object being gesture to. (Example: HitObject.gameObject.name)
         * @apiParam (Parameters) {GestureType} gestureType Identifies which type of gesture is being used.
         * @apiParam (Parameters) {string} gazedObject Reference the GameObject being gazed while stat is being recorded. (AutoGenerated)
         * @apiParamExample {json} Description:
         * Tracks gestures and the GameObjects being interacted with.
         *
         * Can be used for tracking:
         * - Firing projectile
         * - Basic selection
         * - User interaction
         *
         * @apiParamExample {json} Example:
         * "// This example is from the HoloToolkit script GestureInputs.cs with our API implemented."
         * protected void OnTappedEvent(InteractionSourceKing source, int tapCount, Ray headRay)
         *{
         *   "// Get the current Gaze's hit object"
         *   var hitObj = GazeManager.Instance.HitObject;
         *
         *   "// Send an OnSelect message to the focused object and it's ancestors."
         *   if (hitObj != null)
         *   {
         *      if (hitObj.layer == PracticalAPI.Instance.MappingPhysicsLayer)
         *      {
         *         PracticalAPI.Instance.RecordGesture("Mapping");
         *      }
         *      else
         *      {
         *         PracticalAPI.Instance.RecordGesture(hitObj.gameObject.name);
         *      }
         *   }
         *   else
         *   {
         *      PracticalAPI.Instance.RecordGesture("No Hit");
         *   }
         *}
         * @apiParamExample {json} Structure:
         * PracticalAPI.Instance.RecordGesture(string uniqueIdentifier);
         *
         * @apiGroup PracticalAPI
         * @apiPermission Beta
         * @apiVersion 0.1.0
         */

        public void RecordGesture(string uniqueIdentifier, float HoldLength = 0.0f, GestureType gestureType = GestureType.Tap,
                                  string gazedObject = "")
        {
            if (logSummary)
            {
                Debug.Log("Tap event recorded \n");
                Debug.Log("GestureType: " + gestureType + "\n");
                if (gazeManager.HitObject != null)
                {
                    var customCheck = gazeManager.HitObject.gameObject.GetComponent <PracticalGazeTracker>();

                    if (customCheck != null && customCheck.customName)
                    {
                        Debug.Log("Object name: " + customCheck.customIdentifier + "\n");
                    }
                    else
                    {
                        Debug.Log("Object name: " + uniqueIdentifier + "\n");
                    }
                }
                if (HoldLength > 0)
                {
                    Debug.Log("Tap Hold Length : " + HoldLength + " seconds\n");
                }
            }

#if WINDOWS_UWP
            if (gazeManager.HitObject != null)
            {
                // Will pass objName from HitObject & HoldLength default values if not provided.
                var customCheck = gazeManager.HitObject.gameObject.GetComponent <PracticalGazeTracker>();

                if (customCheck != null && customCheck.customName)
                {
                    int res = PracticalDLL.RecordGesture(customCheck.customIdentifier, "1.0", ((int)gestureType).ToString(), customCheck.customIdentifier, HoldLength.ToString());

                    if (res > 0)
                    {
                        Debug.Log(GetErrorMessage(res));
                    }
                }
                else
                {
                    var objName = gazeManager.HitObject.gameObject.name;
                    int ret     = PracticalDLL.RecordGesture(uniqueIdentifier, "1.0", ((int)gestureType).ToString(), objName, HoldLength.ToString());

                    if (ret > 0)
                    {
                        Debug.Log(GetErrorMessage(ret));
                    }
                }
            }
            else
            {
                // Will pass just the HoldLength value, and interacted object with default values if not provided.
                int ret = PracticalDLL.RecordGesture(uniqueIdentifier, "1.0", ((int)gestureType).ToString(), gazedObject, HoldLength.ToString());

                if (ret > 0)
                {
                    Debug.Log(GetErrorMessage(ret));
                }
            }
#endif
        }
Exemplo n.º 6
0
        /**
         * @api {C# - Method} GetLastErrorMessage() GetLastErrorMessage()
         * @apiName GetLastErrorMessage()
         * @apiDescription GetLastErrorMessage() returns last error message from the DLL.
         *
         * @apiParamExample {json} Description:
         * Returns last error message from DLL.
         *
         * See GetErrorMessage() for specific error codes.
         * @apiParamExample {json} Example:
         * "// Returns last error message from DLL."
         * GetLastErrorMessage();
         *
         * @apiParamExample {json} Structure:
         * GetLastErrorMessage();
         * @apiGroup PracticalAPI
         * @apiPermission Beta
         * @apiVersion 0.1.0
         */

#if WINDOWS_UWP
        public string GetLastErrorMessage()
        {
            return(Marshal.PtrToStringAnsi(PracticalDLL.GetLastErrorMessage()));
        }
Exemplo n.º 7
0
        /**
         * @api {C# - Method} GetErrorMessage() GetErrorMessage()
         * @apiName GetErrorMessage()
         * @apiDescription GetErrorMessage() returns specific error message from the DLL.
         *
         * @apiParam (Parameters) {int} errorCode References specific error code.
         * @apiParamExample {json} Description:
         * Call this method with the provided error code to retrieve error message.
         *
         * Error Code:
         * 1) "Authentication did not suceed yet."
         * 2) "No Internet Connection."
         * 3) "API key is invalid."
         * 4) "Message Encoding is invalid."
         * 5) "Must call startup function first."
         * 6) "Hold length parameter must contain float value."
         * 7) "Data buffer is empty."
         * 8) "Value parameter must contain float value."
         * 9) "Measurment parameter must have the enum Measurment Type."
         * 10) "Formula parameter must have the enum Formula Type."
         * 11) "GestureType parameter must have the enum GestureType Type."
         *
         * @apiParamExample {json} Example:
         * "// Retrieves error message from the DLL: API key is invalid."
         * GetErrorMessage(3);
         *
         * @apiParamExample {json} Structure:
         * GetErrorMessage(int errorCode);
         * @apiGroup PracticalAPI
         * @apiPermission Beta
         * @apiVersion 0.1.0
         */

#if WINDOWS_UWP
        public string GetErrorMessage(int errorCode)
        {
            return(Marshal.PtrToStringAnsi(PracticalDLL.GetErrorMessage(errorCode)));
        }