Example #1
0
        public WorkingMaterialBuffer Get(Allocator allocator, Material material)
        {
            WorkingMaterialBuffer buffer = null;
            string guid    = "";
            long   localId = 0;

            if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(material, out guid, out localId) == false)
            {
                //issue guid for just create
                guid = System.Guid.NewGuid().ToString("N");
            }
            else
            {
                guid = guid + material.GetInstanceID();
            }


            if (m_cache.ContainsKey(guid) == false)
            {
                buffer = new WorkingMaterialBuffer(allocator, material);
                m_cache[buffer.Identifier] = buffer;
                guid = buffer.Identifier;
            }

            buffer = m_cache[guid];
            buffer.AddRef();
            return(buffer);
        }
Example #2
0
        public void Dispose()
        {
            m_buffer.Release();
            m_buffer = null;

            m_detector.Dispose();
        }
Example #3
0
        public WorkingMaterialBuffer Create(Allocator allocator, int materialId, string name)
        {
            WorkingMaterialBuffer buffer = new WorkingMaterialBuffer(allocator, materialId, name);

            buffer.AddRef();
            m_cache[buffer.Identifier] = buffer;
            return(buffer);
        }
Example #4
0
 public WorkingMaterial(Allocator allocator, int materialId, string name)
 {
     m_buffer = WorkingMaterialBufferManager.Instance.Create(allocator, materialId, name);
 }
Example #5
0
 public WorkingMaterial(Allocator allocator, Material mat)
 {
     m_buffer = WorkingMaterialBufferManager.Instance.Get(allocator, mat);
 }
Example #6
0
 public void Destroy(WorkingMaterialBuffer buffer)
 {
     m_cache.Remove(buffer.Identifier);
 }