FormatBytes() public static method

Returns a text for a number of bytes.

public static FormatBytes ( int bytes ) : string
bytes int
return string
示例#1
0
        protected override void DrawData(Rect rect, MemoryElement memoryElement, int indent, int row, bool selected)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            string displayName = memoryElement.name;

            if (memoryElement.ChildCount() > 0 && indent < 3)
            {
                displayName += " (" + memoryElement.AccumulatedChildCount() + ")";
            }

            int currentColumn = 0;

            rect.xMax = m_Splitter.realSizes[currentColumn];
            styles.numberLabel.Draw(rect, displayName, false, false, false, selected);
            rect.x     = rect.xMax;
            rect.width = m_Splitter.realSizes[++currentColumn] - kSmallMargin;
            styles.numberLabel.Draw(rect, EditorUtility.FormatBytes(memoryElement.totalMemory), false, false, false, selected);
            rect.x    += m_Splitter.realSizes[currentColumn++];
            rect.width = m_Splitter.realSizes[currentColumn] - kSmallMargin;

            if (memoryElement.ReferenceCount() > 0)
            {
                styles.numberLabel.Draw(rect, memoryElement.ReferenceCount().ToString(), false, false, false, selected);
            }
            else if (selected)
            {
                styles.numberLabel.Draw(rect, "", false, false, false, selected);
            }
        }
        public override string GetInfoString()
        {
            AudioClip clip         = this.target as AudioClip;
            int       channelCount = AudioUtil.GetChannelCount(clip);
            string    text         = (channelCount != 1) ? ((channelCount != 2) ? ((channelCount - 1).ToString() + ".1") : "Stereo") : "Mono";
            string    str          = string.Concat(new object[]
            {
                AudioUtil.GetSoundCompressionFormat(clip).ToString(),
                ", ",
                AudioUtil.GetFrequency(clip),
                " Hz, ",
                text,
                ", "
            });
            TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)AudioUtil.GetDuration(clip));

            if ((uint)AudioUtil.GetDuration(clip) == 4294967295u)
            {
                str += "Unlimited";
            }
            else
            {
                str += string.Format("{0:00}:{1:00}.{2:000}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds);
            }
            str += ", ";
            return(str + EditorUtility.FormatBytes(AudioUtil.GetSoundSize(clip)));
        }
示例#3
0
 protected override void DrawData(Rect rect, MemoryElement memoryElement, int indent, int row, bool selected)
 {
     if (Event.current.type == EventType.Repaint)
     {
         string name = memoryElement.name;
         if ((memoryElement.ChildCount() > 0) && (indent < 3))
         {
             name = name + " (" + memoryElement.AccumulatedChildCount().ToString() + ")";
         }
         int index = 0;
         rect.xMax = base.m_Splitter.realSizes[index];
         MemoryTreeList.styles.numberLabel.Draw(rect, name, false, false, false, selected);
         rect.x     = rect.xMax;
         rect.width = base.m_Splitter.realSizes[++index] - 4f;
         MemoryTreeList.styles.numberLabel.Draw(rect, EditorUtility.FormatBytes(memoryElement.totalMemory), false, false, false, selected);
         rect.x    += base.m_Splitter.realSizes[index++];
         rect.width = base.m_Splitter.realSizes[index] - 4f;
         if (memoryElement.ReferenceCount() > 0)
         {
             MemoryTreeList.styles.numberLabel.Draw(rect, memoryElement.ReferenceCount().ToString(), false, false, false, selected);
         }
         else if (selected)
         {
             MemoryTreeList.styles.numberLabel.Draw(rect, string.Empty, false, false, false, selected);
         }
     }
 }
示例#4
0
        override public string GetInfoString()
        {
            RenderTexture t = target as RenderTexture;

            string info = t.width + "x" + t.height;

            if (t.dimension == UnityEngine.Rendering.TextureDimension.Tex3D)
            {
                info += "x" + t.volumeDepth;
            }

            if (!t.isPowerOfTwo)
            {
                info += "(NPOT)";
            }

            if (QualitySettings.desiredColorSpace == ColorSpace.Linear)
            {
                bool formatIsHDR = GraphicsFormatUtility.IsIEEE754Format(t.graphicsFormat);
                bool sRGB        = t.sRGB && !formatIsHDR;
                info += " " + (sRGB ? "sRGB" : "Linear");
            }

            info += "  " + t.graphicsFormat;
            info += "  " + EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySizeLong(t));

            return(info);
        }
