void Start() { GameObject playerGameObject = GameObject.Find("hero"); //get player and set to pProp pProp = playerGameObject.GetComponent<PlayerProperties>(); speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); intManager = GameObject.FindWithTag("kinect-interaction").GetComponent<InteractionManager>(); heartIcon = GameObject.Find("heart_icon").GetComponent<GUITexture>(); //coins and lives are slightly bigger if using a larger screen livesText.fontSize = Screen.width/40; if (livesText.fontSize < 20) livesText.fontSize = 20; //impose min size restriction coinsText.fontSize = livesText.fontSize; }
void Update() { if(speechManager == null) { speechManager = SpeechManager.Instance; } if(speechManager != null && speechManager.IsSapiInitialized()) { if(speechManager.IsPhraseRecognized()) { string sPhraseTag = speechManager.GetPhraseTagRecognized(); switch(sPhraseTag) { case "RECORD": if(saverPlayer) { saverPlayer.StartRecording(); } break; case "PLAY": if(saverPlayer) { saverPlayer.StartPlaying(); } break; case "STOP": if(saverPlayer) { saverPlayer.StopRecordingOrPlaying(); } break; } speechManager.ClearPhraseRecognized(); } } }
void StartRecognizer() { try { if (debugText != null) { debugText.GetComponent <GUIText>().text = "Please, wait..."; } // initialize Kinect sensor as needed int rc = SpeechWrapper.InitKinectSensor(); if (rc != 0) { throw new Exception("Initialization of Kinect sensor failed"); } // Initialize the kinect speech wrapper string sCriteria = String.Format("Language={0:X};Kinect=True", LanguageCode); rc = SpeechWrapper.InitSpeechRecognizer(sCriteria, true, false); if (rc < 0) { throw new Exception(String.Format("Error initializing Kinect/SAPI: " + SpeechWrapper.GetSystemErrorMessage(rc))); } if (RequiredConfidence > 0) { SpeechWrapper.SetRequiredConfidence(RequiredConfidence); } if (GrammarFileName != string.Empty) { rc = SpeechWrapper.LoadSpeechGrammar(GrammarFileName, (short)LanguageCode); if (rc < 0) { throw new Exception(String.Format("Error loading grammar file " + GrammarFileName + ": hr=0x{0:X}", rc)); } } instance = this; sapiInitialized = true; DontDestroyOnLoad(gameObject); if (debugText != null) { debugText.GetComponent <GUIText>().text = "Ready."; } } catch (DllNotFoundException ex) { Debug.LogError(ex.ToString()); if (debugText != null) { debugText.GetComponent <GUIText>().text = "Please check the Kinect and SAPI installations."; } } catch (Exception ex) { Debug.LogError(ex.ToString()); if (debugText != null) { debugText.GetComponent <GUIText>().text = ex.Message; } } }
void OnDestroy() { if(sapiInitialized && sensorData != null && sensorData.sensorInterface != null) { // finish speech recognition sensorData.sensorInterface.FinishSpeechRecognition(); } sapiInitialized = false; instance = null; }
private string TranslatePage(JournalPage page, int languageNumber) { return(SpeechManager.GetTranslation(page.text, page.lineID, languageNumber)); }
void Start() { speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); worldIndex = GameObject.Find("levelProperties").GetComponent<LevelProperties>().worldIndex; intManager = GameObject.FindWithTag("kinect-interaction").GetComponent<InteractionManager>(); pMenu = GetComponent<MenuPause>(); opMenu = GetComponent<MenuOptions>(); hMenu = GetComponent<MenuHelp>(); }
//----------------------------------- end of public functions --------------------------------------// void Start() { try { // get sensor data KinectManager kinectManager = KinectManager.Instance; if (kinectManager && kinectManager.IsInitialized()) { sensorData = kinectManager.GetSensorData(); } if (sensorData == null || sensorData.sensorInterface == null) { throw new Exception("Speech recognition cannot be started, because KinectManager is missing or not initialized."); } if (debugText != null) { debugText.GetComponent <GUIText>().text = "Please, wait..."; } // ensure the needed dlls are in place and speech recognition is available for this interface bool bNeedRestart = false; if (sensorData.sensorInterface.IsSpeechRecognitionAvailable(ref bNeedRestart)) { if (bNeedRestart) { KinectInterop.RestartLevel(gameObject, "SM"); return; } } else { string sInterfaceName = sensorData.sensorInterface.GetType().Name; throw new Exception(sInterfaceName + ": Speech recognition is not supported!"); } // Initialize the speech recognizer string sCriteria = String.Format("Language={0:X};Kinect=True", languageCode); int rc = sensorData.sensorInterface.InitSpeechRecognition(sCriteria, true, false); if (rc < 0) { string sErrorMessage = (new SpeechErrorHandler()).GetSapiErrorMessage(rc); throw new Exception(String.Format("Error initializing Kinect/SAPI: " + sErrorMessage)); } if (requiredConfidence > 0) { sensorData.sensorInterface.SetSpeechConfidence(requiredConfidence); } if (grammarFileName != string.Empty) { // copy the grammar file from Resources, if available if (!File.Exists(grammarFileName)) { TextAsset textRes = Resources.Load(grammarFileName, typeof(TextAsset)) as TextAsset; if (textRes != null) { string sResText = textRes.text; File.WriteAllText(grammarFileName, sResText); } } // load the grammar file rc = sensorData.sensorInterface.LoadSpeechGrammar(grammarFileName, (short)languageCode); print("Loaded file " + grammarFileName); if (rc < 0) { string sErrorMessage = (new SpeechErrorHandler()).GetSapiErrorMessage(rc); throw new Exception("Error loading grammar file " + grammarFileName + ": " + sErrorMessage); } } instance = this; sapiInitialized = true; //DontDestroyOnLoad(gameObject); if (debugText != null) { debugText.GetComponent <GUIText>().text = "Ready."; } } catch (DllNotFoundException ex) { Debug.LogError(ex.ToString()); if (debugText != null) { debugText.GetComponent <GUIText>().text = "Please check the Kinect and SAPI installations."; } } catch (Exception ex) { Debug.LogError(ex.ToString()); if (debugText != null) { debugText.GetComponent <GUIText>().text = ex.Message; } } }
private void OnGUI() { if (AdvGame.GetReferences().speechManager == null) { EditorGUILayout.HelpBox("A Speech Manager must be assigned before this window can display correctly.", MessageType.Warning); return; } scroll = GUILayout.BeginScrollView(scroll); SpeechManager speechManager = AdvGame.GetReferences().speechManager; EditorGUILayout.HelpBox("Check the settings below and click 'Create' to save a new script sheet.", MessageType.Info); EditorGUILayout.Space(); if (speechManager.languages.Count > 1) { languageIndex = EditorGUILayout.Popup("Language:", languageIndex, speechManager.languages.ToArray()); } else { languageIndex = 0; } limitToCharacter = EditorGUILayout.Toggle("Limit to character?", limitToCharacter); if (limitToCharacter) { characterName = EditorGUILayout.TextField("Character name:", characterName); } limitToTag = EditorGUILayout.Toggle("Limit by tag?", limitToTag); if (limitToTag) { // Create a string List of the field's names (for the PopUp box) List <string> labelList = new List <string>(); int i = 0; int tagNumber = -1; if (speechManager.speechTags.Count > 0) { foreach (SpeechTag speechTag in speechManager.speechTags) { labelList.Add(speechTag.label); if (speechTag.ID == tagID) { tagNumber = i; } i++; } if (tagNumber == -1) { if (tagID > 0) { ACDebug.LogWarning("Previously chosen speech tag no longer exists!"); } tagNumber = 0; tagID = 0; } tagNumber = EditorGUILayout.Popup("Speech tag:", tagNumber, labelList.ToArray()); tagID = speechManager.speechTags [tagNumber].ID; } else { EditorGUILayout.HelpBox("No speech tags!", MessageType.Info); } } limitToMissingAudio = EditorGUILayout.Toggle("Limit to lines with no audio?", limitToMissingAudio); includeDescriptions = EditorGUILayout.Toggle("Include descriptions?", includeDescriptions); removeTokens = EditorGUILayout.Toggle("Remove text tokens?", removeTokens); if (GUILayout.Button("Create")) { CreateScript(); } EditorGUILayout.Space(); EditorGUILayout.EndScrollView(); }
private ManagerPackage CreateManagerPackage(string folder, SceneManager sceneManager, SettingsManager settingsManager, ActionsManager actionsManager, VariablesManager variablesManager, InventoryManager inventoryManager, SpeechManager speechManager, CursorManager cursorManager, MenuManager menuManager) { ManagerPackage managerPackage = CustomAssetUtility.CreateAsset <ManagerPackage> ("ManagerPackage", folder); AssetDatabase.RenameAsset("Assets/" + folder + "/ManagerPackage.asset", folder + "_ManagerPackage"); managerPackage.sceneManager = sceneManager; managerPackage.settingsManager = settingsManager; managerPackage.actionsManager = actionsManager; managerPackage.variablesManager = variablesManager; managerPackage.inventoryManager = inventoryManager; managerPackage.speechManager = speechManager; managerPackage.cursorManager = cursorManager; managerPackage.menuManager = menuManager; managerPackage.AssignManagers(); EditorUtility.SetDirty(managerPackage); AssetDatabase.SaveAssets(); AdventureCreator.Init(); return(managerPackage); }
private void Finish() { if (!references) { GetReferences(); } if (!references) { return; } string managerPath = gameName + "/Managers"; try { System.IO.Directory.CreateDirectory(Application.dataPath + "/" + managerPath); } catch (System.Exception e) { ACDebug.LogError("Wizard aborted - Could not create directory: " + Application.dataPath + "/" + managerPath + ". Please make sure the Assets direcrory is writeable, and that the intended game name contains no special characters."); Debug.LogException(e, this); pageNumber--; return; } try { ShowProgress(0f); SceneManager newSceneManager = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager"); references.sceneManager = newSceneManager; ShowProgress(0.1f); SettingsManager newSettingsManager = CustomAssetUtility.CreateAsset <SettingsManager> ("SettingsManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager"); newSettingsManager.saveFileName = gameName; newSettingsManager.cameraPerspective = cameraPerspective; newSettingsManager.movingTurning = movingTurning; newSettingsManager.movementMethod = movementMethod; newSettingsManager.inputMethod = inputMethod; newSettingsManager.interactionMethod = interactionMethod; newSettingsManager.hotspotDetection = hotspotDetection; if (cameraPerspective == CameraPerspective.TwoPointFiveD) { newSettingsManager.forceAspectRatio = true; } references.settingsManager = newSettingsManager; ShowProgress(0.2f); ActionsManager newActionsManager = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager"); ActionsManager defaultActionsManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager; if (defaultActionsManager != null) { newActionsManager.defaultClass = defaultActionsManager.defaultClass; newActionsManager.defaultClassName = defaultActionsManager.defaultClassName; } references.actionsManager = newActionsManager; AdventureCreator.RefreshActions(); ShowProgress(0.3f); VariablesManager newVariablesManager = CustomAssetUtility.CreateAsset <VariablesManager> ("VariablesManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager"); references.variablesManager = newVariablesManager; ShowProgress(0.4f); InventoryManager newInventoryManager = CustomAssetUtility.CreateAsset <InventoryManager> ("InventoryManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager"); references.inventoryManager = newInventoryManager; ShowProgress(0.5f); SpeechManager newSpeechManager = CustomAssetUtility.CreateAsset <SpeechManager> ("SpeechManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager"); newSpeechManager.ClearLanguages(); references.speechManager = newSpeechManager; ShowProgress(0.6f); CursorManager newCursorManager = CustomAssetUtility.CreateAsset <CursorManager> ("CursorManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager"); references.cursorManager = newCursorManager; ShowProgress(0.7f); MenuManager newMenuManager = CustomAssetUtility.CreateAsset <MenuManager> ("MenuManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager"); references.menuManager = (MenuManager)newMenuManager; CursorManager defaultCursorManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_CursorManager.asset", typeof(CursorManager)) as CursorManager; if (wizardMenu == WizardMenu.Blank) { if (defaultCursorManager != null) { CursorIcon useIcon = new CursorIcon(); useIcon.Copy(defaultCursorManager.cursorIcons[0], false); newCursorManager.cursorIcons.Add(useIcon); EditorUtility.SetDirty(newCursorManager); } } else { if (defaultCursorManager != null) { foreach (CursorIcon defaultIcon in defaultCursorManager.cursorIcons) { CursorIcon newIcon = new CursorIcon(); newIcon.Copy(defaultIcon, false); newCursorManager.cursorIcons.Add(newIcon); } CursorIconBase pointerIcon = new CursorIconBase(); pointerIcon.Copy(defaultCursorManager.pointerIcon); newCursorManager.pointerIcon = pointerIcon; newCursorManager.lookCursor_ID = defaultCursorManager.lookCursor_ID; } else { ACDebug.LogWarning("Cannot find Default_CursorManager asset to copy from!"); } newCursorManager.allowMainCursor = true; EditorUtility.SetDirty(newCursorManager); MenuManager defaultMenuManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_MenuManager.asset", typeof(MenuManager)) as MenuManager; if (defaultMenuManager != null) { #if UNITY_EDITOR newMenuManager.drawOutlines = defaultMenuManager.drawOutlines; newMenuManager.drawInEditor = defaultMenuManager.drawInEditor; #endif newMenuManager.pauseTexture = defaultMenuManager.pauseTexture; if (wizardMenu != WizardMenu.Blank) { System.IO.Directory.CreateDirectory(Application.dataPath + "/" + gameName + "/UI"); } foreach (Menu defaultMenu in defaultMenuManager.menus) { float progress = (float)defaultMenuManager.menus.IndexOf(defaultMenu) / (float)defaultMenuManager.menus.Count; ShowProgress((progress * 0.3f) + 0.7f); Menu newMenu = ScriptableObject.CreateInstance <Menu>(); newMenu.Copy(defaultMenu, true, true); newMenu.Recalculate(); if (wizardMenu == WizardMenu.DefaultAC) { newMenu.menuSource = MenuSource.AdventureCreator; } else if (wizardMenu == WizardMenu.DefaultUnityUI) { newMenu.menuSource = MenuSource.UnityUiPrefab; } if (newMenu.pauseWhenEnabled) { bool autoSelectUI = (inputMethod == InputMethod.KeyboardOrController); newMenu.autoSelectFirstVisibleElement = autoSelectUI; } if (defaultMenu.canvas) { string oldPath = AssetDatabase.GetAssetPath(defaultMenu.canvas.gameObject); string newPath = "Assets/" + gameName + "/UI/" + defaultMenu.canvas.name + ".prefab"; if (AssetDatabase.CopyAsset(oldPath, newPath)) { AssetDatabase.ImportAsset(newPath); GameObject canvasObNewPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(newPath, typeof(GameObject)); newMenu.canvas = canvasObNewPrefab.GetComponent <Canvas>(); } else { newMenu.canvas = null; ACDebug.LogWarning("Could not copy asset " + oldPath + " to " + newPath, defaultMenu.canvas.gameObject); } newMenu.rectTransform = null; } foreach (MenuElement newElement in newMenu.elements) { if (newElement != null) { AssetDatabase.AddObjectToAsset(newElement, newMenuManager); newElement.hideFlags = HideFlags.HideInHierarchy; } else { ACDebug.LogWarning("Null element found in " + newMenu.title + " - the interface may not be set up correctly."); } } if (newMenu != null) { AssetDatabase.AddObjectToAsset(newMenu, newMenuManager); newMenu.hideFlags = HideFlags.HideInHierarchy; newMenuManager.menus.Add(newMenu); } else { ACDebug.LogWarning("Unable to create new Menu from original '" + defaultMenu.title + "'"); } } EditorUtility.SetDirty(newMenuManager); if (newSpeechManager != null) { newSpeechManager.previewMenuName = "Subtitles"; EditorUtility.SetDirty(newSpeechManager); } } else { ACDebug.LogWarning("Cannot find Default_MenuManager asset to copy from!"); } } EditorUtility.ClearProgressBar(); ManagerPackage newManagerPackage = CreateManagerPackage(gameName, newSceneManager, newSettingsManager, newActionsManager, newVariablesManager, newInventoryManager, newSpeechManager, newCursorManager, newMenuManager); AssetDatabase.SaveAssets(); if (newManagerPackage == null || !newManagerPackage.IsFullyAssigned()) { EditorUtility.DisplayDialog("Wizard failed", "The New Game Wizard failed to generate a new 'Manager Package' file with all eight Managers assigned. Check your '/Assets/" + gameName + "/Managers' directory - the Managers may have been created, and just need assigning in the ManagerPackage asset Inspector, found in '/Assets/" + gameName + "'.", "OK"); } else if (GameObject.FindObjectOfType <KickStarter>() == null) { bool initScene = EditorUtility.DisplayDialog("Organise scene?", "Process complete. Would you like to organise the scene objects to begin working? This can be done at any time within the Scene Manager.", "Yes", "No"); if (initScene) { newSceneManager.InitialiseObjects(); } } } catch (System.Exception e) { ACDebug.LogWarning("Could not create Manager. Does the subdirectory " + managerPath + " exist?"); Debug.LogException(e, this); pageNumber--; } }
public string GetHotspotLabel(int languageNumber) { return(SpeechManager.GetTranslation(hotspotLabel, hotspotLabelID, languageNumber)); }
/** * Displays the GUI of the class's entry within the Speech Manager. */ public void ShowGUI() { SpeechManager speechManager = AdvGame.GetReferences().speechManager; if (this == speechManager.activeLine) { EditorGUILayout.BeginVertical("Button"); ShowField("ID #:", lineID.ToString(), false); ShowField("Type:", textType.ToString(), false); ShowField("Original text:", text, true); string sceneName = scene.Replace("Assets/", ""); sceneName = sceneName.Replace(".unity", ""); ShowField("Scene:", sceneName, true); if (textType == AC_TextType.Speech) { ShowField("Speaker:", GetSpeakerName(), false); } if (speechManager.languages != null && speechManager.languages.Count > 1) { for (int i = 0; i < speechManager.languages.Count; i++) { if (i == 0) { } else if (translationText.Count > (i - 1)) { translationText [i - 1] = EditField(speechManager.languages[i] + ":", translationText [i - 1], true); } else { ShowField(speechManager.languages[i] + ":", "(Not defined)", false); } if (speechManager.translateAudio && textType == AC_TextType.Speech) { string language = ""; if (i > 0) { language = speechManager.languages[i]; } if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField(" (Lipsync path):", GetFolderName(language, true), false); } ShowField(" (Audio path):", GetFolderName(language), false); } else { if (i > 0) { SetCustomArraySizes(speechManager.languages.Count - 1); if (speechManager.UseFileBasedLipSyncing()) { customTranslationLipsyncFiles[i - 1] = (TextAsset)EditorGUILayout.ObjectField("Lipsync file:", customTranslationLipsyncFiles[i - 1], typeof(TextAsset), false); } customTranslationAudioClips[i - 1] = (AudioClip)EditorGUILayout.ObjectField("Audio clip:", customTranslationAudioClips[i - 1], typeof(AudioClip), false); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = (TextAsset)EditorGUILayout.ObjectField("Lipsync file:", customLipsyncFile, typeof(TextAsset), false); } customAudioClip = (AudioClip)EditorGUILayout.ObjectField("Audio clip:", customAudioClip, typeof(AudioClip), false); } } EditorGUILayout.Space(); } } if (!speechManager.translateAudio && textType == AC_TextType.Speech) { if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio path:", GetFolderName(""), false); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = (TextAsset)EditorGUILayout.ObjectField("Lipsync file:", customLipsyncFile, typeof(TextAsset), false); } customAudioClip = (AudioClip)EditorGUILayout.ObjectField("Audio clip:", customAudioClip, typeof(AudioClip), false); } } } else if (textType == AC_TextType.Speech) { ShowField("Text:", "'" + text + "'", true); if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio Path:", GetFolderName(""), false); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = (TextAsset)EditorGUILayout.ObjectField("Lipsync file:", customLipsyncFile, typeof(TextAsset), false); } customAudioClip = (AudioClip)EditorGUILayout.ObjectField("Audio clip:", customAudioClip, typeof(AudioClip), false); } } if (textType == AC_TextType.Speech) { if (speechManager.autoNameSpeechFiles) { ShowField("Filename:", GetFilename() + lineID.ToString(), false); } /*else * { * customAudioClip = (AudioClip) EditorGUILayout.ObjectField ("Audio clip:", customAudioClip, typeof (AudioClip), false); * }*/ description = EditField("Description:", description, true); } EditorGUILayout.EndVertical(); } else { if (GUILayout.Button(lineID.ToString() + ": '" + text + "'", EditorStyles.label, GUILayout.MaxWidth(300))) { speechManager.activeLine = this; } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } }
// Use this for initialization void Start() { speechManager = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<SpeechManager>(); }
public void OnAwake() { ClearVariables(); // Test for key imports References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; if (sceneManager == null) { ACDebug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard"); } if (settingsManager == null) { ACDebug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard"); } else { if (settingsManager.IsInLoadingScene()) { ACDebug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene."); SetPersistentEngine(); return; } if (!GameObject.FindGameObjectWithTag(Tags.player)) { KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity); } else { KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>(); if (sceneChanger == null || sceneChanger.GetPlayerOnTransition() == null) { // New local player if (KickStarter.playerPrefab != null) { KickStarter.playerPrefab.Initialise(); } } AssignLocalPlayer(); } } if (actionsManager == null) { ACDebug.LogError("No Actions Manager found - please set one using the main Adventure Creator window"); } if (inventoryManager == null) { ACDebug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window"); } if (variablesManager == null) { ACDebug.LogError("No Variables Manager found - please set one using the main Adventure Creator window"); } if (speechManager == null) { ACDebug.LogError("No Speech Manager found - please set one using the main Adventure Creator window"); } if (cursorManager == null) { ACDebug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window"); } if (menuManager == null) { ACDebug.LogError("No Menu Manager found - please set one using the main Adventure Creator window"); } if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None) { ACDebug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder"); } } else { ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window"); } SetPersistentEngine(); if (persistentEnginePrefab == null) { ACDebug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine"); } else { if (persistentEnginePrefab.GetComponent <Options>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no Options component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached."); } if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached."); } if (persistentEnginePrefab.GetComponent <StateHandler>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached."); } if (persistentEnginePrefab.GetComponent <SceneChanger>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached."); } if (persistentEnginePrefab.GetComponent <SaveSystem>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached."); } if (persistentEnginePrefab.GetComponent <LevelStorage>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeLanguages>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeLanguages component attached."); } } if (GameObject.FindWithTag(Tags.mainCamera) == null) { ACDebug.LogWarning("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one."); } else { if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null && GameObject.FindWithTag(Tags.mainCamera).GetComponentInParent <MainCamera>() == null) { ACDebug.LogError("MainCamera has no MainCamera component."); } } if (this.GetComponent <MenuSystem>() == null) { ACDebug.LogError(this.name + " has no MenuSystem component attached."); } if (this.GetComponent <Dialog>() == null) { ACDebug.LogError(this.name + " has no Dialog component attached."); } if (this.GetComponent <PlayerInput>() == null) { ACDebug.LogError(this.name + " has no PlayerInput component attached."); } if (this.GetComponent <PlayerInteraction>() == null) { ACDebug.LogError(this.name + " has no PlayerInteraction component attached."); } if (this.GetComponent <PlayerMovement>() == null) { ACDebug.LogError(this.name + " has no PlayerMovement component attached."); } if (this.GetComponent <PlayerCursor>() == null) { ACDebug.LogError(this.name + " has no PlayerCursor component attached."); } if (this.GetComponent <PlayerQTE>() == null) { ACDebug.LogError(this.name + " has no PlayerQTE component attached."); } if (this.GetComponent <SceneSettings>() == null) { ACDebug.LogError(this.name + " has no SceneSettings component attached."); } else { if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null) { // No NavMesh, are there Characters in the scene? AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[]; if (allChars.Length > 0) { ACDebug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager."); } } if (this.GetComponent <SceneSettings>().defaultPlayerStart == null) { if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.GetDefaultPlayer() != null) { ACDebug.LogWarning("No default PlayerStart set. The game may not be able to begin if one is not defined - please choose one using the Scene Manager."); } } } if (this.GetComponent <NavigationManager>() == null) { ACDebug.LogError(this.name + " has no NavigationManager component attached."); } if (this.GetComponent <ActionListManager>() == null) { ACDebug.LogError(this.name + " has no ActionListManager component attached."); } }
/// <summary> /// This method is called when the app first appears, but it also checks if it has been launched /// using Cortana's voice commands, and takes appropriate action if this is the case. /// </summary> protected async override void OnNavigatedTo(NavigationEventArgs e) { _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; _presence = new UserPresence(_dispatcher, _unfilteredName); _pageParameters = e.Parameter as VoiceCommandObjects.VoiceCommand; if (_pageParameters != null) { switch(_pageParameters.VoiceCommandName) { case "addNewNote": _activeNote = CreateNote(App.EVERYONE); break; case "addNewNoteForPerson": _activeNote = CreateNote(_pageParameters.NoteOwner); break; default: break; } } //Perform initialization for facial detection. if (AppSettings.FaceApiKey != "") { await FacialSimilarity.TrainDetectionAsync(); } // Perform initialization for speech recognition. _speechManager = new SpeechManager(FamilyModel); _speechManager.PhraseRecognized += speechManager_PhraseRecognized; _speechManager.StateChanged += speechManager_StateChanged; await _speechManager.StartContinuousRecognition(); }
override public float Run() { dialog = GameObject.FindWithTag(Tags.gameEngine).GetComponent <Dialog>(); stateHandler = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <StateHandler>(); options = stateHandler.GetComponent <Options>(); if (dialog && stateHandler && options) { if (!isRunning) { isRunning = true; string _text = messageText; string _language = ""; if (options.optionsData.language > 0) { // Not in original language, so pull translation in from Speech Manager if (!speechManager) { speechManager = AdvGame.GetReferences().speechManager; } if (speechManager.GetLineByID(lineID) != null && speechManager.GetLineByID(lineID).translationText.Count > (options.optionsData.language - 1)) { _text = speechManager.GetLineByID(lineID).translationText [options.optionsData.language - 1]; _language = speechManager.languages[options.optionsData.language]; } } if (_text != "") { dialog.KillDialog(); if (isBackground) { stateHandler.gameState = GameState.Normal; } else { stateHandler.gameState = GameState.Cutscene; } if (isPlayer) { speaker = GameObject.FindWithTag(Tags.player).GetComponent <Player>(); } if (speaker) { dialog.StartDialog(speaker, _text, lineID, _language); if (headClip || mouthClip) { AdvGame.CleanUnusedClips(speaker.GetComponent <Animation>()); if (headClip) { AdvGame.PlayAnimClip(speaker.GetComponent <Animation>(), (int)AnimLayer.Head, headClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, speaker.neckBone); } if (mouthClip) { AdvGame.PlayAnimClip(speaker.GetComponent <Animation>(), (int)AnimLayer.Mouth, mouthClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, speaker.neckBone); } } } else { dialog.StartDialog(_text); } if (!isBackground) { return(defaultPauseTime); } } return(0f); } else { if (!dialog.isMessageAlive) { isRunning = false; stateHandler.gameState = GameState.Cutscene; return(0f); } else { return(defaultPauseTime); } } } return(0f); }
/** * Displays the GUI of the class's entry within the Speech Manager. */ public void ShowGUI() { SpeechManager speechManager = AdvGame.GetReferences().speechManager; string apiPrefix = "KickStarter.speechManager.GetLine (" + lineID + ")"; if (lineID == speechManager.activeLineID) { EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("ID #:", GUILayout.Width(85f)); EditorGUILayout.LabelField(lineID.ToString(), GUILayout.MaxWidth(570f)); if (textType == AC_TextType.Speech && GUILayout.Button("Locate source", GUILayout.MaxWidth(100))) { KickStarter.speechManager.LocateLine(this); } EditorGUILayout.EndHorizontal(); ShowField("Type:", textType.ToString(), false, apiPrefix + ".textType"); ShowField("Original text:", text, true, apiPrefix + ".text"); string sceneName = scene.Replace("Assets/", ""); sceneName = sceneName.Replace(".unity", ""); ShowField("Scene:", sceneName, true, apiPrefix + ".scene"); if (textType == AC_TextType.Speech) { ShowField("Speaker:", GetSpeakerName(), false, apiPrefix + ".owner"); } if (speechManager.languages != null && speechManager.languages.Count > 1) { for (int i = 0; i < speechManager.languages.Count; i++) { if (i == 0) { } else if (translationText.Count > (i - 1)) { translationText [i - 1] = EditField(speechManager.languages[i] + ":", translationText [i - 1], true); } else { ShowField(speechManager.languages[i] + ":", "(Not defined)", false); } if (speechManager.translateAudio && textType == AC_TextType.Speech) { string language = ""; if (i > 0) { language = speechManager.languages[i]; } if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField(" (Lipsync path):", GetFolderName(language, true), false); } ShowField(" (Audio path):", GetFolderName(language), false); } else { if (i > 0) { SetCustomArraySizes(speechManager.languages.Count - 1); if (speechManager.UseFileBasedLipSyncing()) { customTranslationLipsyncFiles[i - 1] = EditField <Object> ("Lipsync file:", customTranslationLipsyncFiles[i - 1], apiPrefix + ".customTranslationLipsyncFiles[i-1]"); } customTranslationAudioClips[i - 1] = EditField <AudioClip> ("Audio clip:", customTranslationAudioClips[i - 1], apiPrefix + ".customTranslationAudioClips[i-1]"); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } EditorGUILayout.Space(); } } if (!speechManager.translateAudio && textType == AC_TextType.Speech) { if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio path:", GetFolderName(""), false); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } } else if (textType == AC_TextType.Speech) { //ShowField ("Text:", "'" + text + "'", true); if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio Path:", GetFolderName(""), false); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } if (textType == AC_TextType.Speech) { if (speechManager.autoNameSpeechFiles) { ShowField("Filename:", GetFilename() + lineID.ToString(), false); } description = EditField("Description:", description, true, apiPrefix + ".description"); if (tagID >= 0 && KickStarter.speechManager.useSpeechTags) { SpeechTag speechTag = speechManager.GetSpeechTag(tagID); if (speechTag != null && speechTag.label.Length > 0) { ShowField("Tag: ", speechTag.label, false, apiPrefix + ".tagID"); } } } EditorGUILayout.EndVertical(); } else { if (GUILayout.Button(lineID.ToString() + ": '" + text + "'", EditorStyles.label, GUILayout.MaxWidth(300))) { speechManager.activeLineID = lineID; EditorGUIUtility.editingTextField = false; } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } }
// Use this for initialization void Start() { speechManager = GameObject.FindObjectOfType <SpeechManager>(); }
void Start() { // get references to the needed components manager = KinectManager.Instance; gestureManager = VisualGestureManager.Instance; speechManager = SpeechManager.Instance; // create lz4 compressor & decompressor decompressor = LZ4Sharp.LZ4DecompressorFactory.CreateNew(); compressor = LZ4Sharp.LZ4CompressorFactory.CreateNew(); try { if (serverHost != string.Empty && serverHost != "0.0.0.0" && serverPort != 0) { byte error = 0; clientConnId = NetworkTransport.Connect(clientHostId, serverHost, serverPort, 0, out error); //Debug.Log("Connect host " + clientHostId + ", client-conn: " + clientConnId); if (error == (byte)NetworkError.Ok) { Debug.Log("Connecting to the server - " + serverHost + ":" + serverPort); if (statusText) { statusText.text = "Connecting to the server..."; } } else { throw new UnityException("Error while connecting: " + (NetworkError)error); } } else if (broadcastPort > 0) { Debug.Log("Waiting for the server..."); if (statusText) { statusText.text = "Waiting for the server..."; } } else { Debug.Log("Server address and port are unknown. Cannot connect."); if (statusText) { statusText.text = "Server address and port are unknown. Cannot connect."; } } } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n" + ex.StackTrace); if (statusText) { statusText.text = ex.Message; } } }
private void OnEnable() { options = null; saveSystem = null; speechManager = null; }
void StartRecognizer() { try { if(debugText != null) debugText.guiText.text = "Please, wait..."; // initialize Kinect sensor as needed int rc = SpeechWrapper.InitKinectSensor(); if(rc != 0) { throw new Exception("Initialization of Kinect sensor failed"); } // Initialize the kinect speech wrapper string sCriteria = String.Format("Language={0:X};Kinect=True", LanguageCode); rc = SpeechWrapper.InitSpeechRecognizer(sCriteria, true, false); if (rc < 0) { throw new Exception(String.Format("Error initializing Kinect/SAPI: " + SpeechWrapper.GetSystemErrorMessage(rc))); } if(RequiredConfidence > 0) { SpeechWrapper.SetRequiredConfidence(RequiredConfidence); } if(GrammarFileName != string.Empty) { rc = SpeechWrapper.LoadSpeechGrammar(GrammarFileName, (short)LanguageCode); if (rc < 0) { throw new Exception(String.Format("Error loading grammar file " + GrammarFileName + ": hr=0x{0:X}", rc)); } } instance = this; sapiInitialized = true; DontDestroyOnLoad(gameObject); if(debugText != null) debugText.guiText.text = "Ready."; } catch(DllNotFoundException ex) { Debug.LogError(ex.ToString()); if(debugText != null) debugText.guiText.text = "Please check the Kinect and SAPI installations."; } catch (Exception ex) { Debug.LogError(ex.ToString()); if(debugText != null) debugText.guiText.text = ex.Message; } }
private void Start() { if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager) { speechManager = AdvGame.GetReferences().speechManager; } SetFontSize(); menus.Add(pauseMenu); menus.Add(optionsMenu); menus.Add(saveMenu); menus.Add(loadMenu); menus.Add(inventoryMenu); menus.Add(inGameMenu); menus.Add(conversationMenu); menus.Add(hotspotMenu); menus.Add(subsMenu); pauseMenu.Add(pause_ResumeButton); pauseMenu.Add(pause_OptionsButton); if (Application.platform != RuntimePlatform.OSXWebPlayer && Application.platform != RuntimePlatform.WindowsWebPlayer) { pauseMenu.Add(pause_SaveButton); pauseMenu.Add(pause_LoadButton); } pauseMenu.Add(pause_QuitButton); pauseMenu.SetBackground(backgroundTexture); pauseMenu.Centre(); optionsMenu.Add(options_Title); options_Speech.SetSliderTexture(sliderTexture); options_Music.SetSliderTexture(sliderTexture); options_Sfx.SetSliderTexture(sliderTexture); optionsMenu.Add(options_Speech); optionsMenu.Add(options_Music); optionsMenu.Add(options_Sfx); if (speechManager) { options_Language = new MenuCycle("Language", speechManager.languages.ToArray()); optionsMenu.Add(options_Language); if (speechManager.languages.Count == 1) { options_Language.isVisible = false; } } optionsMenu.Add(options_Subs); optionsMenu.Add(options_BackButton); optionsMenu.SetBackground(backgroundTexture); optionsMenu.Centre(); saveMenu.Add(save_Title); saveMenu.Add(save_SavesList); saveMenu.Add(save_NewButton); saveMenu.Add(save_BackButton); saveMenu.SetBackground(backgroundTexture); saveMenu.Centre(); loadMenu.Add(load_Title); loadMenu.Add(load_SavesList); loadMenu.Add(load_BackButton); loadMenu.SetBackground(backgroundTexture); loadMenu.Centre(); inventoryMenu.Add(inventory_Box); inventoryMenu.SetSize(new Vector2(1f, 0.12f)); inventoryMenu.Align(TextAnchor.UpperCenter); inventoryMenu.SetBackground(backgroundTexture); inGameMenu.Add(inGame_MenuButton); inGameMenu.Align(TextAnchor.LowerLeft); inGameMenu.SetBackground(backgroundTexture); conversationMenu.Add(dialog_Box); conversationMenu.Add(dialog_Timer); conversationMenu.SetCentre(new Vector2(0.25f, 0.72f)); dialog_Timer.SetSize(new Vector2(0.2f, 0.01f)); dialog_Timer.SetTimerTexture(sliderTexture); conversationMenu.SetBackground(backgroundTexture); subsMenu.Add(subs_Speaker); subsMenu.Add(subs_Line); subsMenu.SetBackground(backgroundTexture); subs_Line.SetAlignment(TextAnchor.UpperLeft); subsMenu.SetCentre(new Vector2(0.5f, 0.85f)); hotspotMenu.Add(hotspot_Label); if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsWebPlayer) { pause_QuitButton.isVisible = false; pauseMenu.AutoResize(); } SetStyles(); if (GameObject.FindWithTag(Tags.persistentEngine)) { if (GameObject.FindWithTag(Tags.persistentEngine).GetComponent <Options>()) { options = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <Options>(); } if (GameObject.FindWithTag(Tags.persistentEngine).GetComponent <SaveSystem>()) { saveSystem = GameObject.FindWithTag(Tags.persistentEngine).GetComponent <SaveSystem>(); } } }
void Start() { speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); intManager = GameObject.FindWithTag("kinect-interaction").GetComponent<InteractionManager>(); pMenu = GetComponent<MenuPause>(); opMenu = GetComponent<MenuOptions>(); }
protected bool TestManagerPresence() { References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; string missingManagers = string.Empty; if (sceneManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Scene"; } if (settingsManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Settings"; } if (actionsManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Actions"; } if (variablesManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Variables"; } if (inventoryManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Inventory"; } if (speechManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Speech"; } if (cursorManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Cursor"; } if (menuManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Menu"; } if (!string.IsNullOrEmpty(missingManagers)) { ACDebug.LogError("Unassigned AC Manager(s): " + missingManagers + " - all Managers must be assigned in the AC Game Editor window for AC to initialise"); return(false); } } else { ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window"); return(false); } return(true); }
private void OnGUI() { if (AdvGame.GetReferences().speechManager == null) { EditorGUILayout.HelpBox("A Settings Manager must be assigned before this window can display correctly.", MessageType.Warning); return; } SpeechManager speechManager = AdvGame.GetReferences().speechManager; EditorGUILayout.HelpBox("Assign any labels you want to be able to tag 'Dialogue: Play speech' Actions as here.", MessageType.Info); EditorGUILayout.Space(); speechManager.useSpeechTags = EditorGUILayout.Toggle("Use speech tags?", speechManager.useSpeechTags); if (speechManager.useSpeechTags) { EditorGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(205f)); if (speechManager.speechTags.Count == 0) { speechManager.speechTags.Add(new SpeechTag("(Untagged)")); } for (int i = 0; i < speechManager.speechTags.Count; i++) { EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); if (i == 0) { EditorGUILayout.TextField("Tag " + speechManager.speechTags[i].ID.ToString() + ": " + speechManager.speechTags[0].label, EditorStyles.boldLabel); } else { SpeechTag speechTag = speechManager.speechTags[i]; speechTag.label = EditorGUILayout.TextField("Tag " + speechManager.speechTags[i].ID.ToString() + ":", speechTag.label); speechManager.speechTags[i] = speechTag; if (GUILayout.Button("-", GUILayout.MaxWidth(20f))) { Undo.RecordObject(speechManager, "Delete tag"); speechManager.speechTags.RemoveAt(i); i = 0; return; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); if (GUILayout.Button("Add new tag")) { Undo.RecordObject(speechManager, "Delete tag"); speechManager.speechTags.Add(new SpeechTag(GetIDArray(speechManager.speechTags.ToArray()))); } } if (GUI.changed) { EditorUtility.SetDirty(speechManager); } }
void FixedUpdate () { // get the speech manager instance if(speechManager == null) { speechManager = SpeechManager.Instance; } if(speechManager != null && speechManager.IsSapiInitialized()) { if(speechManager.IsPhraseRecognized()) { string sPhraseTag = speechManager.GetPhraseTagRecognized(); switch(sPhraseTag) { case "FORWARD": walkSpeed = 0.2f; walkDirection = 0f; break; case "BACK": walkSpeed = -0.2f; walkDirection = 0f; break; case "LEFT": walkDirection = -0.2f; if(walkSpeed == 0f) walkSpeed = 0.2f; break; case "RIGHT": walkDirection = 0.2f; if(walkSpeed == 0f) walkSpeed = 0.2f; break; case "RUN": walkSpeed = 0.5f; walkDirection = 0f; break; case "STOP": walkSpeed = 0f; walkDirection = 0f; break; case "JUMP": jumpNow = true; walkSpeed = 0.5f; walkDirection = 0f; break; case "HELLO": waveNow = true; walkSpeed = 0.0f; walkDirection = 0f; break; } speechManager.ClearPhraseRecognized(); } } else { walkDirection = Input.GetAxis("Horizontal"); // setup h variable as our horizontal input axis walkSpeed = Input.GetAxis("Vertical"); // setup v variables as our vertical input axis jumpNow = Input.GetButtonDown("Jump"); waveNow = Input.GetButtonDown("Jump"); } anim.SetFloat("Speed", walkSpeed); // set our animator's float parameter 'Speed' equal to the vertical input axis anim.SetFloat("Direction", walkDirection); // set our animator's float parameter 'Direction' equal to the horizontal input axis anim.speed = animSpeed; // set the speed of our animator to the public variable 'animSpeed' //anim.SetLookAtWeight(lookWeight); // set the Look At Weight - amount to use look at IK vs using the head's animation currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // set our currentState variable to the current state of the Base Layer (0) of animation if(anim.layerCount == 2) { layer2CurrentState = anim.GetCurrentAnimatorStateInfo(1); // set our layer2CurrentState variable to the current state of the second Layer (1) of animation } // if we are currently in a state called Locomotion (see line 25), then allow Jump input (Space) to set the Jump bool parameter in the Animator to true if (currentBaseState.fullPathHash == locoState) { if(jumpNow) { jumpNow = false; anim.SetBool("Jump", true); } } // if we are in the jumping state... else if(currentBaseState.fullPathHash == jumpState) { // ..and not still in transition.. if(!anim.IsInTransition(0)) { if(useCurves) // ..set the collider height to a float curve in the clip called ColliderHeight col.height = anim.GetFloat("ColliderHeight"); // reset the Jump bool so we can jump again, and so that the state does not loop anim.SetBool("Jump", false); } // Raycast down from the center of the character.. Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up); RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(ray, out hitInfo)) { // ..if distance to the ground is more than 1.75, use Match Target if (hitInfo.distance > 1.75f) { // MatchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray. // Here we're telling the Root of the character to only be influenced on the Y axis (MatchTargetWeightMask) and only occur between 0.35 and 0.5 // of the timeline of our animation clip anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0, 1, 0), 0), 0.35f, 0.5f); } } } // check if we are at idle, if so, let us Wave! else if (currentBaseState.fullPathHash == idleState) { if(waveNow) { waveNow = false; anim.SetBool("Wave", true); } } // if we enter the waving state, reset the bool to let us wave again in future if(layer2CurrentState.fullPathHash == waveState) { anim.SetBool("Wave", false); } }
//----------------------------------- end of public functions --------------------------------------// void Start() { try { // get sensor data KinectManager kinectManager = KinectManager.Instance; if(kinectManager && kinectManager.IsInitialized()) { sensorData = kinectManager.GetSensorData(); } if(sensorData == null || sensorData.sensorInterface == null) { throw new Exception("Speech recognition cannot be started, because KinectManager is missing or not initialized."); } if(debugText != null) { debugText.GetComponent<GUIText>().text = "Please, wait..."; } // ensure the needed dlls are in place and speech recognition is available for this interface bool bNeedRestart = false; if(sensorData.sensorInterface.IsSpeechRecognitionAvailable(ref bNeedRestart)) { if(bNeedRestart) { KinectInterop.RestartLevel(gameObject, "SM"); return; } } else { string sInterfaceName = sensorData.sensorInterface.GetType().Name; throw new Exception(sInterfaceName + ": Speech recognition is not supported!"); } // Initialize the speech recognizer string sCriteria = String.Format("Language={0:X};Kinect=True", languageCode); int rc = sensorData.sensorInterface.InitSpeechRecognition(sCriteria, true, false); if (rc < 0) { string sErrorMessage = (new SpeechErrorHandler()).GetSapiErrorMessage(rc); throw new Exception(String.Format("Error initializing Kinect/SAPI: " + sErrorMessage)); } if(requiredConfidence > 0) { sensorData.sensorInterface.SetSpeechConfidence(requiredConfidence); } if(grammarFileName != string.Empty) { // copy the grammar file from Resources, if available if(!File.Exists(grammarFileName)) { TextAsset textRes = Resources.Load(grammarFileName, typeof(TextAsset)) as TextAsset; if(textRes != null) { string sResText = textRes.text; File.WriteAllText(grammarFileName, sResText); } } // load the grammar file rc = sensorData.sensorInterface.LoadSpeechGrammar(grammarFileName, (short)languageCode); if (rc < 0) { string sErrorMessage = (new SpeechErrorHandler()).GetSapiErrorMessage(rc); throw new Exception("Error loading grammar file " + grammarFileName + ": " + sErrorMessage); } } instance = this; sapiInitialized = true; //DontDestroyOnLoad(gameObject); if(debugText != null) { debugText.GetComponent<GUIText>().text = "Ready."; } } catch(DllNotFoundException ex) { Debug.LogError(ex.ToString()); if(debugText != null) debugText.GetComponent<GUIText>().text = "Please check the Kinect and SAPI installations."; } catch (Exception ex) { Debug.LogError(ex.ToString()); if(debugText != null) debugText.GetComponent<GUIText>().text = ex.Message; } }
void Start() { speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); intManager = GameObject.FindWithTag("kinect-interaction").GetComponent<InteractionManager>(); hud = GameObject.FindWithTag("hud").GetComponent<HudController>(); }
/** * <summary>Combines the class's various fields into a formatted HTML string, for display in exported game text.</summary> * <param name = "languageIndex">The index number of the language to display fields for, where 0 = the game's original language</param> * <param name = "includeDescriptions">If True, its description will also be included</param> * <param name = "removeTokens">If True, text tokens such as [wait] within the text will be removed</param> * <returns>A string of the owner, filename, text and description</returns> */ public string Print(int languageIndex = 0, bool includeDescriptions = false, bool removeTokens = false) { int i = languageIndex; string result = "<table>\n"; result += "<tr><td><b>Line ID:</b></td><td>" + lineID + "</td></tr>\n"; result += "<tr><td width=150><b>Character:</b></td><td>" + GetSpeakerName() + "</td></tr>\n"; string lineText = text; if (i > 0 && translationText.Count > (i - 1)) { lineText = translationText [i - 1]; } if (removeTokens) { Speech tempSpeech = new Speech(lineText); lineText = tempSpeech.displayText; } result += "<tr><td><b>Line text:</b></td><td>" + lineText + "</td></tr>\n"; if (description != null && description.Length > 0 && includeDescriptions) { result += "<tr><td><b>Description:</b></td><td>" + description + "</td></tr>\n"; } string language = ""; SpeechManager speechManager = AdvGame.GetReferences().speechManager; if (i > 0 && speechManager.translateAudio) { language = AdvGame.GetReferences().speechManager.languages[i]; } if (speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { result += "<td><b>Lipsync file:</b></td><td>" + GetFolderName(language, true) + GetFilename() + lineID.ToString() + "</td></tr>\n"; } result += "<tr><td><b>Audio file:</b></td><td>" + GetFolderName(language, false) + GetFilename() + lineID.ToString() + "</td></tr>\n"; } else { if (speechManager.UseFileBasedLipSyncing() && customLipsyncFile != null) { result += "<td><b>Lipsync file:</b></td><td>" + customLipsyncFile.name + "</td></tr>\n"; } if (customAudioClip != null) { result += "<tr><td><b>Audio file:</b></td><td>" + customAudioClip.name + "</td></tr>\n"; } } result += "</table>\n\n"; result += "<br/>\n"; return(result); }
void Update() { if (speechManager == null) { speechManager = SpeechManager.Instance; } if (speechManager != null && speechManager.IsSapiInitialized()) { if (speechManager.IsPhraseRecognized()) { string sPhraseTag = speechManager.GetPhraseTagRecognized(); switch (sPhraseTag) { case "RECORD": if (saverPlayer) { saverPlayer.StartRecording(); } break; case "PLAY": if (saverPlayer) { saverPlayer.StartPlaying(); } break; case "STOP": if (saverPlayer) { saverPlayer.StopRecordingOrPlaying(); } break; } speechManager.ClearPhraseRecognized(); } } // alternatively, use the keyboard if (Input.GetButtonDown("Jump")) // start or stop recording { if (saverPlayer) { if (!saverPlayer.IsRecording()) { saverPlayer.StartRecording(); } else { saverPlayer.StopRecordingOrPlaying(); } } } if (Input.GetButtonDown("Fire1")) // start or stop playing { if (saverPlayer) { if (!saverPlayer.IsPlaying()) { saverPlayer.StartPlaying(); } else { saverPlayer.StopRecordingOrPlaying(); } } } }
// Update is called once per frame. void Update() { // Access the ThalmicMyo component attached to the Myo object. ThalmicMyo thalmicMyo = myo.GetComponent<ThalmicMyo> (); // Update references when the pose becomes fingers spread or the q key is pressed. updateReference = false; if (thalmicMyo.pose != _lastPose) { _lastPose = thalmicMyo.pose; if (thalmicMyo.pose == Pose.FingersSpread) { updateReference = true; ExtendUnlockAndNotifyUserAction(thalmicMyo); } } //get speechManager instance if (speech == null) speech = SpeechManager.Instance; if (dragging == null) dragging = DraggingBehaviour.Instance; if (speech != null && speech.IsSapiInitialized()) { if (speech.IsPhraseRecognized()) { switch (speech.GetPhraseTagRecognized()) { case "RESET": updateReference = true; ExtendUnlockAndNotifyUserAction(thalmicMyo); break; case "KINECT": dragging.bothEnabled = false; dragging.kinectEnabled = true; break; case "MYO": dragging.bothEnabled = false; dragging.kinectEnabled = false; ExtendUnlockAndNotifyUserAction(thalmicMyo); break; case "BOTH": dragging.bothEnabled = true; break; default: break; } speech.ClearPhraseRecognized(); } } if (Input.GetKeyDown ("r")) { updateReference = true; } // Update references. This anchors the joint on-screen such that it faces forward away // from the viewer when the Myo armband is oriented the way it is when these references are taken. if (updateReference) { // _antiYaw represents a rotation of the Myo armband about the Y axis (up) which aligns the forward // vector of the rotation with Z = 1 when the wearer's arm is pointing in the reference direction. _antiYaw = Quaternion.FromToRotation ( new Vector3 (myo.transform.forward.x, 0, myo.transform.forward.z), new Vector3 (0, 0, 1) ); // _referenceRoll represents how many degrees the Myo armband is rotated clockwise // about its forward axis (when looking down the wearer's arm towards their hand) from the reference zero // roll direction. This direction is calculated and explained below. When this reference is // taken, the joint will be rotated about its forward axis such that it faces upwards when // the roll value matches the reference. Vector3 referenceZeroRoll = computeZeroRollVector (myo.transform.forward); _referenceRoll = rollFromZero (referenceZeroRoll, myo.transform.forward, myo.transform.up); } // Current zero roll vector and roll value. Vector3 zeroRoll = computeZeroRollVector (myo.transform.forward); float roll = rollFromZero (zeroRoll, myo.transform.forward, myo.transform.up); // The relative roll is simply how much the current roll has changed relative to the reference roll. // adjustAngle simply keeps the resultant value within -180 to 180 degrees. float relativeRoll = normalizeAngle (roll - _referenceRoll); // antiRoll represents a rotation about the myo Armband's forward axis adjusting for reference roll. Quaternion antiRoll = Quaternion.AngleAxis (relativeRoll, myo.transform.forward); // Here the anti-roll and yaw rotations are applied to the myo Armband's forward direction to yield // the orientation of the joint. quatRotation = _antiYaw * antiRoll * Quaternion.LookRotation (myo.transform.forward); transform.rotation = quatRotation; // The above calculations were done assuming the Myo armbands's +x direction, in its own coordinate system, // was facing toward the wearer's elbow. If the Myo armband is worn with its +x direction facing the other way, // the rotation needs to be updated to compensate. if (thalmicMyo.xDirection == Thalmic.Myo.XDirection.TowardWrist) { // Mirror the rotation around the XZ plane in Unity's coordinate system (XY plane in Myo's coordinate // system). This makes the rotation reflect the arm's orientation, rather than that of the Myo armband. quatRotation = new Quaternion(transform.localRotation.x, -transform.localRotation.y, transform.localRotation.z, -transform.localRotation.w); transform.rotation = quatRotation; } }
private void speak(string text) { SpeechManager.SpeakAsync(text); }
void Update() { int recHostId; int connectionId; int recChannelId; int dataSize; bool connListUpdated = false; if (backgroundImage && backgroundImage.texture == null) { backgroundImage.texture = manager ? manager.GetUsersLblTex() : null; } // if(faceManager == null) // { // faceManager = FacetrackingManager.Instance; // } if (gestureManager == null) { gestureManager = VisualGestureManager.Instance; } if (speechManager == null) { speechManager = SpeechManager.Instance; } try { byte error = 0; NetworkEventType recData = NetworkTransport.Receive(out recHostId, out connectionId, out recChannelId, recBuffer, bufferSize, out dataSize, out error); switch (recData) { case NetworkEventType.Nothing: //1 break; case NetworkEventType.ConnectEvent: //2 if (recHostId == serverHostId && recChannelId == serverChannelId && !dictConnection.ContainsKey(connectionId)) { HostConnection conn = new HostConnection(); conn.hostId = recHostId; conn.connectionId = connectionId; conn.channelId = recChannelId; conn.keepAlive = true; conn.reqDataType = "ka,kb,km,kh"; //conn.matrixSent = false; dictConnection[connectionId] = conn; connListUpdated = true; //Debug.Log(connectionId + "-conn: " + conn.reqDataType); } // // reset chunked face messages // sendFvMsg = string.Empty; // sendFvNextOfs = 0; // // sendFtMsg = string.Empty; // sendFtNextOfs = 0; break; case NetworkEventType.DataEvent: //3 if (recHostId == serverHostId && recChannelId == serverChannelId && dictConnection.ContainsKey(connectionId)) { HostConnection conn = dictConnection[connectionId]; int decompSize = 0; if (decompressor != null && (recBuffer[0] > 127 || recBuffer[0] < 32)) { decompSize = decompressor.Decompress(recBuffer, 0, compressBuffer, 0, dataSize); } else { System.Buffer.BlockCopy(recBuffer, 0, compressBuffer, 0, dataSize); decompSize = dataSize; } string sRecvMessage = System.Text.Encoding.UTF8.GetString(compressBuffer, 0, decompSize); if (sRecvMessage.StartsWith("ka")) { if (sRecvMessage == "ka") // vr-examples v1.0 keep-alive message { sRecvMessage = "ka,kb,km,kh"; } conn.keepAlive = true; conn.reqDataType = sRecvMessage; dictConnection[connectionId] = conn; //Debug.Log(connectionId + "-recv: " + conn.reqDataType); // check for SR phrase-reset int iIndexSR = sRecvMessage.IndexOf(",sr"); if (iIndexSR >= 0 && speechManager) { speechManager.ClearPhraseRecognized(); //Debug.Log("phrase cleared"); } } } break; case NetworkEventType.DisconnectEvent: //4 if (dictConnection.ContainsKey(connectionId)) { dictConnection.Remove(connectionId); connListUpdated = true; } break; } if (connListUpdated) { // get all connection IDs alConnectionId.Clear(); alConnectionId.AddRange(dictConnection.Keys); // display the number of connections StringBuilder sbConnStatus = new StringBuilder(); sbConnStatus.AppendFormat("Server running: {0} connection(s)", dictConnection.Count); foreach (int connId in dictConnection.Keys) { HostConnection conn = dictConnection[connId]; int iPort = 0; string sAddress = string.Empty; NetworkID network; NodeID destNode; NetworkTransport.GetConnectionInfo(conn.hostId, conn.connectionId, out sAddress, out iPort, out network, out destNode, out error); if (error == (int)NetworkError.Ok) { sbConnStatus.AppendLine().Append(" ").Append(sAddress).Append(":").Append(iPort); } } Debug.Log(sbConnStatus); if (connStatusText) { connStatusText.text = sbConnStatus.ToString(); } } // send body frame to available connections const char delimiter = ','; string sBodyFrame = manager ? manager.GetBodyFrameData(ref liRelTime, ref fCurrentTime, delimiter) : string.Empty; if (sBodyFrame.Length > 0 && dictConnection.Count > 0) { StringBuilder sbSendMessage = new StringBuilder(); sbSendMessage.Append(manager.GetWorldMatrixData(delimiter)).Append('|'); sbSendMessage.Append(sBodyFrame).Append('|'); sbSendMessage.Append(manager.GetBodyHandData(ref liRelTime, delimiter)).Append('|'); if (gestureManager && gestureManager.IsVisualGestureInitialized()) { sbSendMessage.Append(gestureManager.GetGestureDataAsCsv(delimiter)).Append('|'); } if (speechManager && speechManager.IsSapiInitialized()) { sbSendMessage.Append(speechManager.GetSpeechDataAsCsv(delimiter)).Append('|'); } if (sbSendMessage.Length > 0 && sbSendMessage[sbSendMessage.Length - 1] == '|') { sbSendMessage.Remove(sbSendMessage.Length - 1, 1); } byte[] btSendMessage = System.Text.Encoding.UTF8.GetBytes(sbSendMessage.ToString()); int compSize = 0; if (compressor != null && btSendMessage.Length > 100) { compSize = compressor.Compress(btSendMessage, 0, btSendMessage.Length, compressBuffer, 0); } else { System.Buffer.BlockCopy(btSendMessage, 0, compressBuffer, 0, btSendMessage.Length); compSize = btSendMessage.Length; } // // check face-tracking requests // bool bFaceParams = false, bFaceVertices = false, bFaceUvs = false, bFaceTriangles = false; // if(faceManager && faceManager.IsFaceTrackingInitialized()) // CheckFacetrackRequests(out bFaceParams, out bFaceVertices, out bFaceUvs, out bFaceTriangles); // // byte[] btFaceParams = null; // if(bFaceParams) // { // string sFaceParams = faceManager.GetFaceParamsAsCsv(); // if(!string.IsNullOrEmpty(sFaceParams)) // btFaceParams = System.Text.Encoding.UTF8.GetBytes(sFaceParams); // } // // // next chunk of data for face vertices // byte[] btFaceVertices = null; // string sFvMsgHead = string.Empty; // GetNextFaceVertsChunk(bFaceVertices, bFaceUvs, ref btFaceVertices, out sFvMsgHead); // // // next chunk of data for face triangles // byte[] btFaceTriangles = null; // string sFtMsgHead = string.Empty; // GetNextFaceTrisChunk(bFaceTriangles, ref btFaceTriangles, out sFtMsgHead); foreach (int connId in alConnectionId) { HostConnection conn = dictConnection[connId]; if (conn.keepAlive) { conn.keepAlive = false; dictConnection[connId] = conn; if (conn.reqDataType != null && conn.reqDataType.Contains("kb,")) { //Debug.Log(conn.connectionId + "-sendkb: " + conn.reqDataType); error = 0; //if(!NetworkTransport.Send(conn.hostId, conn.connectionId, conn.channelId, btSendMessage, btSendMessage.Length, out error)) if (!NetworkTransport.Send(conn.hostId, conn.connectionId, conn.channelId, compressBuffer, compSize, out error)) { string sMessage = "Error sending body data via conn " + conn.connectionId + ": " + (NetworkError)error; Debug.LogError(sMessage); if (serverStatusText) { serverStatusText.text = sMessage; } } } // if(bFaceParams && btFaceParams != null && // conn.reqDataType != null && conn.reqDataType.Contains("fp,")) // { // //Debug.Log(conn.connectionId + "-sendfp: " + conn.reqDataType); // // error = 0; // if(!NetworkTransport.Send(conn.hostId, conn.connectionId, conn.channelId, btFaceParams, btFaceParams.Length, out error)) // { // string sMessage = "Error sending face params via conn " + conn.connectionId + ": " + (NetworkError)error; // Debug.LogError(sMessage); // // if(serverStatusText) // { // serverStatusText.text = sMessage; // } // } // } // // if(bFaceVertices && btFaceVertices != null && // conn.reqDataType != null && conn.reqDataType.Contains("fv,")) // { // //Debug.Log(conn.connectionId + "-sendfv: " + conn.reqDataType + " - " + sFvMsgHead); // // error = 0; // if(!NetworkTransport.Send(conn.hostId, conn.connectionId, conn.channelId, btFaceVertices, btFaceVertices.Length, out error)) // { // string sMessage = "Error sending face verts via conn " + conn.connectionId + ": " + (NetworkError)error; // Debug.LogError(sMessage); // // if(serverStatusText) // { // serverStatusText.text = sMessage; // } // } // } // // if(bFaceTriangles && btFaceTriangles != null && // conn.reqDataType != null && conn.reqDataType.Contains("ft,")) // { // //Debug.Log(conn.connectionId + "-sendft: " + conn.reqDataType + " - " + sFtMsgHead); // // error = 0; // if(!NetworkTransport.Send(conn.hostId, conn.connectionId, conn.channelId, btFaceTriangles, btFaceTriangles.Length, out error)) // { // string sMessage = "Error sending face tris via conn " + conn.connectionId + ": " + (NetworkError)error; // Debug.LogError(sMessage); // // if(serverStatusText) // { // serverStatusText.text = sMessage; // } // } // } } } } } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n" + ex.StackTrace); if (serverStatusText) { serverStatusText.text = ex.Message; } } }
protected string TranslateLabel(string label, int languageNumber) { return(SpeechManager.GetTranslation(label, lineID, languageNumber)); }
private void CreateScript() { #if UNITY_WEBPLAYER ACDebug.LogWarning("Game text cannot be exported in WebPlayer mode - please switch platform and try again."); #else if (AdvGame.GetReferences() == null || AdvGame.GetReferences().speechManager == null) { ACDebug.LogError("Cannot create script sheet - no Speech Manager is assigned!"); return; } SpeechManager speechManager = AdvGame.GetReferences().speechManager; languageIndex = Mathf.Max(languageIndex, 0); string suggestedFilename = "Adventure Creator"; if (AdvGame.GetReferences().settingsManager) { suggestedFilename = AdvGame.GetReferences().settingsManager.saveFileName; } if (limitToCharacter && characterName != "") { suggestedFilename += " (" + characterName + ")"; } if (limitToTag && tagID >= 0) { SpeechTag speechTag = speechManager.GetSpeechTag(tagID); if (speechTag != null && speechTag.label.Length > 0) { suggestedFilename += " (" + speechTag.label + ")"; } } suggestedFilename += " - "; if (languageIndex > 0) { suggestedFilename += speechManager.languages[languageIndex] + " "; } suggestedFilename += "script.html"; string fileName = EditorUtility.SaveFilePanel("Save script file", "Assets", suggestedFilename, "html"); if (fileName.Length == 0) { return; } string gameName = "Adventure Creator"; if (AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.saveFileName.Length > 0) { gameName = AdvGame.GetReferences().settingsManager.saveFileName; if (languageIndex > 0) { gameName += " (" + speechManager.languages[languageIndex] + ")"; } } System.Text.StringBuilder script = new System.Text.StringBuilder(); script.Append("<html>\n<head>\n"); script.Append("<meta http-equiv='Content-Type' content='text/html;charset=ISO-8859-1' charset='UTF-8'>\n"); script.Append("<title>" + gameName + "</title>\n"); script.Append("<style> body, table, div, p, dl { font: 400 14px/22px Roboto,sans-serif; } footer { text-align: center; padding-top: 20px; font-size: 12px;} footer a { color: blue; text-decoration: none} </style>\n</head>\n"); script.Append("<body>\n"); script.Append("<h1>" + gameName + " - script sheet"); if (limitToCharacter && characterName != "") { script.Append(" (" + characterName + ")"); } script.Append("</h1>\n"); script.Append("<h2>Created: " + DateTime.UtcNow.ToString("HH:mm dd MMMM, yyyy") + "</h2>\n"); // By scene foreach (string sceneFile in sceneFiles) { List <SpeechLine> sceneSpeechLines = new List <SpeechLine>(); int slashPoint = sceneFile.LastIndexOf("/") + 1; string sceneName = sceneFile.Substring(slashPoint); foreach (SpeechLine line in speechManager.lines) { if (line.textType == AC_TextType.Speech && (line.scene == sceneFile || sceneName == (line.scene + ".unity")) && (!limitToCharacter || characterName == "" || line.owner == characterName || (line.isPlayer && characterName == "Player")) && (!limitToTag || line.tagID == tagID)) { if (limitToMissingAudio && line.HasAudio(languageIndex)) { continue; } sceneSpeechLines.Add(line); } } if (sceneSpeechLines != null && sceneSpeechLines.Count > 0) { sceneSpeechLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.OrderIdentifier.CompareTo(b.OrderIdentifier)); }); script.Append("<hr/>\n<h3><b>Scene:</b> " + sceneName + "</h3>\n"); foreach (SpeechLine sceneSpeechLine in sceneSpeechLines) { script.Append(sceneSpeechLine.Print(languageIndex, includeDescriptions, removeTokens)); } } } // No scene List <SpeechLine> assetSpeechLines = new List <SpeechLine>(); foreach (SpeechLine line in speechManager.lines) { if (line.scene == "" && line.textType == AC_TextType.Speech && (!limitToCharacter || characterName == "" || line.owner == characterName || (line.isPlayer && characterName == "Player")) && (!limitToTag || line.tagID == tagID)) { if (limitToMissingAudio && line.HasAudio(languageIndex)) { continue; } assetSpeechLines.Add(line); } } if (assetSpeechLines != null && assetSpeechLines.Count > 0) { assetSpeechLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.OrderIdentifier.CompareTo(b.OrderIdentifier)); }); script.Append("<hr/>\n<h3>Scene-independent lines:</h3>\n"); foreach (SpeechLine assetSpeechLine in assetSpeechLines) { script.Append(assetSpeechLine.Print(languageIndex, includeDescriptions, removeTokens)); } } script.Append("<footer>Generated by <a href='http://adventurecreator.org' target=blank>Adventure Creator</a>, by Chris Burton</footer>\n"); script.Append("</body>\n</html>"); Serializer.SaveFile(fileName, script.ToString()); #endif this.Close(); }
public void ShowGUI() { SpeechManager speechManager = AdvGame.GetReferences().speechManager; if (this == speechManager.activeLine) { EditorGUILayout.BeginVertical("Button"); ShowField("ID #:", lineID.ToString(), false); ShowField("Type:", textType.ToString(), false); string sceneName = scene.Replace("Assets/", ""); sceneName = sceneName.Replace(".unity", ""); ShowField("Scene:", sceneName, true); if (textType == AC_TextType.Speech) { if (isPlayer) { if (KickStarter.speechManager && KickStarter.speechManager.usePlayerRealName) { ShowField("Speaker", owner, false); } else { ShowField("Speaker:", "Player", false); } } else { ShowField("Speaker:", owner, false); } } if (speechManager.languages != null && speechManager.languages.Count > 1) { for (int i = 0; i < speechManager.languages.Count; i++) { if (i == 0) { ShowField("Original:", "'" + text + "'", true); } else if (translationText.Count > (i - 1)) { ShowField(speechManager.languages[i] + ":", "'" + translationText [i - 1] + "'", true); } else { ShowField(speechManager.languages[i] + ":", "(Not defined)", false); } if (speechManager.translateAudio && textType == AC_TextType.Speech) { if (i == 0) { if (speechManager.UseFileBasedLipSyncing()) { ShowField(" (Lipsync path):", GetFolderName("", true), false); } ShowField(" (Audio path):", GetFolderName(""), false); } else { if (speechManager.UseFileBasedLipSyncing()) { ShowField(" (Lipsync path):", GetFolderName(speechManager.languages[i], true), false); } ShowField(" (Audio path):", GetFolderName(speechManager.languages[i]), false); } EditorGUILayout.Space(); } } if (!speechManager.translateAudio && textType == AC_TextType.Speech) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio path:", GetFolderName(""), false); } } else if (textType == AC_TextType.Speech) { ShowField("Text:", "'" + text + "'", true); if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio Path:", GetFolderName(""), false); } if (textType == AC_TextType.Speech) { ShowField("Filename:", GetFilename() + lineID.ToString(), false); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Description:", GUILayout.Width(65f)); description = EditorGUILayout.TextField(description); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } else { if (GUILayout.Button(lineID.ToString() + ": '" + text + "'", EditorStyles.label, GUILayout.MaxWidth(300))) { speechManager.activeLine = this; } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } }
void FixedUpdate() { // get the speech manager instance if (speechManager == null) { speechManager = SpeechManager.Instance; } if (speechManager != null && speechManager.IsSapiInitialized()) { if (speechManager.IsPhraseRecognized()) { string sPhraseTag = speechManager.GetPhraseTagRecognized(); switch (sPhraseTag) { case "FORWARD": walkSpeed = 0.2f; walkDirection = 0f; break; case "BACK": walkSpeed = -0.2f; walkDirection = 0f; break; case "LEFT": walkDirection = -0.2f; if (walkSpeed == 0f) { walkSpeed = 0.2f; } break; case "RIGHT": walkDirection = 0.2f; if (walkSpeed == 0f) { walkSpeed = 0.2f; } break; case "RUN": walkSpeed = 0.5f; walkDirection = 0f; break; case "STOP": walkSpeed = 0f; walkDirection = 0f; break; case "JUMP": jumpNow = true; walkSpeed = 0.5f; walkDirection = 0f; break; case "HELLO": waveNow = true; walkSpeed = 0.0f; walkDirection = 0f; break; } speechManager.ClearPhraseRecognized(); } } else { walkDirection = Input.GetAxis("Horizontal"); // setup h variable as our horizontal input axis walkSpeed = Input.GetAxis("Vertical"); // setup v variables as our vertical input axis jumpNow = Input.GetButtonDown("Jump"); waveNow = Input.GetButtonDown("Jump"); } anim.SetFloat("Speed", walkSpeed); // set our animator's float parameter 'Speed' equal to the vertical input axis anim.SetFloat("Direction", walkDirection); // set our animator's float parameter 'Direction' equal to the horizontal input axis anim.speed = animSpeed; // set the speed of our animator to the public variable 'animSpeed' anim.SetLookAtWeight(lookWeight); // set the Look At Weight - amount to use look at IK vs using the head's animation currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // set our currentState variable to the current state of the Base Layer (0) of animation if (anim.layerCount == 2) { layer2CurrentState = anim.GetCurrentAnimatorStateInfo(1); // set our layer2CurrentState variable to the current state of the second Layer (1) of animation } // if we are currently in a state called Locomotion (see line 25), then allow Jump input (Space) to set the Jump bool parameter in the Animator to true if (currentBaseState.nameHash == locoState) { if (jumpNow) { jumpNow = false; anim.SetBool("Jump", true); } } // if we are in the jumping state... else if (currentBaseState.nameHash == jumpState) { // ..and not still in transition.. if (!anim.IsInTransition(0)) { if (useCurves) { // ..set the collider height to a float curve in the clip called ColliderHeight col.height = anim.GetFloat("ColliderHeight"); } // reset the Jump bool so we can jump again, and so that the state does not loop anim.SetBool("Jump", false); } // Raycast down from the center of the character.. Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up); RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(ray, out hitInfo)) { // ..if distance to the ground is more than 1.75, use Match Target if (hitInfo.distance > 1.75f) { // MatchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray. // Here we're telling the Root of the character to only be influenced on the Y axis (MatchTargetWeightMask) and only occur between 0.35 and 0.5 // of the timeline of our animation clip anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0, 1, 0), 0), 0.35f, 0.5f); } } } // check if we are at idle, if so, let us Wave! else if (currentBaseState.nameHash == idleState) { if (waveNow) { waveNow = false; anim.SetBool("Wave", true); } } // if we enter the waving state, reset the bool to let us wave again in future if (layer2CurrentState.nameHash == waveState) { anim.SetBool("Wave", false); } }
void Start() { intManager = GameObject.FindWithTag("kinect-interaction").GetComponent<InteractionManager>(); speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); prevGameExists = PlayerPrefs.GetInt("previousGameExists") == 1; //0 = false, 1 = true; TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); timeStarted = t.TotalMilliseconds; // PlayerPrefs.DeleteAll(); // PlayerPrefs.Save(); }
public void OnAwake() { ClearVariables(); // Test for key imports References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; if (sceneManager == null) { ACDebug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard"); } if (settingsManager == null) { ACDebug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard"); } else { if (settingsManager.IsInLoadingScene()) { ACDebug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene."); SetPersistentEngine(); return; } // Unity 5.3 has a bug whereby a modified Player prefab is placed in the scene when editing, but not visible // This causes the Player to not load properly, so try to detect this remnant and delete it! GameObject existingPlayer = GameObject.FindGameObjectWithTag(Tags.player); if (existingPlayer != null) { if (settingsManager.GetDefaultPlayer() != null && existingPlayer.name == (settingsManager.GetDefaultPlayer().name + "(Clone)")) { DestroyImmediate(GameObject.FindGameObjectWithTag(Tags.player)); ACDebug.LogWarning("Player clone found in scene - this may have been hidden by a Unity bug, and has been destroyed."); } } if (!GameObject.FindGameObjectWithTag(Tags.player)) { KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity, false, true); } else { KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>(); SetPersistentEngine(); if (sceneChanger == null || sceneChanger.GetPlayerOnTransition() == null) { // New local player after another local player scene if (KickStarter.playerPrefab != null) { KickStarter.playerPrefab.Initialise(); SetLocalPlayerID(KickStarter.playerPrefab); } } AssignLocalPlayer(); } if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None) { ACDebug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder"); } } if (actionsManager == null) { ACDebug.LogError("No Actions Manager found - please set one using the main Adventure Creator window"); } if (inventoryManager == null) { ACDebug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window"); } if (variablesManager == null) { ACDebug.LogError("No Variables Manager found - please set one using the main Adventure Creator window"); } if (speechManager == null) { ACDebug.LogError("No Speech Manager found - please set one using the main Adventure Creator window"); } if (cursorManager == null) { ACDebug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window"); } if (menuManager == null) { ACDebug.LogError("No Menu Manager found - please set one using the main Adventure Creator window"); } } else { ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window"); } SetPersistentEngine(); if (persistentEnginePrefab == null) { ACDebug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine"); } else { if (persistentEnginePrefab.GetComponent <Options>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no Options component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached."); } if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached."); } if (persistentEnginePrefab.GetComponent <StateHandler>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached."); } if (persistentEnginePrefab.GetComponent <SceneChanger>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached."); } if (persistentEnginePrefab.GetComponent <SaveSystem>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached."); } if (persistentEnginePrefab.GetComponent <LevelStorage>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeLanguages>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeLanguages component attached."); } if (persistentEnginePrefab.GetComponent <ActionListAssetManager>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no ActionListAssetManager component attached."); } } if (this.GetComponent <MenuSystem>() == null) { ACDebug.LogError(this.name + " has no MenuSystem component attached."); } if (this.GetComponent <Dialog>() == null) { ACDebug.LogError(this.name + " has no Dialog component attached."); } if (this.GetComponent <PlayerInput>() == null) { ACDebug.LogError(this.name + " has no PlayerInput component attached."); } if (this.GetComponent <PlayerInteraction>() == null) { ACDebug.LogError(this.name + " has no PlayerInteraction component attached."); } if (this.GetComponent <PlayerMovement>() == null) { ACDebug.LogError(this.name + " has no PlayerMovement component attached."); } if (this.GetComponent <PlayerCursor>() == null) { ACDebug.LogError(this.name + " has no PlayerCursor component attached."); } if (this.GetComponent <PlayerQTE>() == null) { ACDebug.LogError(this.name + " has no PlayerQTE component attached."); } if (this.GetComponent <SceneSettings>() == null) { ACDebug.LogError(this.name + " has no SceneSettings component attached."); } else { if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null) { // No NavMesh, are there Characters in the scene? AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[]; if (allChars.Length > 0) { ACDebug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager."); } } if (this.GetComponent <SceneSettings>().defaultPlayerStart == null) { if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.GetDefaultPlayer() != null) { ACDebug.LogWarning("No default PlayerStart set. The game may not be able to begin if one is not defined - please choose one using the Scene Manager."); } } } if (this.GetComponent <NavigationManager>() == null) { ACDebug.LogError(this.name + " has no NavigationManager component attached."); } if (this.GetComponent <ActionListManager>() == null) { ACDebug.LogError(this.name + " has no ActionListManager component attached."); } if (this.GetComponent <EventManager>() == null) { ACDebug.LogError(this.name + " has no EventManager component attached."); } if (KickStarter.player != null) { if (KickStarter.saveSystem != null && KickStarter.saveSystem.loadingGame == LoadingGame.JustSwitchingPlayer && KickStarter.settingsManager != null && KickStarter.settingsManager.useLoadingScreen) { // Special case: As player is moved out of way when in a loading screen, need to re-load position data once in new scene saveSystem.AssignPlayerAllData(KickStarter.player); } else { saveSystem.AssignPlayerAnimData(KickStarter.player); } } }
void Start() { speechManager = GameObject.Find("SpeechManager").GetComponent <SpeechManager> (); gameObject.SetActive(false); }
void Update () { if(speechManager == null) { speechManager = SpeechManager.Instance; } if(speechManager != null && speechManager.IsSapiInitialized()) { if(speechManager.IsPhraseRecognized()) { string sPhraseTag = speechManager.GetPhraseTagRecognized(); switch(sPhraseTag) { case "RECORD": if(saverPlayer) { saverPlayer.StartRecording(); } break; case "PLAY": if(saverPlayer) { saverPlayer.StartPlaying(); } break; case "STOP": if(saverPlayer) { saverPlayer.StopRecordingOrPlaying(); } break; } speechManager.ClearPhraseRecognized(); } } // alternatively, use the keyboard if(Input.GetButtonDown("Jump")) // start or stop recording { if(saverPlayer) { if(!saverPlayer.IsRecording()) { saverPlayer.StartRecording(); } else { saverPlayer.StopRecordingOrPlaying(); } } } if(Input.GetButtonDown("Fire1")) // start or stop playing { if(saverPlayer) { if(!saverPlayer.IsPlaying()) { saverPlayer.StartPlaying(); } else { saverPlayer.StopRecordingOrPlaying(); } } } }
/** * <summary>Displays the GUI of the class's entry within the Speech Manager.</summary> */ public void ShowGUI() { SpeechManager speechManager = AdvGame.GetReferences().speechManager; string apiPrefix = "KickStarter.speechManager.GetLine (" + lineID + ")"; if (lineID == speechManager.activeLineID) { EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("ID #:", GUILayout.Width(85f)); EditorGUILayout.LabelField(lineID.ToString(), GUILayout.MaxWidth(570f)); if ((textType == AC_TextType.Speech || textType == AC_TextType.DialogueOption) && GUILayout.Button("Locate source", GUILayout.MaxWidth(100))) { KickStarter.speechManager.LocateLine(this); } EditorGUILayout.EndHorizontal(); ShowField("Type:", textType.ToString(), false, apiPrefix + ".textType", "The type of text this is."); ShowField("Original text:", text, true, apiPrefix + ".text", "The original text as recorded during the 'Gather text' process"); string sceneName = scene.Replace("Assets/", string.Empty); sceneName = sceneName.Replace(".unity", string.Empty); ShowField("Scene:", sceneName, true, apiPrefix + ".scene", "The name of the scene that the text was found in"); if (textType == AC_TextType.Speech) { ShowField("Speaker:", GetSpeakerName(), false, apiPrefix + ".owner", "The character who says the line"); } if (speechManager.languages != null && speechManager.languages.Count > 1) { for (int i = 0; i < speechManager.languages.Count; i++) { if (i == 0) { if (speechManager.languages.Count > 1 && speechManager.translateAudio && !speechManager.ignoreOriginalText && textType == AC_TextType.Speech) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Original language:"); } } else if (translationText.Count > (i - 1)) { translationText [i - 1] = EditField(speechManager.languages[i] + ":", translationText [i - 1], true, "", "The display text in '" + speechManager.languages[i] + "'"); } else { ShowField(speechManager.languages[i] + ":", "(Not defined)", false); } if (speechManager.translateAudio && textType == AC_TextType.Speech) { string language = string.Empty; if (i > 0) { language = speechManager.languages[i]; } else if (speechManager.ignoreOriginalText && speechManager.languages.Count > 1) { continue; } if (speechManager.autoNameSpeechFiles) { if (SeparatePlayerAudio() && speechManager.placeAudioInSubfolders) { for (int j = 0; j < KickStarter.settingsManager.players.Count; j++) { if (KickStarter.settingsManager.players[j].playerOb) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path " + j.ToString() + ":", GetFolderName(language, true, KickStarter.settingsManager.players[j].playerOb.name), false); } ShowField("Audio Path " + j.ToString() + ":", GetFolderName(language, false, KickStarter.settingsManager.players[j].playerOb.name), false); } } } else { if (speechManager.useAssetBundles) { if (speechManager.UseFileBasedLipSyncing()) { if (!string.IsNullOrEmpty(speechManager.languageLipsyncAssetBundles[i])) { ShowField(" (Lipsync AB):", "StreamingAssets/" + speechManager.languageLipsyncAssetBundles[i], false); } } if (!string.IsNullOrEmpty(speechManager.languageAudioAssetBundles[i])) { ShowField(" (Audio AB):", "StreamingAssets/" + speechManager.languageAudioAssetBundles[i], false); } } else { if (speechManager.UseFileBasedLipSyncing()) { EditorGUILayout.BeginHorizontal(); ShowField(" (Lipsync path):", GetFolderName(language, true), false); ShowLocateButton(i, true); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); ShowField(" (Audio path):", GetFolderName(language), false); ShowLocateButton(i); EditorGUILayout.EndHorizontal(); } } } else { if (i > 0) { SetCustomArraySizes(speechManager.languages.Count - 1); if (speechManager.UseFileBasedLipSyncing()) { customTranslationLipsyncFiles[i - 1] = EditField <Object> ("Lipsync file:", customTranslationLipsyncFiles[i - 1], apiPrefix + ".customTranslationLipsyncFiles[i-1]", "The text file to use for lipsyncing when the language is '" + KickStarter.speechManager.languages[i - 1] + "'"); } customTranslationAudioClips[i - 1] = EditField <AudioClip> ("Audio clip:", customTranslationAudioClips[i - 1], apiPrefix + ".customTranslationAudioClips[i-1]", "The voice AudioClip to play when the language is '" + KickStarter.speechManager.languages[i - 1] + "'"); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile", "The text file to use for lipsyncing in the original language"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip", "The voice AudioClip to play in the original language"); } } EditorGUILayout.Space(); } } } // Original language if (textType == AC_TextType.Speech) { if (speechManager.languages == null || speechManager.languages.Count <= 1 || !speechManager.translateAudio) { if (speechManager.autoNameSpeechFiles) { if (SeparatePlayerAudio() && speechManager.placeAudioInSubfolders) { for (int i = 0; i < KickStarter.settingsManager.players.Count; i++) { if (KickStarter.settingsManager.players[i].playerOb) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path " + i.ToString() + ":", GetFolderName(string.Empty, true, KickStarter.settingsManager.players[i].playerOb.name), false, "", "The filepath to the text asset file to rely on for Lipsyncing"); } ShowField("Audio Path " + i.ToString() + ":", GetFolderName(string.Empty, false, KickStarter.settingsManager.players[i].playerOb.name), false, "", "The filepath to the voice AudioClip asset file to play"); } } } else { if (speechManager.useAssetBundles) { if (speechManager.UseFileBasedLipSyncing()) { if (!string.IsNullOrEmpty(speechManager.languageLipsyncAssetBundles[0])) { ShowField("Lipsync AB:", "StreamingAssets/" + speechManager.languageLipsyncAssetBundles[0], false); } } if (!string.IsNullOrEmpty(speechManager.languageAudioAssetBundles[0])) { ShowField("Audio AB:", "StreamingAssets/" + speechManager.languageAudioAssetBundles[0], false); } } else { if (speechManager.UseFileBasedLipSyncing()) { EditorGUILayout.BeginHorizontal(); ShowField("Lipsync path:", GetFolderName(string.Empty, true), false); ShowLocateButton(0, true); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); ShowField("Audio Path:", GetFolderName(string.Empty), false); ShowLocateButton(0); EditorGUILayout.EndHorizontal(); } } } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile", "The text file to use for lipsyncing in the original language"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip", "The voice AudioClip to play in the original language"); } } if (speechManager.autoNameSpeechFiles) { if (SeparatePlayerAudio()) { for (int i = 0; i < KickStarter.settingsManager.players.Count; i++) { if (KickStarter.settingsManager.players[i].playerOb) { ShowField("Filename " + i.ToString() + ":", GetFilename(KickStarter.settingsManager.players[i].playerOb.name) + lineID.ToString(), false); } } } else { ShowField("Filename:", GetFilename() + lineID.ToString(), false); } } if (tagID >= 0 && speechManager.useSpeechTags) { SpeechTag speechTag = speechManager.GetSpeechTag(tagID); if (speechTag != null && speechTag.label.Length > 0) { ShowField("Tag: ", speechTag.label, false, apiPrefix + ".tagID"); } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Only say once?", "If True, then this line can only be spoken once. Additional calls to play it will be ignored."), GUILayout.Width(85f)); onlyPlaySpeechOnce = CustomGUILayout.Toggle(onlyPlaySpeechOnce, GUILayout.MaxWidth(570f), apiPrefix + ".onlyPlaySpeechOnce"); EditorGUILayout.EndHorizontal(); } if (SupportsDescriptions()) { description = EditField("Description:", description, true, apiPrefix + ".description", "An Editor-only description"); } EditorGUILayout.EndVertical(); } else { if (GUILayout.Button(lineID.ToString() + ": '" + GetShortText() + "'", EditorStyles.label, GUILayout.MaxWidth(300))) { speechManager.activeLineID = lineID; EditorGUIUtility.editingTextField = false; } GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1)); } }
// Make sure to kill the Kinect on quitting. void OnApplicationQuit() { // Shutdown Speech Recognizer and Kinect SpeechWrapper.FinishSpeechRecognizer(); SpeechWrapper.ShutdownKinectSensor(); sapiInitialized = false; instance = null; }
/** * <summary>Checks if the line has all associated audio for a given language, if a speech line</summary> * <param name = "languageIndex">The index number of the language in question. The game's original language is 0</param> * <returns>True if the line has all associated audio for the given language</returns> */ public bool HasAudio(int languageIndex) { if (textType != AC_TextType.Speech) { return(false); } SpeechManager speechManager = KickStarter.speechManager; if (speechManager == null) { return(false); } if (speechManager.autoNameSpeechFiles) { string language = (languageIndex == 0) ? string.Empty : speechManager.languages[languageIndex]; if (SeparatePlayerAudio()) { bool doDisplay = false; foreach (PlayerPrefab player in KickStarter.settingsManager.players) { if (player != null && player.playerOb != null) { string fullName = GetAutoAssetPathAndName(language, false, player.playerOb.name); AudioClip clipObj = Resources.Load(fullName) as AudioClip; if (clipObj == null) { doDisplay = true; } } } if (!doDisplay) { return(false); } return(true); } else { string fullName = GetAutoAssetPathAndName(language); AudioClip clipObj = Resources.Load(fullName) as AudioClip; if (clipObj != null) { return(true); } } } else { if (languageIndex == 0 && customAudioClip != null) { return(true); } if (speechManager.translateAudio && languageIndex > 0 && customTranslationAudioClips.Count > (languageIndex - 1) && customTranslationAudioClips[languageIndex - 1] != null) { return(true); } if (!speechManager.translateAudio && customAudioClip != null) { return(true); } } return(false); }
void Awake() { manager = GetComponent<InteractionManager>(); handCursor = GameObject.Find("HandCursor"); speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); }
//----------------------------------- end of public functions --------------------------------------// void Awake() { instance = this; }
void Start() { speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); }
void Start() { speechManager = GameObject.FindWithTag("kinect-speech").GetComponent<SpeechManager>(); worldIndex = GameObject.Find("levelProperties").GetComponent<levelProperties>().worldIndex; }