Speech to text enabling in unity not working - unity3d

I am using unity 2018.1.0f2 and windows 10. Below is the code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Windows.Speech;
public class Dinovoice : MonoBehaviour {
KeywordRecognizer KeywordRecognizerObj;
void Start () {
string[] keywords_array={"Jump","Run"};
KeywordRecognizerObj= new KeywordRecognizer(keywords_array);
KeywordRecognizerObj.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
KeywordRecognizerObj.Start();
Debug.Log("Started");
}
void Update() {
}
private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
{
Debug.Log("Ended");
}
}
When I run from unity Started is getting printed.Ended is not getting printed at all when I speak.I am using unity with wikitude. I am adding this script to my prefab.Can you please help me out.Is there any setting I am missing?
Thanks

Related

unity ads not showing up

i followed the official unity tutorial on how to put bannner ads on my game, i set everything up in the unity dashboard, and in the editor i see a rectangle that says the ad should be there, but when i build the game nothing shows up, here is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class bannerad : MonoBehaviour
{
bool testMode = false;
public string gameId = "******" (my game id is here i just dot want to share it);
// Start is called before the first frame update
IEnumerator Start()
{
Advertisement.Initialize(gameId, testMode);
while (!Advertisement.IsReady("Lost_Ad"))
{
yield return null;
}
Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
Advertisement.Banner.Show("Lost_Ad");
}
}
anyone knows what is the solution?
Are you ever calling this function? If you just replaced the Start function with this IEnumerator it will not get called unless you call it.
private void Start()
{
Advertisement.Initialize(gameId, testMode);
StartCoroutine(StartAds());
}
private IEnumerator StartAds()
{
// your code here
}

Unity UI doesn't set the interactability to true in script

I've had this problem before, and I can't stand it anymore. Why and how does this happen? I'm new to C# and I don't know what I'm doing wrong.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonActivate : MonoBehaviour
{
bool Test;
Button ButtonHere;
void Update()
{
Test = true;
if (Test == true)
{
ButtonHere.interactable = true;
}
}
}
2 possible mistakes I can think of are:
Buttonhere is null or is referencing the wrong GameObject.
The script isn't attached to anything, try attaching it to something like the button itself or the 'Main Camera'.

Unity Networkserver.SpawnwithclientAuthroity doesn't work on host

I followed a Youtube tutorial https://www.youtube.com/watch?v=afz2An4X0vw on how to use Unity networking.
The point is to have an object with a network ID component spawn the player and in order to control the player we need to give the client spawning the player authority over that player.
However, having done exactly the same as in the video, whenever I host the game (with the unity Network HUD) the hasAuthority returns false instead of true on only the host.
It returns true on all the other clients (as it should).
To me it seems as if the hosting person doesn't see itself as a client but only the server, yet this doesn't happen in the video linked above.
How do I make the hosting player return true on hasAuthority as it refuses to do so with the code below?
The script on the object (spawned when the client connects):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class ThePlayerScript : NetworkBehaviour
{
public GameObject abigail;
public GameObject abigailN;
void Start ()
{
if(isLocalPlayer == false)
{
return;
}
CmdSpawnPlayer();
}
void Update () { }
[Command]
void CmdSpawnPlayer()
{
abigailN = Instantiate(abigail);
NetworkServer.SpawnWithClientAuthority(abigailN, connectionToClient);
}
}
The code on the player that is spawned by the gameobject:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class Abigail : NetworkBehaviour
{
public GameObject mainCamera;
Vector3 myLocation;
Vector3 cameraView;
// Use this for initialization
void Start ()
{
if(hasAuthority == false)
{
Destroy(this);
return;
}
mainCamera = GameObject.Find("Main Camera");
}
}
(I removed the Update function in the Abigail class as it is irrelevant as it doesn't get executed.)
I found out that hasAuthority in this case will only return false in the Start() method. If you use it in the Update() method it will return true properly if you assign authority simply as you do in "ThePlayerScipt" with:
NetworkServer.SpawnWithClientAuthority(abigailN, connectionToClient);
Hope that helps :)

JetBrains Rider not catching ArgumentOutOfRange exception from Unity

Is it just me ? Also Rider is very slow.
Tried with an empty Unity project with just a script and an empty list:
using System.Collections.Generic;
using UnityEngine;
public class TestException : MonoBehaviour
{
private List<int> emptyList= new List<int>();
void Start ()
{
emptyList[11] = 0;
}
}
JBR 2018.2.3
Unity 2018.2.8f1

VRTK_ControllerEvents returning null

I am trying to make a gun in Unity with SteamVR and VRTK but I can't figure out how to properly get controller input. When I use the SteamVR Tracked Controller script I get an IsMatrixValid error and it messes up my HMD. I am currently trying to use VRTK controller events method but it keeps returning as a null even though I followed the video correctly.
Screenshot of script location in project
Video in question: https://www.youtube.com/watch?v=escwjnHFce0
(14:17)
Script in question:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EZEffects;
using VRTK;
public class GunBehavior : MonoBehaviour {
public VRTK_ControllerEvents controllerEvents;
private SteamVR_TrackedObject trackedObj;
public EffectTracer TracerEffect;
public Transform muzzleTransform;
// Use this for initialization
void Start () {
Debug.Log(controllerEvents);
if (controllerEvents)
{
Debug.Log("Hue22");
}
else
{
Debug.Log("work");
}
}
// Update is called once per frame
void Update () {
if (controllerEvents.triggerPressed)
{
ShootWeapon();
}
}
void TriggerPressed(object sender, VRTK.ControllerInteractionEventArgs e)
{
ShootWeapon();
}
void ShootWeapon()
{
RaycastHit hit = new RaycastHit();
Ray ray = new Ray(muzzleTransform.position, muzzleTransform.forward);
TracerEffect.ShowTracerEffect(muzzleTransform.position, muzzleTransform.forward, 250f);
if (Physics.Raycast(ray, out hit, 5000f))
{
Debug.Log("Hueheuhue");
}
}
}
Delete these 3 lines of code from your scrip and it should work
void TriggerPressed(object sender, VRTK.ControllerInteractionEventArgs e)
{
ShootWeapon();
}