示例#5
0
        private void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            int bytes = 0;
            int num2  = 0;
            Dictionary <Vector2, int> dictionary = new Dictionary <Vector2, int>();
            bool flag = false;

            foreach (LightmapData data in LightmapSettings.lightmaps)
            {
                if (data.lightmapFar != null)
                {
                    num2++;
                    Vector2 key = new Vector2((float)data.lightmapFar.width, (float)data.lightmapFar.height);
                    if (dictionary.ContainsKey(key))
                    {
                        Dictionary <Vector2, int> dictionary2;
                        Vector2 vector2;
                        int     num4 = dictionary2[vector2];
                        (dictionary2 = dictionary)[vector2 = key] = num4 + 1;
                    }
                    else
                    {
                        dictionary.Add(key, 1);
                    }
                    bytes += TextureUtil.GetStorageMemorySize(data.lightmapFar);
                    if (data.lightmapNear != null)
                    {
                        bytes += TextureUtil.GetStorageMemorySize(data.lightmapNear);
                        flag   = true;
                    }
                }
            }
            object[] objArray1 = new object[] { num2, !flag ? " non-directional" : " directional", " lightmap", (num2 != 1) ? "s" : string.Empty };
            string   str       = string.Concat(objArray1);
            bool     flag2     = true;

            foreach (KeyValuePair <Vector2, int> pair in dictionary)
            {
                str   = str + (!flag2 ? ", " : ": ");
                flag2 = false;
                if (pair.Value > 1)
                {
                    str = str + pair.Value + "x";
                }
                string   str2      = str;
                object[] objArray2 = new object[] { str2, pair.Key.x, "x", pair.Key.y, "px" };
                str = string.Concat(objArray2);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(str + " ", styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(EditorUtility.FormatBytes(bytes), styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.Label((num2 != 0) ? string.Empty : "No Lightmaps", styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
        void CachePreview()
        {
            string text = string.Empty;

            if (m_TextAsset != null)
            {
                if (targets.Length > 1)
                {
                    text = targetTitle;
                }
                else if (Path.GetExtension(AssetDatabase.GetAssetPath(m_TextAsset)) != ".bytes")
                {
                    text = m_TextAsset.GetPreview(kMaxChars);
                    if (text.Length >= kMaxChars)
                    {
                        text = text.Substring(0, kMaxChars) + "...\n\n<...etc...>";
                    }
                }
                else
                {
                    text = $"{EditorUtility.FormatBytes(m_TextAsset.dataSize)} size .bytes file";
                }
            }

            m_CachedPreview = new GUIContent(text);
        }
 private void ShowGICache()
 {
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     EditorGUILayout.PrefixLabel(PreferencesWindow.Styles.maxCacheSize, EditorStyles.popup);
     this.m_GICacheSettings.m_MaximumSize = EditorGUILayout.IntSlider(this.m_GICacheSettings.m_MaximumSize, 5, 100, new GUILayoutOption[0]);
     this.WritePreferences();
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     if (Lightmapping.isRunning)
     {
         GUIContent gUIContent = EditorGUIUtility.TextContent(PreferencesWindow.Styles.cantChangeCacheSettings.text);
         EditorGUILayout.HelpBox(gUIContent.text, MessageType.Warning, true);
     }
     GUILayout.EndHorizontal();
     EditorGUI.BeginDisabledGroup(Lightmapping.isRunning);
     this.m_GICacheSettings.m_EnableCustomPath = EditorGUILayout.Toggle(PreferencesWindow.Styles.customCacheLocation, this.m_GICacheSettings.m_EnableCustomPath, new GUILayoutOption[0]);
     if (this.m_GICacheSettings.m_EnableCustomPath)
     {
         GUIStyle popup = EditorStyles.popup;
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         EditorGUILayout.PrefixLabel(PreferencesWindow.Styles.cacheFolderLocation, popup);
         Rect       rect    = GUILayoutUtility.GetRect(GUIContent.none, popup);
         GUIContent content = (!string.IsNullOrEmpty(this.m_GICacheSettings.m_CachePath)) ? new GUIContent(this.m_GICacheSettings.m_CachePath) : PreferencesWindow.Styles.browse;
         if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Native, popup))
         {
             string cachePath = this.m_GICacheSettings.m_CachePath;
             string text      = EditorUtility.OpenFolderPanel(PreferencesWindow.Styles.browseGICacheLocation.text, cachePath, string.Empty);
             if (!string.IsNullOrEmpty(text))
             {
                 this.m_GICacheSettings.m_CachePath = text;
                 this.WritePreferences();
             }
         }
         GUILayout.EndHorizontal();
     }
     else
     {
         this.m_GICacheSettings.m_CachePath = string.Empty;
     }
     this.m_GICacheSettings.m_CompressionLevel = ((!EditorGUILayout.Toggle(PreferencesWindow.Styles.cacheCompression, this.m_GICacheSettings.m_CompressionLevel == 1, new GUILayoutOption[0])) ? 0 : 1);
     if (GUILayout.Button(PreferencesWindow.Styles.cleanCache, new GUILayoutOption[]
     {
         GUILayout.Width(120f)
     }))
     {
         Lightmapping.Clear();
         Lightmapping.ClearDiskCache();
     }
     if (Lightmapping.diskCacheSize >= 0L)
     {
         GUILayout.Label(PreferencesWindow.Styles.cacheSizeIs.text + " " + EditorUtility.FormatBytes(Lightmapping.diskCacheSize), new GUILayoutOption[0]);
     }
     else
     {
         GUILayout.Label(PreferencesWindow.Styles.cacheSizeIs.text + " is being calculated...", new GUILayoutOption[0]);
     }
     GUILayout.Label(PreferencesWindow.Styles.cacheFolderLocation.text + ":", new GUILayoutOption[0]);
     GUILayout.Label(Lightmapping.diskCachePath, PreferencesWindow.constants.cacheFolderLocation, new GUILayoutOption[0]);
     EditorGUI.EndDisabledGroup();
 }
        void SummaryGUI()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            if (StaticOcclusionCulling.umbraDataSize == 0)
            {
                GUILayout.Label(s_Styles.noOcclusionData, s_Styles.labelStyle);
            }
            else
            {
                GUILayout.Label("Last bake:", s_Styles.labelStyle);

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical();
                GUILayout.Label("Occlusion data size ", s_Styles.labelStyle);
                GUILayout.EndVertical();

                GUILayout.BeginVertical();
                GUILayout.Label(EditorUtility.FormatBytes(StaticOcclusionCulling.umbraDataSize), s_Styles.labelStyle);
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
        }
示例#9
0
 protected override void DrawData(Rect rect, MemoryElement memoryElement, int indent, int row, bool selected)
 {
     if (Event.current.type == EventType.Repaint)
     {
         string text = memoryElement.name;
         if (memoryElement.ChildCount() > 0 && indent < 3)
         {
             text = text + " (" + memoryElement.AccumulatedChildCount().ToString() + ")";
         }
         int num = 0;
         rect.xMax = (float)this.m_Splitter.realSizes[num];
         MemoryTreeList.styles.numberLabel.Draw(rect, text, false, false, false, selected);
         rect.x     = rect.xMax;
         rect.width = (float)this.m_Splitter.realSizes[++num] - 4f;
         MemoryTreeList.styles.numberLabel.Draw(rect, EditorUtility.FormatBytes(memoryElement.totalMemory), false, false, false, selected);
         rect.x    += (float)this.m_Splitter.realSizes[num++];
         rect.width = (float)this.m_Splitter.realSizes[num] - 4f;
         if (memoryElement.ReferenceCount() > 0)
         {
             MemoryTreeList.styles.numberLabel.Draw(rect, memoryElement.ReferenceCount().ToString(), false, false, false, selected);
         }
         else if (selected)
         {
             MemoryTreeList.styles.numberLabel.Draw(rect, "", false, false, false, selected);
         }
     }
 }
示例#10
0
        public override string GetInfoString()
        {
            Texture3D tex    = target as Texture3D;
            var       format = TextureUtil.GetTextureFormatString(tex.format);
            var       size   = EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySizeLong(tex));
            string    info   = $"{tex.width}x{tex.height}x{tex.depth} {format} {size}";

            return(info);
        }
示例#11
0
        static void ShowIndexInfo(Mesh mesh)
        {
            var indexCount    = CalcTotalIndices(mesh);
            var indexSize     = mesh.indexFormat == IndexFormat.UInt16 ? 2 : 4;
            var bufferSizeStr = EditorUtility.FormatBytes(indexCount * indexSize);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField($"Indices: {indexCount}, {mesh.indexFormat} format ({bufferSizeStr})", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            var    subMeshCount = mesh.subMeshCount;
            string subMeshText  = subMeshCount == 1 ? "submesh" : "submeshes";

            EditorGUILayout.LabelField($"{mesh.subMeshCount} {subMeshText}:");

            for (int i = 0; i < mesh.subMeshCount; i++)
            {
                var    subMesh    = mesh.GetSubMesh(i);
                string topology   = subMesh.topology.ToString().ToLowerInvariant();
                string baseVertex = subMesh.baseVertex == 0 ? "" : ", base vertex " + subMesh.baseVertex;

                var divisor = 3;
                switch (subMesh.topology)
                {
                case MeshTopology.Points: divisor = 1; break;

                case MeshTopology.Lines: divisor = 2; break;

                case MeshTopology.Triangles: divisor = 3; break;

                case MeshTopology.Quads: divisor = 4; break;

                case MeshTopology.LineStrip: divisor = 2; break;     // technically not correct, but eh
                }

                var primCount = subMesh.indexCount / divisor;
                if (subMeshCount > 1)
                {
                    GUILayout.BeginHorizontal();
                    var rect = GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.label, GUILayout.Width(7));
                    rect.x += EditorGUI.indentLevel * 15; //@TODO: use EditorGUI.indent;
                    //rect.x += EditorGUI.indent;
                    var tint = GetSubMeshTint(i);
                    DrawColorRect(rect, tint);
                }

                EditorGUILayout.LabelField($"#{i}: {primCount} {topology} ({subMesh.indexCount} indices starting from {subMesh.indexStart}){baseVertex}");
                if (subMeshCount > 1)
                {
                    GUILayout.EndHorizontal();
                }
            }
            EditorGUI.indentLevel--;
        }
示例#12
0
        public override string GetInfoString()
        {
            Texture3D tex = target as Texture3D;

            string info = UnityString.Format("{0}x{1}x{2} {3} {4}",
                                             tex.width, tex.height, tex.depth,
                                             TextureUtil.GetTextureFormatString(tex.format),
                                             EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySizeLong(tex)));

            return(info);
        }
