/// <summary>
        /// 获取 GPU 数据,返回根元素
        /// </summary>
        /// <param name="writer"></param>
        public static GPUElement GetGPUDetail(StreamWriter writer)
        {
            if (IsWindowEmpty())
            {
                return(null);
            }

            if (IsPropertyEmpty())
            {
                return(null);
            }

            return(GPUElement.Create(CPUOrGPUproperty));
        }
Ejemplo n.º 2
0
        public static GPUElement Create(UnityEditorInternal.ProfilerProperty root)
        {
            allGPUEle = new List <GPUElement>();
            if (allGPUEle == null)
            {
                return(null);
            }
            if (root == null)
            {
                return(null);
            }
            GPUElement rootEle = new GPUElement
            {
                FuncName        = root.propertyName,
                TotalGPUPercent = root.GetColumn(ProfilerColumn.TotalGPUPercent),
                SelfGPUPercent  = root.GetColumn(ProfilerColumn.SelfGPUPercent),
                DrawCalls       = root.GetColumn(ProfilerColumn.DrawCalls),
                TotalGPUTime    = root.GetColumn(ProfilerColumn.TotalGPUTime),
                SelfGPUTime     = root.GetColumn(ProfilerColumn.SelfGPUTime),
                RelatedObjName  = root.GetColumn(ProfilerColumn.ObjectName),
                Depth           = root.depth
            };

            if (allGPUEle != null)
            {
                allGPUEle.Add(rootEle);
            }

            while (root.Next(root.HasChildren))
            {
                GPUElement ele = new GPUElement
                {
                    FuncName        = root.propertyName,
                    TotalGPUPercent = root.GetColumn(ProfilerColumn.TotalGPUPercent),
                    DrawCalls       = root.GetColumn(ProfilerColumn.DrawCalls),
                    TotalGPUTime    = root.GetColumn(ProfilerColumn.TotalGPUTime),
                    RelatedObjName  = root.GetColumn(ProfilerColumn.ObjectName),
                    Depth           = root.depth
                };
                if (allGPUEle != null)
                {
                    allGPUEle.Add(ele);
                }
            }

            SetChildren();
            return(rootEle);
        }
        /// <summary>
        /// 从跟打印所有GPU数据
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="root"></param>
        public static void WriteGPU(StreamWriter writer, GPUElement root)
        {
            if (root == null)
            {
                return;
            }

            writer.WriteLine(root.ToString());
            if (root.children == null)
            {
                return;
            }

            foreach (var child in root.children)
            {
                WriteGPU(writer, child);
            }
        }