Example #1
0
        public static bool IsFixedSize(UnsafeDictionary *map)
        {
            UDebug.Assert(map != null);

            return(map->_collection.Entries.Dynamic == 0);
        }
Example #2
0
        public static int GetCount(UnsafeDictionary *map)
        {
            UDebug.Assert(map != null);

            return(map->_collection.UsedCount - map->_collection.FreeCount);
        }
        public static bool IsFixedSize(UnsafeStack *stack)
        {
            UDebug.Assert(stack != null);

            return(stack->_items.Dynamic == 0);
        }
Example #4
0
        public static int GetCapacity(UnsafeDictionary *map)
        {
            UDebug.Assert(map != null);

            return(map->_collection.Entries.Length);
        }
Example #5
0
        static UVData GetMeshUVData(Mesh mesh)
        {
            var    assetPath = AssetDatabase.GetAssetPath(mesh);
            UVData result    = null;

            if (String.IsNullOrEmpty(assetPath))
            {
                result = null;
            }
            else
            {
                UVData md              = null;
                var    importer        = AssetImporter.GetAtPath(assetPath) as ModelImporter;
                var    isReadable      = true;
                var    meshCompression = ModelImporterMeshCompression.Off;
                if (importer != null)
                {
                    isReadable      = importer.isReadable;
                    meshCompression = importer.meshCompression;
                }
                Func <Mesh, UVData> readMeshData = _mesh => {
                    var _md = new UVData();
                    _md.name      = _mesh.name;
                    _md.uvs[0]    = _mesh.uv;
                    _md.uvs[1]    = _mesh.uv2;
                    _md.uvs[2]    = _mesh.uv3;
                    _md.uvs[3]    = _mesh.uv4;
                    _md.subMeshes = new List <int[]>(_mesh.subMeshCount);
                    for (int s = 0; s < _mesh.subMeshCount; ++s)
                    {
                        UDebug.Assert(_mesh.GetTopology(s) == MeshTopology.Triangles);
                        _md.subMeshes.Add(_mesh.GetTriangles(s));
                    }
                    return(_md);
                };
                UVData _cachedMeshData = null;
                var    key             = GetMeshAssetHash(assetPath, mesh);
                if (m_MeshUVCache.TryGetValue(key, out _cachedMeshData))
                {
                    md = _cachedMeshData;
                }
                else
                {
                    if (!isReadable || meshCompression != ModelImporterMeshCompression.Off)
                    {
                        if (importer != null)
                        {
                            importer.isReadable      = true;
                            importer.meshCompression = ModelImporterMeshCompression.Off;
                            AssetDatabase.ImportAsset(assetPath);
                        }
                    }
                    try {
                        md = readMeshData(mesh);
                    } finally {
                        if (!isReadable || meshCompression != ModelImporterMeshCompression.Off)
                        {
                            if (importer != null)
                            {
                                importer.isReadable      = isReadable;
                                importer.meshCompression = meshCompression;
                                AssetDatabase.ImportAsset(assetPath);
                            }
                        }
                        if (md != null)
                        {
                            m_MeshUVCache.Add(key, md);
                        }
                    }
                }
                result = md;
            }
            return(result);
        }