示例#13
0
        public override string GetInfoString()
        {
            RenderTexture target = this.target as RenderTexture;
            string        str    = target.width + "x" + target.height;

            if (!target.isPowerOfTwo)
            {
                str = str + "(NPOT)";
            }
            return((str + "  " + target.format) + "  " + EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySize(target)));
        }
示例#14
0
 public override void OnPreviewGUI(Rect r, GUIStyle background)
 {
     if (Event.current.type == EventType.Repaint)
     {
         VideoClipImporter videoClipImporter = (VideoClipImporter)this.target;
         RectOffset        rectOffset        = new RectOffset(-5, -5, -5, -5);
         r        = rectOffset.Add(r);
         r.height = EditorGUIUtility.singleLineHeight;
         Rect rect  = r;
         Rect rect2 = r;
         rect.width  = 120f;
         rect2.xMin += 120f;
         rect2.width = 200f;
         this.ShowProperty(ref rect, ref rect2, "Original Size", EditorUtility.FormatBytes((long)videoClipImporter.sourceFileSize));
         this.ShowProperty(ref rect, ref rect2, "Imported Size", EditorUtility.FormatBytes((long)videoClipImporter.outputFileSize));
         int    frameCount = videoClipImporter.frameCount;
         double frameRate  = videoClipImporter.frameRate;
         string arg_FD_0;
         if (frameRate > 0.0)
         {
             arg_FD_0 = TimeSpan.FromSeconds((double)frameCount / frameRate).ToString();
         }
         else
         {
             TimeSpan timeSpan = new TimeSpan(0L);
             arg_FD_0 = timeSpan.ToString();
         }
         string text = arg_FD_0;
         if (text.IndexOf('.') != -1)
         {
             text = text.Substring(0, text.Length - 4);
         }
         this.ShowProperty(ref rect, ref rect2, "Duration", text);
         this.ShowProperty(ref rect, ref rect2, "Frames", frameCount.ToString());
         this.ShowProperty(ref rect, ref rect2, "FPS", frameRate.ToString("F2"));
         int resizeWidth  = videoClipImporter.GetResizeWidth(VideoResizeMode.OriginalSize);
         int resizeHeight = videoClipImporter.GetResizeHeight(VideoResizeMode.OriginalSize);
         this.ShowProperty(ref rect, ref rect2, "Pixels", resizeWidth + "x" + resizeHeight);
         this.ShowProperty(ref rect, ref rect2, "PAR", videoClipImporter.pixelAspectRatioNumerator + ":" + videoClipImporter.pixelAspectRatioDenominator);
         this.ShowProperty(ref rect, ref rect2, "Alpha", (!videoClipImporter.sourceHasAlpha) ? "No" : "Yes");
         ushort sourceAudioTrackCount = videoClipImporter.sourceAudioTrackCount;
         this.ShowProperty(ref rect, ref rect2, "Audio", (sourceAudioTrackCount != 0) ? ((sourceAudioTrackCount != 1) ? "" : this.GetAudioTrackDescription(videoClipImporter, 0)) : "none");
         if (sourceAudioTrackCount > 1)
         {
             rect.xMin  += 30f;
             rect.width -= 30f;
             for (ushort num = 0; num < sourceAudioTrackCount; num += 1)
             {
                 this.ShowProperty(ref rect, ref rect2, "Track #" + (int)(num + 1), this.GetAudioTrackDescription(videoClipImporter, num));
             }
         }
     }
 }
示例#15
0
        public override string GetInfoString()
        {
            Texture2DArray tex = (Texture2DArray)target;

            string info = UnityString.Format("{0}x{1} {2} slice{5} {3} {4}",
                                             tex.width, tex.height, tex.depth,
                                             TextureUtil.GetTextureFormatString(tex.format),
                                             EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySizeLong(tex)),
                                             tex.depth != 1 ? "s" : "");

            return(info);
        }
        public override string GetInfoString()
        {
            RenderTexture renderTexture = base.target as RenderTexture;
            string        text          = renderTexture.width + "x" + renderTexture.height;

            if (!renderTexture.isPowerOfTwo)
            {
                text += "(NPOT)";
            }
            text = text + "  " + renderTexture.format;
            return(text + "  " + EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySize(renderTexture)));
        }
