taha121
Posts: 1
Joined: Tue Aug 18, 2020 1:34 pm

Unity 3d oscova entities not working

Tue Aug 18, 2020 4:32 pm

Hello!
I am doing my final year project and implementing a chatbot in Ar using unity. I was following oscova tutorial for unity and the hello bot works fie but when I add other entities it is showing error. Please help!! I am already late on my project. Also if I use template method it also shows error.I am using unity 2018.4.12f1

CSharp Code

  
    [Expression("open {unity}")]
    [Expression("open {facebook}")]
    [Entity("app")]
    public void OpenApp(Context context, Result result)
    {
        var appEntity = result.Entities.OfType("app");
        
        if (app == "unity")//error here
        {
            Debug.Log("works");
            Application.OpenURL("http://unity3d.com/");
            result.SendResponse("App opened");
        }
        if (app == "facebook")//error here
        {
            Application.OpenURL("http://facebook.com/");
            result.SendResponse("App opened");
        }
    }
	

User avatar
Fantom
Help & Support
Posts: 320
Joined: Fri Oct 25, 2013 9:20 pm

Re: Unity 3d oscova entities not working

Tue Aug 18, 2020 5:12 pm

Your code could not be compiled. However, we've found a basic problem.

You've compared an object of IEntity to String which is a compile time error. We've fixed your code below.

CSharp Code

[Expression("open {unity}")]
[Expression("open {facebook}")]
[Entity("app")]
public void OpenApp(Context context, Result result)
{
    var appEntity = result.Entities.OfType("app");

    if (appEntity.Value == "unity")//error here
    {
        Debug.Log("works");
        MediaTypeNames.Application.OpenURL("http://unity3d.com/");
        result.SendResponse("App opened");
    }
    if (appEntity.Value == "facebook")//error here
    {
        MediaTypeNames.Application.OpenURL("http://facebook.com/");
        result.SendResponse("App opened");
    }
}
Although the above code should work. We encourage you to use Template expressions instead.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest