Ejemplo n.º 1
0
        public static AudioClip LoadVO(string resref, int index)
        {
            resref = resref.ToLower();

            AudioClip clip;

            if (data.voLocations.ContainsKey(resref))
            {
                // We know where the VO file is located
                using (FileStream stream = File.Open(data.voLocations[resref], FileMode.Open))
                {
                    WAVObject wav = new WAVObject(stream);

                    clip = AudioClip.Create(resref, wav.data.Length / wav.channels, wav.channels, wav.sampleRate, false);
                    clip.SetData(wav.data, 0);

                    return(clip);
                }
            }

            if (!data.tlk.strings.ContainsKey(index))
            {
                return(null);
            }

            if (data.tlk.strings[index].soundResRef != null && data.tlk.strings[index].soundResRef != "")
            {
                return(LoadVO(data.tlk.strings[index].soundResRef, -1));
            }

            return(null);
        }
Ejemplo n.º 2
0
        public static AudioClip LoadAudio(string resref)
        {
            // using (FileStream stream = File.Open(AuroraPrefs.GetKotorLocation() + "\\streammusic\\" + resref + ".wav", FileMode.Open)) {
            using (FileStream stream = File.Open(AuroraPrefs.GetKotorLocation() + "/streammusic/" + resref + ".wav", FileMode.Open))
            {
                WAVObject wav = new WAVObject(stream);

                AudioClip clip = AudioClip.Create(resref, wav.data.Length / wav.channels, wav.channels, wav.sampleRate, false);
                clip.SetData(wav.data, 0);

                return(clip);
            }
        }
Ejemplo n.º 3
0
        static AudioClip LoadVOAlternative(string resref)
        {
            // Check if the resref is long enough
            if (resref.Length <= 11)
            {
                return(null);
            }
            resref = resref.Replace("_", "") + "_";

            // Firstly, check if it's in the top-level


            // The first five characters are the top-level folder
            string topFolder = resref.Substring(1, 5);
            // Next six characters are the subfolder
            string subFolder = resref.Substring(6, 6);

            string fullname = AuroraPrefs.GetKotorLocation() + "/streamwaves/" + topFolder + "/" + subFolder + "/" + resref + ".wav";

            // string fullname = AuroraPrefs.GetKotorLocation() + "\\streamwaves\\" + topFolder + "\\" + subFolder + "\\" + resref + ".wav";

            if (!File.Exists(fullname))
            {
                UnityEngine.Debug.Log("Did not find resref " + resref + " with filename " + fullname);
                return(null);
            }

            using (FileStream stream = File.Open(fullname, FileMode.Open))
            {
                WAVObject wav = new WAVObject(stream);

                AudioClip clip = AudioClip.Create(resref, wav.data.Length / wav.channels, wav.channels, wav.sampleRate, false);
                clip.SetData(wav.data, 0);

                return(clip);
            }
        }