示例#17
0
 private void CommandBufferGUI()
 {
     if (base.targets.Length == 1)
     {
         Camera target = base.target as Camera;
         if (target != null)
         {
             int commandBufferCount = target.commandBufferCount;
             if (commandBufferCount != 0)
             {
                 this.m_CommandBuffersShown = GUILayout.Toggle(this.m_CommandBuffersShown, GUIContent.Temp(commandBufferCount + " command buffers"), EditorStyles.foldout, new GUILayoutOption[0]);
                 if (this.m_CommandBuffersShown)
                 {
                     EditorGUI.indentLevel++;
                     foreach (CameraEvent event2 in (CameraEvent[])Enum.GetValues(typeof(CameraEvent)))
                     {
                         CommandBuffer[] commandBuffers = target.GetCommandBuffers(event2);
                         foreach (CommandBuffer buffer in commandBuffers)
                         {
                             using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
                             {
                                 Rect r = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel);
                                 r.xMin += EditorGUI.indent;
                                 Rect removeButtonRect = GetRemoveButtonRect(r);
                                 r.xMax = removeButtonRect.x;
                                 GUI.Label(r, $"{event2}: {buffer.name} ({EditorUtility.FormatBytes(buffer.sizeInBytes)})", EditorStyles.miniLabel);
                                 if (GUI.Button(removeButtonRect, Styles.iconRemove, Styles.invisibleButton))
                                 {
                                     target.RemoveCommandBuffer(event2, buffer);
                                     SceneView.RepaintAll();
                                     GameView.RepaintAll();
                                     GUIUtility.ExitGUI();
                                 }
                             }
                         }
                     }
                     using (new GUILayout.HorizontalScope(new GUILayoutOption[0]))
                     {
                         GUILayout.FlexibleSpace();
                         if (GUILayout.Button("Remove all", EditorStyles.miniButton, new GUILayoutOption[0]))
                         {
                             target.RemoveAllCommandBuffers();
                             SceneView.RepaintAll();
                             GameView.RepaintAll();
                         }
                     }
                     EditorGUI.indentLevel--;
                 }
             }
         }
     }
 }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            for (int i = 0; i < targets.Length; i++)
            {
                var newCount = EditorUtility.GetDirtyCount(targets[i]);
                if (m_DirtyCount[i] != newCount)
                {
                    InitializeExtraDataInstance(extraDataTargets[i], i);
                }
            }

            extraDataSerializedObject.Update();

            OnAudioImporterGUI(m_SelectionContainsTrackerFile);

            int origSize = 0, compSize = 0;

            foreach (AudioImporter importer in GetAllAudioImporterTargets())
            {
                origSize += importer.origSize;
                compSize += importer.compSize;
            }

            GUILayout.Space(10);

            EditorGUILayout.HelpBox("Original Size: \t" + EditorUtility.FormatBytes(origSize) + "\nImported Size: \t" + EditorUtility.FormatBytes(compSize) + "\n" +
                                    "Ratio: \t\t" + (100.0f * (float)compSize / (float)origSize).ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + "%", MessageType.Info);

            if (CurrentPlatformHasAutoTranslatedCompression())
            {
                GUILayout.Space(10);
                EditorGUILayout.HelpBox("The selection contains different compression formats to the default settings for the current build platform.", MessageType.Info);
            }

            if (CurrentSelectionContainsHardwareSounds())
            {
                GUILayout.Space(10);
                EditorGUILayout.HelpBox("The selection contains sounds that are decompressed in hardware. Advanced mixing is not available for these sounds.", MessageType.Info);
            }

            extraDataSerializedObject.ApplyModifiedProperties();
            serializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();

            for (int i = 0; i < targets.Length; i++)
            {
                m_DirtyCount[i] = EditorUtility.GetDirtyCount(targets[i]);
            }
        }
示例#19
0
        public override string GetInfoString()
        {
            Texture3D texture3D = base.target as Texture3D;

            return(string.Format("{0}x{1}x{2} {3} {4}", new object[]
            {
                texture3D.width,
                texture3D.height,
                texture3D.depth,
                TextureUtil.GetTextureFormatString(texture3D.format),
                EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySizeLong(texture3D))
            }));
        }
        protected override void DrawData(Rect rect, MemoryElement memoryElement, int indent, int row, bool selected)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            string text = memoryElement.name;

            if (memoryElement.ChildCount() > 0 && indent < 3)
            {
                text = text + " (" + memoryElement.AccumulatedChildCount().ToString() + ")";
            }
            int index1 = 0;

            rect.xMax = (float)this.m_Splitter.realSizes[index1];
            MemoryTreeList.styles.numberLabel.Draw(rect, text, false, false, false, selected);
            rect.x = rect.xMax;
            int num1;

            rect.width = (float)this.m_Splitter.realSizes[num1 = index1 + 1] - 4f;
            MemoryTreeList.styles.numberLabel.Draw(rect, EditorUtility.FormatBytes(memoryElement.totalMemory), false, false, false, selected);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Rect& local = @rect;
            // ISSUE: explicit reference operation
            double x = (double)(^ local).x;

            int[]  realSizes = this.m_Splitter.realSizes;
            int    index2    = num1;
            int    num2      = 1;
            int    index3    = index2 + num2;
            double num3      = (double)realSizes[index2];
            double num4      = x + num3;

            // ISSUE: explicit reference operation
            (^ local).x = (float)num4;
            rect.width  = (float)this.m_Splitter.realSizes[index3] - 4f;
            if (memoryElement.ReferenceCount() > 0)
            {
                MemoryTreeList.styles.numberLabel.Draw(rect, memoryElement.ReferenceCount().ToString(), false, false, false, selected);
            }
            else
            {
                if (!selected)
                {
                    return;
                }
                MemoryTreeList.styles.numberLabel.Draw(rect, string.Empty, false, false, false, selected);
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            bool selectionContainsTrackerFile = false;

            foreach (AudioImporter importer in GetAllAudioImporterTargets())
            {
                string assetPath = importer.assetPath;
                string ext       = FileUtil.GetPathExtension(assetPath).ToLowerInvariant();
                if (ext == "mod" || ext == "it" || ext == "s3m" || ext == "xm")
                {
                    selectionContainsTrackerFile = true;
                    break;
                }
            }

            OnAudioImporterGUI(selectionContainsTrackerFile);

            int origSize = 0, compSize = 0;

            foreach (AudioImporter importer in GetAllAudioImporterTargets())
            {
                origSize += importer.origSize;
                compSize += importer.compSize;
            }

            GUILayout.Space(10);

            EditorGUILayout.HelpBox("Original Size: \t" + EditorUtility.FormatBytes(origSize) + "\nImported Size: \t" + EditorUtility.FormatBytes(compSize) + "\n" +
                                    "Ratio: \t\t" + (100.0f * (float)compSize / (float)origSize).ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + "%", MessageType.Info);


            if (CurrentPlatformHasAutoTranslatedCompression())
            {
                GUILayout.Space(10);
                EditorGUILayout.HelpBox("The selection contains different compression formats to the default settings for the current build platform.", MessageType.Info);
            }

            if (CurrentSelectionContainsHardwareSounds())
            {
                GUILayout.Space(10);
                EditorGUILayout.HelpBox("The selection contains sounds that are decompressed in hardware. Advanced mixing is not available for these sounds.", MessageType.Info);
            }

            serializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();
        }
