private void DrawLineCol(int startY, int col, float width, int objIndex, GUIStyle style, float lineHeight) { object obj = m_objects[objIndex]; float cellWidth = width / ColumnCount; var rect = new Rect(cellWidth * col, startY, cellWidth, lineHeight); if (rect.Contains(Event.current.mousePosition)) { if (Event.current.type == EventType.MouseDown && m_selectedIndex != objIndex) { m_selectedIndex = objIndex; if (OnSelected != null) { OnSelected(obj, objIndex); } } m_hostWindow.Repaint(); } TextureInfoItem item = obj as TextureInfoItem; if (item != null) { GUI.DrawTexture(rect, item.TextureObject); if (m_selectedIndex == objIndex /*&& m_selected == obj*/) { style = _appearance.Style_SelectedCell; } Rect textRect = rect; textRect.y = rect.y + rect.height - 20; textRect.height = 20; style.alignment = TextAnchor.LowerLeft; string text = string.Format("{0}. {1} ({2}x{3})", objIndex, item.TextureName, item.TextureWidth, item.TextureHeight); GUI.Label(textRect, new GUIContent(text, text), style); } }
void OnTextureSelected(object selected, int col) { TextureInfoItem item = selected as TextureInfoItem; if (item != null) { _selectedTexture = item.TextureObject; if (_highlightSelection) { foreach (var p in _highlighted) { p.Key.mainTexture = p.Value; } _highlighted.Clear(); HashSet <Material> mats; if (VisibleTextures.TryGetValue(_selectedTexture, out mats)) { foreach (var mat in mats) { _highlighted[mat] = mat.mainTexture; mat.mainTexture = null; } } List <GameObject> objects; if (_visibleGameObjects.TryGetValue(_selectedTexture, out objects)) { if (objects != null && objects.Count > 0) { GotoHighlightedGameObject(objects[0]); } } } } }
private void RefreshTextureInfoTables() { _visibleMaterials.Clear(); _visibleTextures.Clear(); _visibleGameObjects.Clear(); TextureCategorizing.RefreshRootObjects(); Renderer[] meshRenderers = UnityEngine.Object.FindObjectsOfType(typeof(Renderer)) as Renderer[]; foreach (Renderer mr in meshRenderers) { if (mr.isVisible) { GameObject go = mr.gameObject; //if (_meshLut.AddMesh(go)) { _nameLut[go.GetInstanceID()] = go.name; //Debug.Log(string.Format("CollectFrameData(): adding game object. {0}, name {1}, name count {2}", // go.GetInstanceID(), // go.name, // _nameLut.Count)); foreach (var mat in mr.sharedMaterials) { AddVisibleMaterial(mat, mr.gameObject); if (mat != null) { #if UNITY_EDITOR if (Application.isEditor) { int cnt = ShaderUtil.GetPropertyCount(mat.shader); for (int i = 0; i < cnt; i++) { if (ShaderUtil.GetPropertyType(mat.shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) { string propName = ShaderUtil.GetPropertyName(mat.shader, i); AddVisibleTexture(mat.GetTexture(propName), mat, go); } } } else #endif { AddVisibleTexture(mat.mainTexture, mat, go); } } } } } } #if JX3M HashSet <Texture> textures = new HashSet <Texture>(); UISprite[] sprites = UnityEngine.Object.FindObjectsOfType(typeof(UISprite)) as UISprite[]; foreach (UISprite s in sprites) { if (!textures.Contains(s.mainTexture)) { AddVisibleTexture(s.mainTexture, s.material, s.gameObject); } } #endif //UIAtlas[] atlases = UnityEngine.Object.FindObjectsOfType(typeof(UIAtlas)) as UIAtlas[]; //foreach (UIAtlas a in atlases) //{ // AddVisibleTexture(a.texture, a.spriteMaterial, a.gameObject); //} Debug.Log(string.Format("{0} visible materials ({1}), visible textures ({2})", DateTime.Now.ToLongTimeString(), VisibleMaterials.Count, VisibleTextures.Count)); Dictionary <int, int> countDict = new Dictionary <int, int>(); Dictionary <int, int> sizeDict = new Dictionary <int, int>(); countDict[(int)TextureCategory.All] = 0; sizeDict[(int)TextureCategory.All] = 0; List <object> entries = new List <object>(); foreach (var p in VisibleTextures) { TextureInfoItem si = new TextureInfoItem(); si.TextureName = p.Key.name; si.TextureWidth = p.Key.width; si.TextureHeight = p.Key.height; si.TextureSize = _textureSizeLut[p.Key]; si.TextureCat = _textureCatLut[p.Key]; si.TextureObject = p.Key; if (_selectedCategory == (TextureCategory)si.TextureCat || _selectedCategory == TextureCategory.All) { entries.Add(si); } if (!sizeDict.ContainsKey(si.TextureCat)) { sizeDict.Add(si.TextureCat, 0); } sizeDict[si.TextureCat] += si.TextureSize; sizeDict[(int)TextureCategory.All] += si.TextureSize; if (!countDict.ContainsKey(si.TextureCat)) { countDict.Add(si.TextureCat, 0); } countDict[si.TextureCat] += 1; countDict[(int)TextureCategory.All] += 1; } _textureInfoTable.RefreshData(entries); _textureInfoTiles.RefreshData(entries); _totalVisibleTextureCount = countDict[(int)TextureCategory.All]; _totalVisibleTextureSize = sizeDict[(int)TextureCategory.All]; List <object> catEntries = new List <object>(); for (int i = 0; i < (int)TextureCategory.Num; ++i) { TextureCategoryItem cat = new TextureCategoryItem(); cat.TextureCat = i; cat.TextureCatName = ((TextureCategory)i).ToString(); cat.TextureCatSize = sizeDict.ContainsKey(i) ? sizeDict[i] : 0; cat.TextureCatCount = countDict.ContainsKey(i) ? countDict[i] : 0; catEntries.Add(cat); } _textureCatTable.RefreshData(catEntries); Repaint(); }