public AudioClip ExistingAudioClip(string fileName) { Debug.Log("MOD getting existing audioclip from file access util with filename: " + fileName); AudioClip tempClip; tempClip = FileAccessUtil.LoadWordAudio(fileName + ".wav"); if (tempClip != null) { return(tempClip); } else { Debug.Log("No audioclip found in wordaudio folder. Attempting to load from resources."); tempClip = Resources.Load <AudioClip>("Sound/" + fileName); if (tempClip != null) { Debug.Log("Found stock audio clip in resources. returning"); return(tempClip); } else { Debug.Log("ERROR: No stock audioclip found in resource. returning null"); return(null); } } }
/// <summary> /// Plays the audio clip corresponding to the string parameter. /// </summary> /// <param name="word"></param> public void PlayAudio(string word) { AudioClip tempClip = FileAccessUtil.LoadWordAudio(word + ".wav"); if (tempClip != null) { audioSource.clip = tempClip; audioSource.Play(); } else { tempClip = Resources.Load <AudioClip>("Sound/" + word); if (tempClip != null) { audioSource.clip = tempClip; audioSource.Play(); } else { Debug.Log("No audioclip found"); } //audioSource.clip = tempClip; //audioSource.Play(); } }
///<summary>System event called when dragging an object ends</summary> ///<param name="eventData">the data collected about the event by Unity</param> public virtual void OnEndDrag(PointerEventData eventData) { string word; word = ImageBeingDragged.name; Debug.Log("Image dropped is " + word); //Unload ImageBeingDragged ImageBeingDragged = null; //Re-enables raycasting to the image //GetComponent<CanvasGroup>().blocksRaycasts = true; //Check if this object's parent is the starting slot _or_ the canvas if (transform.parent == startParent) { //Sets the object's position back to the starting slot transform.position = startPosition; if (word == helper.word1) { helper.word1Errors++; } else if (word == helper.word2) { helper.word2Errors++; } else if (word == helper.word3) { helper.word3Errors++; } else { Debug.Log("Error. word dropped does not match word1, word2 or word3"); } } else { AudioClip tempClip = FileAccessUtil.LoadWordAudio(word + ".wav"); if (tempClip != null) { audioSource.clip = tempClip; Debug.Log("Playing word sound"); audioSource.Play(); } else { tempClip = Resources.Load <AudioClip>("Sound/" + word); if (tempClip != null) { audioSource.clip = tempClip; Debug.Log("Playing word sound"); audioSource.Play(); } else { Debug.Log("No Sound available to play"); } //audioSource.clip = tempClip; //Debug.Log("Playing word sound"); //audioSource.Play(); } helper.IterateSolvedPairs(); } Debug.Log("End OnDrag"); }
///<summary>System event called when dragging an object ends</summary> ///<param name="eventData">the data collected about the event by Unity</param> public virtual void OnEndDrag(PointerEventData eventData) { string letter; letter = letterBeingDragged.name.Replace("_", " ").Replace("(Clone)", ""); Debug.Log("Letter dropped is " + letter); //Unload letterBeingDragged letterBeingDragged = null; //Re-enables raycasting to the letter GetComponent <CanvasGroup>().blocksRaycasts = true; //Check if this object's parent is the starting slot _or_ the canvas //if (transform.parent == startParent || transform.parent == transform.root) { if (transform.parent == startParent) { //Sets the object's position back to the starting slot transform.position = startPosition; //Sets the object's parent back to the starting slot //transform.SetParent (startParent); ExecuteEvents.ExecuteHierarchy <IPostAnError>(gameObject, null, (x, y) => x.PostAnError()); print("posting an error"); } else { //Play soundclip //audioSource.Play(); AudioClip tempClip = FileAccessUtil.LoadWordAudio(letter + ".wav"); if (tempClip != null) { audioSource.clip = tempClip; audioSource.Play(); } else { tempClip = Resources.Load <AudioClip>("Sound/" + letter); if (tempClip != null) { audioSource.clip = tempClip; audioSource.Play(); } else { //Do nothing } audioSource.clip = tempClip; audioSource.Play(); } //Play animation animation.Play(); } }