示例#22
0
 private void SummaryGUI()
 {
     GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
     if (StaticOcclusionCulling.umbraDataSize == 0)
     {
         GUILayout.Label(OcclusionCullingWindow.s_Styles.noOcclusionData, OcclusionCullingWindow.s_Styles.labelStyle, new GUILayoutOption[0]);
     }
     else
     {
         GUILayout.Label("Last bake:", OcclusionCullingWindow.s_Styles.labelStyle, new GUILayoutOption[0]);
         GUILayout.BeginHorizontal();
         GUILayout.BeginVertical();
         GUILayout.Label("Occlusion data size ", OcclusionCullingWindow.s_Styles.labelStyle, new GUILayoutOption[0]);
         GUILayout.EndVertical();
         GUILayout.BeginVertical();
         GUILayout.Label(EditorUtility.FormatBytes(StaticOcclusionCulling.umbraDataSize), OcclusionCullingWindow.s_Styles.labelStyle, new GUILayoutOption[0]);
         GUILayout.EndVertical();
         GUILayout.EndHorizontal();
     }
     GUILayout.EndVertical();
 }
示例#23
0
        public override string GetInfoString()
        {
            RenderTexture renderTexture = base.target as RenderTexture;
            string        text          = renderTexture.width + "x" + renderTexture.height;

            if (renderTexture.dimension == TextureDimension.Tex3D)
            {
                text = text + "x" + renderTexture.volumeDepth;
            }
            if (!renderTexture.isPowerOfTwo)
            {
                text += "(NPOT)";
            }
            if (QualitySettings.desiredColorSpace == ColorSpace.Linear)
            {
                bool flag  = RenderTextureEditor.IsHDRFormat(renderTexture.format);
                bool flag2 = renderTexture.sRGB && !flag;
                text = text + " " + ((!flag2) ? "Linear" : "sRGB");
            }
            text = text + "  " + renderTexture.format;
            return(text + "  " + EditorUtility.FormatBytes(TextureUtil.GetRuntimeMemorySizeLong(renderTexture)));
        }
        public override void OnInspectorGUI()
        {
            this.serializedObject.UpdateIfDirtyOrScript();
            bool selectionContainsTrackerFile = false;

            foreach (AssetImporter audioImporterTarget in this.GetAllAudioImporterTargets())
            {
                string lowerInvariant = FileUtil.GetPathExtension(audioImporterTarget.assetPath).ToLowerInvariant();
                if (lowerInvariant == "mod" || lowerInvariant == "it" || (lowerInvariant == "s3m" || lowerInvariant == "xm"))
                {
                    selectionContainsTrackerFile = true;
                    break;
                }
            }
            this.OnAudioImporterGUI(selectionContainsTrackerFile);
            int bytes1 = 0;
            int bytes2 = 0;

            foreach (AudioImporter audioImporterTarget in this.GetAllAudioImporterTargets())
            {
                bytes1 += audioImporterTarget.origSize;
                bytes2 += audioImporterTarget.compSize;
            }
            GUILayout.Space(10f);
            EditorGUILayout.HelpBox("Original Size: \t" + EditorUtility.FormatBytes(bytes1) + "\nImported Size: \t" + EditorUtility.FormatBytes(bytes2) + "\nRatio: \t\t" + (100f * (float)bytes2 / (float)bytes1).ToString("0.00") + "%", MessageType.Info);
            if (this.CurrentPlatformHasAutoTranslatedCompression())
            {
                GUILayout.Space(10f);
                EditorGUILayout.HelpBox("The selection contains different compression formats to the default settings for the current build platform.", MessageType.Info);
            }
            if (this.CurrentSelectionContainsHardwareSounds())
            {
                GUILayout.Space(10f);
                EditorGUILayout.HelpBox("The selection contains sounds that are decompressed in hardware. Advanced mixing is not available for these sounds.", MessageType.Info);
            }
            this.ApplyRevertGUI();
        }
示例#25
0
        static void ShowVertexInfo(Mesh mesh)
        {
            int vSize = 0;

            //EditorGUILayout.LabelField($"Vertices: {mesh.vertexCount} ({bufferSizeStr})", EditorStyles.boldLabel);
            EditorGUILayout.LabelField($"Vertices: {mesh.vertexCount}", EditorStyles.boldLabel);

            EditorGUI.indentLevel++;
            if (mesh.colors.Length != 0)
            {
                EditorGUILayout.LabelField("colors", $"byte x 4 (4 bytes)"); vSize += 4;
            }
            if (mesh.normals.Length != 0)
            {
                EditorGUILayout.LabelField("normals", $"float x 3 (12 bytes)"); vSize += 12;
            }
            if (mesh.tangents.Length != 0)
            {
                EditorGUILayout.LabelField("tangents", $"float x 4 (16 bytes)"); vSize += 16;
            }

            for (int i = 0; i < 8; i++)
            {
                List <Vector4> uvs = new List <Vector4>();
                mesh.GetUVs(i, uvs);
                if (uvs.Count != 0)
                {
                    EditorGUILayout.LabelField($"uv{i+1}", "float x 4 (16 bytes)");
                    vSize += 16;
                }
            }
            EditorGUI.indentLevel--;

            var bufferSizeStr = EditorUtility.FormatBytes(mesh.vertexCount * vSize);

            EditorGUILayout.LabelField($"Total size: ({bufferSizeStr})", EditorStyles.boldLabel);
        }
