+1

Get string from script on button on another gameobject to use as float for transform

sski 2 years ago 0

I am a complete noob with c# unity and bolt.

I have a demo scene file containing monodevelop script which has emotion recognition from webcam, the results are outputted as a string onto text parented to a button.

I would like to get this string and convert it to float to apply transforms to other objects in the scene. The string is made from this code which is part of the whole script

if (eda.ProcessImage(img))
{
msg.text = String.Format("{0} Face(s detected.", eda.Faces.Count);

if (eda.ProcessFaces())
{
if (eda.ProcessLandmarks())
{
Dictionary emos = new Dictionary();

foreach (String emo in eda.Emotions)
{
// Debug.LogFormat("{0} scores {1}.", emo, eda[0, emo]);
emos[emo] = eda[0, emo];
}

emotions.text = String.Join("\r\n", emos.OrderBy(p => p.Key).Select(p => String.Format("{0}={1:0.00}", p.Key, p.Value)).ToArray());
}
else
{
msg.text = "No emotions detected";
}
}
else
{
msg.text = "No landmarks detected";
}
}
else
{
msg.text = "No Face(s) detected";
}
}

I assume it is a variable called emotions looking at the beginning of the script

public class ButtonScript : MonoBehaviour
{
public RawImage rawimage;
public Text emotions;

I have no idea what I am doing... could someone point me in the right direction.


Many thanks.

Bolt Version:
Unity Version:
2017.4.21f1
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):