Пример #1
0
 public void DelShader(Shader shader)
 {
     if (ab != null)
     {
         string name = shader.name;
         if (dictShaderRefs.ContainsKey(name))
         {
             ShaderRef refs = dictShaderRefs [name];
             refs.refs--;
             if (refs.refs == 0)
             {
                 // 删除资源物体
                                         #if !UNITY_EDITOR
                 UnityEngine.Object.Destroy(refs.shader);
                                         #else
                 UnityEngine.Object.DestroyImmediate(refs.shader, true);                         // 这里绝不关联到
                                         #endif
                 dictShaderRefs.Remove(name);
             }
         }
         else
         {
             Debug.LogError("DelShader " + name + ":Shader not found in manager!");
         }
     }
 }
Пример #2
0
 public int GetShaderRef(string name)
 {
     if (ab != null)
     {
         if (dictShaderRefs.ContainsKey(name))
         {
             ShaderRef refs = dictShaderRefs [name];
             return(refs.refs);
         }
     }
     return(0);
 }
Пример #3
0
 public void DisposeBundle()
 {
     Dictionary <string, ShaderRef> .Enumerator e = dictShaderRefs.GetEnumerator();
     while (e.MoveNext())
     {
         ShaderRef refs = e.Current.Value;
                         #if !UNITY_EDITOR
         UnityEngine.Object.Destroy(refs.shader);
                         #else
         UnityEngine.Object.DestroyImmediate(refs.shader, true);                 // 这里绝不关联到
                         #endif
     }
     dictShaderRefs.Clear();
     dictName2Path.Clear();
     if (ab != null)
     {
         ab.Unload(true);
     }
 }
Пример #4
0
 public Shader AddShader(string name)
 {
     if (ab != null)
     {
         if (dictShaderRefs.ContainsKey(name))
         {
             ShaderRef refs = dictShaderRefs [name];
             refs.refs++;
             return(refs.shader);
         }
         else
         {
             ShaderRef refs = new ShaderRef();
             refs.refs   = 1;
             refs.shader = ab.LoadAsset <Shader> (dictName2Path [name]);
             dictShaderRefs.Add(name, refs);
             return(refs.shader);
         }
     }
     return(null);
 }