示例#26
0
        static void ShowVertexInfo(Mesh mesh, VertexAttributeDescriptor[] attributes)
        {
            var vertexSize    = attributes.Sum(attr => ConvertFormatToSize(attr.format) * attr.dimension);
            var bufferSizeStr = EditorUtility.FormatBytes(mesh.vertexCount * vertexSize);

            EditorGUILayout.LabelField($"Vertices: {mesh.vertexCount} ({bufferSizeStr})", EditorStyles.boldLabel);

            EditorGUI.indentLevel++;
            foreach (var a in attributes)
            {
                // skin related attributes listed separately
                if (a.attribute == VertexAttribute.BlendIndices || a.attribute == VertexAttribute.BlendWeight)
                {
                    continue;
                }
                var title = a.attribute.ToString();
                if (title.Contains("TexCoord"))
                {
                    title = title.Replace("TexCoord", "UV");
                }
                EditorGUILayout.LabelField(title, GetAttributeString(a));
            }
            EditorGUI.indentLevel--;
        }
示例#27
0
        private void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            int num  = 0;
            int num2 = 0;
            Dictionary <Vector2, int> dictionary = new Dictionary <Vector2, int>();
            bool flag = false;

            LightmapData[] lightmaps = LightmapSettings.lightmaps;
            for (int i = 0; i < lightmaps.Length; i++)
            {
                LightmapData lightmapData = lightmaps[i];
                if (!(lightmapData.lightmapFar == null))
                {
                    num2++;
                    Vector2 vector = new Vector2((float)lightmapData.lightmapFar.width, (float)lightmapData.lightmapFar.height);
                    if (dictionary.ContainsKey(vector))
                    {
                        Dictionary <Vector2, int> dictionary2;
                        Dictionary <Vector2, int> expr_7C = dictionary2 = dictionary;
                        Vector2 key;
                        Vector2 expr_81 = key = vector;
                        int     num3    = dictionary2[key];
                        expr_7C[expr_81] = num3 + 1;
                    }
                    else
                    {
                        dictionary.Add(vector, 1);
                    }
                    num += TextureUtil.GetStorageMemorySize(lightmapData.lightmapFar);
                    if (lightmapData.lightmapNear)
                    {
                        num += TextureUtil.GetStorageMemorySize(lightmapData.lightmapNear);
                        flag = true;
                    }
                }
            }
            string text = string.Concat(new object[]
            {
                num2,
                (!flag) ? " non-directional" : " directional",
                " lightmap",
                (num2 != 1) ? "s" : string.Empty
            });
            bool flag2 = true;

            foreach (KeyValuePair <Vector2, int> current in dictionary)
            {
                text += ((!flag2) ? ", " : ": ");
                flag2 = false;
                if (current.Value > 1)
                {
                    text = text + current.Value + "x";
                }
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    current.Key.x,
                    "x",
                    current.Key.y,
                    "px"
                });
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(text + " ", LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(EditorUtility.FormatBytes(num), LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.Label((num2 != 0) ? string.Empty : "No Lightmaps", LightingWindow.styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
示例#28
0
        void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            long totalMemorySize            = 0;
            int  lightmapCount              = 0;
            Dictionary <Vector2, int> sizes = new Dictionary <Vector2, int>();
            bool directionalLightmapsMode   = false;
            bool shadowmaskMode             = false;

            foreach (LightmapData ld in LightmapSettings.lightmaps)
            {
                if (ld.lightmapColor == null)
                {
                    continue;
                }
                lightmapCount++;

                Vector2 texSize = new Vector2(ld.lightmapColor.width, ld.lightmapColor.height);
                if (sizes.ContainsKey(texSize))
                {
                    sizes[texSize]++;
                }
                else
                {
                    sizes.Add(texSize, 1);
                }

                totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.lightmapColor);
                if (ld.lightmapDir)
                {
                    totalMemorySize         += TextureUtil.GetStorageMemorySizeLong(ld.lightmapDir);
                    directionalLightmapsMode = true;
                }
                if (ld.shadowMask)
                {
                    totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.shadowMask);
                    shadowmaskMode   = true;
                }
            }
            StringBuilder sizesString = new StringBuilder();

            sizesString.Append(lightmapCount);
            sizesString.Append((directionalLightmapsMode ? " Directional" : " Non-Directional"));
            sizesString.Append(" Lightmap");
            if (lightmapCount != 1)
            {
                sizesString.Append("s");
            }
            if (shadowmaskMode)
            {
                sizesString.Append(" with Shadowmask");
                if (lightmapCount != 1)
                {
                    sizesString.Append("s");
                }
            }

            bool first = true;

            foreach (var s in sizes)
            {
                sizesString.Append(first ? ": " : ", ");
                first = false;
                if (s.Value > 1)
                {
                    sizesString.Append(s.Value);
                    sizesString.Append("x");
                }
                sizesString.Append(s.Key.x.ToString(CultureInfo.InvariantCulture.NumberFormat));
                sizesString.Append("x");
                sizesString.Append(s.Key.y.ToString(CultureInfo.InvariantCulture.NumberFormat));
                sizesString.Append("px");
            }
            sizesString.Append(" ");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Label(sizesString.ToString(), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.Label(EditorUtility.FormatBytes(totalMemorySize), Styles.LabelStyle);
            GUILayout.Label((lightmapCount == 0 ? "No Lightmaps" : ""), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            if (LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten)
            {
                GUILayout.BeginVertical();
                GUILayout.Label("Occupied Texels: " + InternalEditorUtility.CountToString(Lightmapping.occupiedTexelCount), Styles.LabelStyle);
                if (Lightmapping.isRunning)
                {
                    int numLightmapsInView             = 0;
                    int numConvergedLightmapsInView    = 0;
                    int numNotConvergedLightmapsInView = 0;

                    int numLightmapsNotInView             = 0;
                    int numConvergedLightmapsNotInView    = 0;
                    int numNotConvergedLightmapsNotInView = 0;

                    int numLightmaps = LightmapSettings.lightmaps.Length;
                    for (int i = 0; i < numLightmaps; ++i)
                    {
                        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(i);
                        if (!lc.IsValid())
                        {
                            continue;
                        }

                        if (Lightmapping.GetVisibleTexelCount(i) > 0)
                        {
                            numLightmapsInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsInView++;
                            }
                        }
                        else
                        {
                            numLightmapsNotInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsNotInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsNotInView++;
                            }
                        }
                    }
                    if (Lightmapping.atlasCount > 0)
                    {
                        int convergedMaps = numConvergedLightmapsInView + numConvergedLightmapsNotInView;
                        GUILayout.Label("Lightmap convergence: (" + convergedMaps + "/" + Lightmapping.atlasCount + ")", Styles.LabelStyle);
                    }
                    EditorGUILayout.LabelField("Lightmaps in view: " + numLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;
                    EditorGUILayout.LabelField("Lightmaps not in view: " + numLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;

                    LightProbesConvergence lpc = Lightmapping.GetLightProbesConvergence();
                    if (lpc.IsValid() && lpc.probeSetCount > 0)
                    {
                        GUILayout.Label("Light Probes convergence: (" + lpc.convergedProbeSetCount + "/" + lpc.probeSetCount + ")", Styles.LabelStyle);
                    }
                }
                float bakeTime    = Lightmapping.GetLightmapBakeTimeTotal();
                float mraysPerSec = Lightmapping.GetLightmapBakePerformanceTotal();
                if (mraysPerSec >= 0.0)
                {
                    GUILayout.Label("Bake Performance: " + mraysPerSec.ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + " mrays/sec", Styles.LabelStyle);
                }
                if (!Lightmapping.isRunning)
                {
                    float bakeTimeRaw = Lightmapping.GetLightmapBakeTimeRaw();
                    if (bakeTime >= 0.0)
                    {
                        int time  = (int)bakeTime;
                        int timeH = time / 3600;
                        time -= 3600 * timeH;
                        int timeM = time / 60;
                        time -= 60 * timeM;
                        int timeS = time;

                        int timeRaw  = (int)bakeTimeRaw;
                        int timeRawH = timeRaw / 3600;
                        timeRaw -= 3600 * timeRawH;
                        int timeRawM = timeRaw / 60;
                        timeRaw -= 60 * timeRawM;
                        int timeRawS = timeRaw;

                        int oHeadTime  = Math.Max(0, (int)(bakeTime - bakeTimeRaw));
                        int oHeadTimeH = oHeadTime / 3600;
                        oHeadTime -= 3600 * oHeadTimeH;
                        int oHeadTimeM = oHeadTime / 60;
                        oHeadTime -= 60 * oHeadTimeM;
                        int oHeadTimeS = oHeadTime;


                        GUILayout.Label("Total Bake Time: " + timeH.ToString("0") + ":" + timeM.ToString("00") + ":" + timeS.ToString("00"), Styles.LabelStyle);
                        if (Unsupported.IsDeveloperBuild())
                        {
                            GUILayout.Label("(Raw Bake Time: " + timeRawH.ToString("0") + ":" + timeRawM.ToString("00") + ":" + timeRawS.ToString("00") + ", Overhead: " + oHeadTimeH.ToString("0") + ":" + oHeadTimeM.ToString("00") + ":" + oHeadTimeS.ToString("00") + ")", Styles.LabelStyle);
                        }
                    }
                }
                string deviceName = Lightmapping.GetLightmapBakeGPUDeviceName();
                if (deviceName.Length > 0)
                {
                    GUILayout.Label("Baking device: " + deviceName, Styles.LabelStyle);
                }
                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }
		public static void OnGUI()
		{
			EventType type = Event.current.type;
			if (CacheServerPreferences.s_Constants == null)
			{
				CacheServerPreferences.s_Constants = new CacheServerPreferences.Constants();
			}
			if (!InternalEditorUtility.HasTeamLicense())
			{
				GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
			}
			using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
			{
				if (!CacheServerPreferences.s_PrefsLoaded)
				{
					CacheServerPreferences.ReadPreferences();
					if (CacheServerPreferences.s_CacheServerMode != CacheServerPreferences.CacheServerMode.Disabled && CacheServerPreferences.s_ConnectionState == CacheServerPreferences.ConnectionState.Unknown)
					{
						if (InternalEditorUtility.CanConnectToCacheServer())
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
						}
						else
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
						}
					}
					CacheServerPreferences.s_PrefsLoaded = true;
				}
				EditorGUI.BeginChangeCheck();
				CacheServerPreferences.s_CacheServerMode = (CacheServerPreferences.CacheServerMode)EditorGUILayout.EnumPopup("Cache Server Mode", CacheServerPreferences.s_CacheServerMode, new GUILayoutOption[0]);
				if (CacheServerPreferences.s_CacheServerMode == CacheServerPreferences.CacheServerMode.Remote)
				{
					CacheServerPreferences.s_CacheServerIPAddress = EditorGUILayout.DelayedTextField("IP Address", CacheServerPreferences.s_CacheServerIPAddress, new GUILayoutOption[0]);
					if (GUI.changed)
					{
						CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Unknown;
					}
					GUILayout.Space(5f);
					if (GUILayout.Button("Check Connection", new GUILayoutOption[]
					{
						GUILayout.Width(150f)
					}))
					{
						if (InternalEditorUtility.CanConnectToCacheServer())
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
						}
						else
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
						}
					}
					GUILayout.Space(-25f);
					CacheServerPreferences.ConnectionState connectionState = CacheServerPreferences.s_ConnectionState;
					if (connectionState != CacheServerPreferences.ConnectionState.Success)
					{
						if (connectionState != CacheServerPreferences.ConnectionState.Failure)
						{
							if (connectionState == CacheServerPreferences.ConnectionState.Unknown)
							{
								GUILayout.Space(44f);
							}
						}
						else
						{
							EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
						}
					}
					else
					{
						EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
					}
				}
				else if (CacheServerPreferences.s_CacheServerMode == CacheServerPreferences.CacheServerMode.Local)
				{
					CacheServerPreferences.s_LocalCacheServerSize = EditorGUILayout.IntSlider(CacheServerPreferences.Styles.maxCacheSize, CacheServerPreferences.s_LocalCacheServerSize, 1, 200, new GUILayoutOption[0]);
					CacheServerPreferences.s_EnableCustomPath = EditorGUILayout.Toggle(CacheServerPreferences.Styles.customCacheLocation, CacheServerPreferences.s_EnableCustomPath, new GUILayoutOption[0]);
					if (CacheServerPreferences.s_EnableCustomPath)
					{
						GUIStyle miniButton = EditorStyles.miniButton;
						GUILayout.BeginHorizontal(new GUILayoutOption[0]);
						EditorGUILayout.PrefixLabel(CacheServerPreferences.Styles.cacheFolderLocation, miniButton);
						Rect rect = GUILayoutUtility.GetRect(GUIContent.none, miniButton);
						GUIContent content = (!string.IsNullOrEmpty(CacheServerPreferences.s_CachePath)) ? new GUIContent(CacheServerPreferences.s_CachePath) : CacheServerPreferences.Styles.browse;
						if (EditorGUI.DropdownButton(rect, content, FocusType.Passive, miniButton))
						{
							string folder = CacheServerPreferences.s_CachePath;
							string text = EditorUtility.OpenFolderPanel(CacheServerPreferences.Styles.browseCacheLocation.text, folder, "");
							if (!string.IsNullOrEmpty(text))
							{
								if (LocalCacheServer.CheckValidCacheLocation(text))
								{
									CacheServerPreferences.s_CachePath = text;
									CacheServerPreferences.WritePreferences();
								}
								else
								{
									EditorUtility.DisplayDialog("Invalid Cache Location", "The directory " + text + " contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", "OK");
								}
								GUIUtility.ExitGUI();
							}
						}
						GUILayout.EndHorizontal();
					}
					else
					{
						CacheServerPreferences.s_CachePath = "";
					}
					bool flag = LocalCacheServer.CheckCacheLocationExists();
					if (flag)
					{
						GUIContent label = EditorGUIUtility.TextContent("Cache size is unknown");
						if (CacheServerPreferences.s_LocalCacheServerUsedSize != -1L)
						{
							label = EditorGUIUtility.TextContent("Cache size is " + EditorUtility.FormatBytes(CacheServerPreferences.s_LocalCacheServerUsedSize));
						}
						GUILayout.BeginHorizontal(new GUILayoutOption[0]);
						GUIStyle miniButton2 = EditorStyles.miniButton;
						EditorGUILayout.PrefixLabel(label, miniButton2);
						Rect rect2 = GUILayoutUtility.GetRect(GUIContent.none, miniButton2);
						if (EditorGUI.Button(rect2, CacheServerPreferences.Styles.enumerateCache, miniButton2))
						{
							CacheServerPreferences.s_LocalCacheServerUsedSize = ((!LocalCacheServer.CheckCacheLocationExists()) ? 0L : FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation()));
						}
						GUILayout.EndHorizontal();
						GUILayout.BeginHorizontal(new GUILayoutOption[0]);
						GUIContent blankContent = EditorGUIUtility.blankContent;
						EditorGUILayout.PrefixLabel(blankContent, miniButton2);
						Rect rect3 = GUILayoutUtility.GetRect(GUIContent.none, miniButton2);
						if (EditorGUI.Button(rect3, CacheServerPreferences.Styles.cleanCache, miniButton2))
						{
							LocalCacheServer.Clear();
							CacheServerPreferences.s_LocalCacheServerUsedSize = 0L;
						}
						GUILayout.EndHorizontal();
					}
					else
					{
						EditorGUILayout.HelpBox("Local cache directory does not exist - please check that you can access the cache folder and are able to write to it", MessageType.Warning, false);
						CacheServerPreferences.s_LocalCacheServerUsedSize = -1L;
					}
					GUILayout.Label(CacheServerPreferences.Styles.cacheFolderLocation.text + ":", new GUILayoutOption[0]);
					GUILayout.Label(LocalCacheServer.GetCacheLocation(), CacheServerPreferences.s_Constants.cacheFolderLocation, new GUILayoutOption[0]);
				}
				if (EditorGUI.EndChangeCheck())
				{
					CacheServerPreferences.s_HasPendingChanges = true;
				}
				if (CacheServerPreferences.s_HasPendingChanges && GUIUtility.hotControl == 0)
				{
					CacheServerPreferences.s_HasPendingChanges = false;
					CacheServerPreferences.WritePreferences();
					CacheServerPreferences.ReadPreferences();
				}
			}
		}
