Example #1
0
    public void HandleEmotion(WatsonServiceConnection.WatsonToneID watsonToneId, double score)
    {
        Debug.Log("EmotionHandler ");

        // display the highest scoring value
        if (score > maxEmotionScore)
        {
            if (maxEmotionTextUI != null)
            {
                maxEmotionTextUI.text = WatsonServiceConnection.nameForWatsonToneID(watsonToneId);
            }
            maxEmotionScore = (float)score;
        }

        // lookup the corresponding GameObject and apply action to it
        if (dictionary.ContainsKey(watsonToneId))
        {
            Text go = dictionary[watsonToneId];
            if (go != null)
            {
                // Action to be applied
                go.text = score.ToString();
            }
        }
    }
    public void HandleEmotion(WatsonServiceConnection.WatsonToneID watsonToneId, double score)
    {
        Debug.Log("EmotionHandler ");

        // display the highest scoring value
        if (score > maxEmotionScore)
        {
            if (maxEmotionTextUI != null)
            {
                maxEmotionTextUI.text = WatsonServiceConnection.nameForWatsonToneID(watsonToneId);
            }
            maxEmotionScore = (float)score;
        }

        // lookup the corresponding GameObject and apply action to it
        if (dictionary.ContainsKey(watsonToneId))
        {
            GameObject go = dictionary[watsonToneId];
            if (go != null)
            {
                // Action to be applied
                // if different for different WatsonToneID, use a switch or dictionary
                // simple case is to toggle on/off based on emotion_threshold
                if (score > emotion_threshold)
                {
                    go.SetActive(true);
                }
                else
                {
                    go.SetActive(false);
                }
            }
        }
    }