示例#1
0
        private Mesh GetMesh(Type simplifiedType, Mesh source, float quality, string guid, long time)
        {
            SimplifiedMeshList meshList = GetMeshList(guid, time);

            var mesh = meshList.GetMesh(quality, simplifiedType);

            if (mesh != null)
            {
                return(mesh.Mesh);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        private void UpdateImpl(Type simplifiedType, Mesh originalMesh, Mesh simplifiedMesh, float quality)
        {
            string path = AssetDatabase.GetAssetPath(originalMesh);
            string guid = AssetDatabase.AssetPathToGUID(path);

            if (string.IsNullOrEmpty(guid) == true)
            {
                return;
            }

            DateTime           time     = System.IO.File.GetLastWriteTime(path);
            SimplifiedMeshList meshList = GetMeshList(guid, time.ToFileTimeUtc());
            var mesh = meshList.GetMesh(quality, simplifiedType);

            if (mesh != null)
            {
                mesh.Mesh = simplifiedMesh;
            }
            else
            {
                meshList.AddMesh(quality, simplifiedType, simplifiedMesh);
            }

            AssetDatabase.AddObjectToAsset(simplifiedMesh, meshList);
            EditorUtility.SetDirty(meshList);

            for (int i = 0; i < m_GeneratingInfos.Count; ++i)
            {
                if (m_GeneratingInfos[i].Type == simplifiedType &&
                    m_GeneratingInfos[i].Mesh == originalMesh &&
                    Mathf.Abs(Instance.m_GeneratingInfos[i].Quality - quality) < 0.0001f)
                {
                    m_GeneratingInfos.RemoveAt(i);
                    return;
                }
            }
        }