示例#1
0
 public static void DefaultReleaseDelegate(T value, List <UnityEngine.Object> subObjects)
 {
     ComponentExtensions.DestroyResource(value);
     foreach (UnityEngine.Object subObject in subObjects)
     {
         ComponentExtensions.DestroyResource(subObject);
     }
 }
示例#2
0
        public void Release(TKey key)
        {
            Item item = cache[key];

            item.RefCount--;
            if (!item.Permanent && item.RefCount <= 0 && ValueReleaser(key, item.Value))
            {
                ComponentExtensions.DestroyResource(item.Value);
                cache.Remove(key);
            }
        }
示例#3
0
 private void adjustSkybox()
 {
     if (SkyboxMaterialKey != null && !string.IsNullOrEmpty(SkyboxMaterialKey.Key))
     {
         Texture mainTexture = RenderSettings.skybox.mainTexture;
         RenderSettings.skybox.mainTexture = null;
         ComponentExtensions.DestroyResource(mainTexture);
         Content.LoadAsync(delegate(string path, Material material)
         {
             onScheduledSkyboxLoaded(material);
         }, SkyboxMaterialKey);
     }
 }
示例#4
0
 private void swapMaterials()
 {
     materialsToSwap = new List <ScheduledSwapMaterialData>();
     ScheduledSwapMaterialData[] swapMaterialData = SwapMaterialData;
     foreach (ScheduledSwapMaterialData scheduledSwapMaterialData in swapMaterialData)
     {
         Renderer component = scheduledSwapMaterialData.SwapTarget.GetComponent <Renderer>();
         if (component != null)
         {
             if (scheduledSwapMaterialData.SwapMaterialKey != null && !string.IsNullOrEmpty(scheduledSwapMaterialData.SwapMaterialKey.Key))
             {
                 materialsToSwap.Add(scheduledSwapMaterialData);
             }
             else
             {
                 Log.LogError(this, $"Error: {base.gameObject.GetPath()} has a Swap Material data field with a null material entry");
             }
         }
         else
         {
             Log.LogError(this, $"Error: {base.gameObject.GetPath()} has a no renderer component attached");
         }
     }
     if (materialsToSwap.Count <= 0)
     {
         return;
     }
     Service.Get <LoadingController>().AddLoadingSystem(this);
     swapMaterialsLoadTimer = new Stopwatch();
     swapMaterialsLoadTimer.Start();
     foreach (ScheduledSwapMaterialData item in materialsToSwap)
     {
         Renderer component   = item.SwapTarget.GetComponent <Renderer>();
         Material material    = component.material;
         Texture  mainTexture = component.material.mainTexture;
         component.material.mainTexture = null;
         component.material             = null;
         if (item.DestroyTexture)
         {
             ComponentExtensions.DestroyResource(mainTexture);
         }
         ComponentExtensions.DestroyResource(material);
         if (Content.TryLoadImmediate(out var result, item.SwapMaterialKey))
         {
             component.material = result;
         }
     }
     Service.Get <LoadingController>().RemoveLoadingSystem(this);
     swapMaterialsLoadTimer.Stop();
 }
 private void setSkybox(MaterialContentKey skyboxMaterialKey)
 {
     if (skyboxMaterialKey != null && !string.IsNullOrEmpty(skyboxMaterialKey.Key))
     {
         Texture mainTexture = RenderSettings.skybox.mainTexture;
         if (mainTexture != null)
         {
             RenderSettings.skybox.mainTexture = null;
             ComponentExtensions.DestroyResource(mainTexture);
         }
         Content.LoadAsync(delegate(string path, Material material)
         {
             onSkyboxLoaded(material);
         }, skyboxMaterialKey);
     }
 }
示例#6
0
        public void ReleaseAll()
        {
            List <TKey> list = new List <TKey>();

            foreach (KeyValuePair <TKey, Item> item in cache)
            {
                if (!item.Value.Permanent && item.Value.RefCount <= 0 && ValueReleaser(item.Key, item.Value.Value))
                {
                    ComponentExtensions.DestroyResource(item.Value.Value);
                    list.Add(item.Key);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                cache.Remove(list[i]);
            }
        }