Пример #1
0
        public static int AquireAudio(string filename)
        {
            foreach (int id in audios.Keys)
            {
                if (audios[id].Filename == filename)
                {
                    return(id);
                }
            }

            AudioAsset asset = new AudioAsset(filename);

            try
            {
                asset.Load();
                audios.Add(asset.ID, asset);
                return((int)asset.ID);
            }
            catch (FileNotFoundException e)
            {
                Debug.LogError("Asset couldn't be loaded. Exception thrown:");
                Debug.LogError(e.Message);
                return(-1);
            }
        }
Пример #2
0
 public static void Initialize()
 {
     textures       = new Dictionary <long, TextureAsset>();
     audios         = new Dictionary <long, AudioAsset>();
     fonts          = new Dictionary <long, FontAsset>();
     defaultTexture = new TextureAsset("Resources/default/default.png");
     defaultAudio   = new AudioAsset("Resources/default/default.ogg");
     defaultFont    = new FontAsset("Resources/default/default.ttf");
     try
     {
         defaultTexture.Load();
         defaultAudio.Load();
         defaultFont.Load();
         Debug.Log("Default resources loaded.");
     }
     catch (FileNotFoundException e)
     {
         Debug.LogError(e.Message);
         throw new NotInitializedException("The default resources couldn't be found. They are required to run the application. Assetmanager initialization cancelled.");
     }
 }