示例#30
0
        private void CommandBufferGUI()
        {
            // Command buffers are not serialized data, so can't get to them through
            // serialized property (hence no multi-edit).
            if (targets.Length != 1)
            {
                return;
            }
            var cam = target as Camera;

            if (cam == null)
            {
                return;
            }
            int count = cam.commandBufferCount;

            if (count == 0)
            {
                return;
            }

            m_CommandBuffersShown = GUILayout.Toggle(m_CommandBuffersShown, GUIContent.Temp(count + " command buffers"), EditorStyles.foldout);
            if (!m_CommandBuffersShown)
            {
                return;
            }
            EditorGUI.indentLevel++;
            foreach (CameraEvent ce in (CameraEvent[])System.Enum.GetValues(typeof(CameraEvent)))
            {
                CommandBuffer[] cbs = cam.GetCommandBuffers(ce);
                foreach (CommandBuffer cb in cbs)
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        // row with event & command buffer information label
                        Rect rowRect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel);
                        rowRect.xMin += EditorGUI.indent;
                        Rect minusRect = GetRemoveButtonRect(rowRect);
                        rowRect.xMax = minusRect.x;
                        GUI.Label(rowRect, string.Format("{0}: {1} ({2})", ce, cb.name, EditorUtility.FormatBytes(cb.sizeInBytes)), EditorStyles.miniLabel);
                        // and a button to remove it
                        if (GUI.Button(minusRect, Styles.iconRemove, Styles.invisibleButton))
                        {
                            cam.RemoveCommandBuffer(ce, cb);
                            SceneView.RepaintAll();
                            PlayModeView.RepaintAll();
                            GUIUtility.ExitGUI();
                        }
                    }
                }
            }
            // "remove all" button
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Remove all", EditorStyles.miniButton))
                {
                    cam.RemoveAllCommandBuffers();
                    SceneView.RepaintAll();
                    PlayModeView.RepaintAll();
                }
            }
            EditorGUI.indentLevel--;
        }