예제 #1
0
        static void GetSpriteStats(Sprite s, ref ObjectStatInfo ret)
        {
            if (s == null)
            {
                return;
            }

            ret.sprite_packed += s.packed ? 1u : 0u;
            ret.mesh_tris     += (ulong)(s.triangles.LongLength / 3);

            if (s.texture != null)
            {
                if (!ret.texture_total.Contains(s.texture.GetInstanceID()))
                {
                    ret.texture_memory += (double)Profiler.GetRuntimeMemorySizeLong(s.texture);
                    ret.texture_total.Add(s.texture.GetInstanceID());
                }
            }

            if (GetAssociatedAlphaSplitTexture(s) != null)
            {
                if (!ret.texture_total.Contains(GetAssociatedAlphaSplitTexture(s).GetInstanceID()))
                {
                    ret.texture_memory += (double)Profiler.GetRuntimeMemorySizeLong(GetAssociatedAlphaSplitTexture(s));
                    ret.texture_total.Add(GetAssociatedAlphaSplitTexture(s).GetInstanceID());
                }
            }
        }
예제 #2
0
        static void GetAnimationClipStats(Animator a, ref ObjectStatInfo ret)
        {
            RuntimeAnimatorController rac = a.runtimeAnimatorController;

            if (rac == null)
            {
                return;
            }

            AnimationClip[] acs = rac.animationClips;
            if (acs == null)
            {
                return;
            }

            for (int i = 0; i < acs.Length; ++i)
            {
                if (acs[i] == null)
                {
                    continue;
                }

                /* First encounter. */
                if (!ret.anim_total.Contains(acs[i].GetInstanceID()))
                {
                    ret.anim_memory += (double)Profiler.GetRuntimeMemorySizeLong(acs[i]);
                    ret.anim_total.Add(acs[i].GetInstanceID());
                }
            }
        }
예제 #3
0
        static void GetTextureStats(Material m, ref ObjectStatInfo ret)
        {
            if (m == null)
            {
                return;
            }

            Shader s = m.shader;

            if (s == null)
            {
                return;
            }

            for (int i = 0; i < ShaderUtil.GetPropertyCount(s); ++i)
            {
                if (ShaderUtil.GetPropertyType(s, i) != ShaderUtil.ShaderPropertyType.TexEnv)
                {
                    continue;
                }

                Texture t = m.GetTexture(ShaderUtil.GetPropertyName(s, i));
                if (t == null)
                {
                    continue;
                }

                /* First encounter. */
                if (!ret.texture_total.Contains(t.GetInstanceID()))
                {
                    ret.texture_memory += (double)Profiler.GetRuntimeMemorySizeLong(t);
                    ret.texture_total.Add(t.GetInstanceID());
                }
            }
        }
예제 #4
0
        static void GetMaterialStats(Material[] mats, ref ObjectStatInfo ret, GameObject parent)
        {
            if (mats == null)
            {
                return;
            }

            for (int i = 0; i < mats.Length; ++i)
            {
                if (mats[i] == null)
                {
                    continue;
                }

                /* First time we encounter or is an instance. */
                if (!ret.mat_total.Contains(mats[i].GetInstanceID()))
                {
                    ret.shader_passes += (ulong)mats[i].passCount;
                    ret.mat_memory    += (double)Profiler.GetRuntimeMemorySizeLong(mats[i]);
                    ret.mat_total.Add(mats[i].GetInstanceID());

                    /* Get all textures from shader. */
                    GetTextureStats(mats[i], ref ret);
                }

                /* Is an instance. */
                if (mats[i].name.Contains("Instance"))
                {
                    ++ret.mat_instances;
                    ret.mat_instances_log.AppendLine("    " + parent.name + " : " + mats[i].name);
                }
            }
        }
예제 #5
0
        static void GetSharedMeshStats(Mesh sm, ref ObjectStatInfo ret, bool is_static_batched, GameObject parent)
        {
            if (sm == null)
            {
                return;
            }

            /* First time we encounter or is an instance. */
            if (!ret.mesh_total.Contains(sm.GetInstanceID()))
            {
                ret.mesh_memory += (double)Profiler.GetRuntimeMemorySizeLong(sm);
                ret.mesh_tris   += (ulong)(sm.triangles.LongLength / 3);
                ret.mesh_total.Add(sm.GetInstanceID());
            }
            else if (!is_static_batched)
            {
                ret.mesh_tris += (ulong)(sm.triangles.LongLength / 3);
            }

            /* Is an instance. */
            if (sm.name.Contains("Instance"))
            {
                ++ret.mesh_instances;
                ret.mesh_instances_log.AppendLine("    " + parent.name + " : " + sm.name);
            }
        }
예제 #6
0
        static void GetAudioStats(AudioClip ac, ref ObjectStatInfo ret)
        {
            if (ac == null)
            {
                return;
            }

            if (!ret.audio_total.Contains(ac.GetInstanceID()))
            {
                ret.audio_memory += (double)Profiler.GetRuntimeMemorySizeLong(ac);
                ret.audio_total.Add(ac.GetInstanceID());
            }
        }
예제 #7
0
        internal static void OnSelectionChange()
        {
            if (Selection.objects.Length == 0)
            {
                return;
            }
            //Debug.Log( "SelectionChange: " + Selection.activeObject.name );

            //_selected_objects = GetStats( Selection.gameObjects );
            _selected_objects = GetStats(Selection.activeGameObject);

            //Debug.Log( _selected_objects.ToString() );
        }
예제 #8
0
        /* Return a cached stat object or generate new one. */
        static ObjectStatInfo GetStats(GameObject obj)
        {
            //if( _cache.ContainsKey( obj ) ) {
            //	return _cache[ obj ];
            //}
            ObjectStatInfo ret = new ObjectStatInfo(obj.name);

            RecurseStats(obj, ref ret);

            //if( _enable_cache ) {
            //	_cache[ obj ] = ret;
            //}
            return(ret);
        }
예제 #9
0
        static void GetParticleStats(ParticleSystem ps, ref ObjectStatInfo ret)
        {
            if (ps == null)
            {
                return;
            }

            ParticleSystemRenderer psr = ps.GetComponent <ParticleSystemRenderer>();

            if (!psr)
            {
                return;
            }

            if (psr.renderMode != ParticleSystemRenderMode.Mesh)
            {
                ret.mesh_tris += _billboard_tris * (ulong)ps.particleCount;
            }
            else
            {
                ret.mesh_tris += (ulong)(psr.mesh.triangles.LongLength / 3) * (ulong)ps.particleCount;
                ret.mesh_total.Add(psr.mesh.GetInstanceID());
            }
        }
예제 #10
0
        /* Drill down hierarchy and collect stats. */
        static void RecurseStats(GameObject obj, ref ObjectStatInfo ret)
        {
            bool     is_static_batched = false;
            Renderer r = obj.GetComponent <Renderer>();

            if (r)
            {
                ret.renderers_total   += 1u;
                ret.renderers_visible += r.isVisible ? 1u : 0u;
                is_static_batched      = r.isPartOfStaticBatch;
                ret.renderers_batched += is_static_batched ? 1u : 0u;
                GetMaterialStats(r.sharedMaterials, ref ret, obj);
            }

            MeshFilter mf = obj.GetComponent <MeshFilter>();

            if (mf)
            {
                GetSharedMeshStats(mf.sharedMesh, ref ret, is_static_batched, obj);
            }

            SkinnedMeshRenderer smr = obj.GetComponent <SkinnedMeshRenderer>();

            if (smr)
            {
                GetSharedMeshStats(smr.sharedMesh, ref ret, is_static_batched, obj);
            }

            SpriteRenderer sr = obj.GetComponent <SpriteRenderer>();

            if (sr)
            {
                GetSpriteStats(sr.sprite, ref ret);
            }

            ParticleSystem ps = obj.GetComponent <ParticleSystem>();

            if (ps)
            {
                GetParticleStats(ps, ref ret);
            }

            Animator a = obj.GetComponent <Animator>();

            if (a)
            {
                GetAnimationClipStats(a, ref ret);
            }

            AudioSource au = obj.GetComponent <AudioSource>();

            if (au)
            {
                GetAudioStats(au.clip, ref ret);
            }

            for (int i = 0; i < obj.transform.childCount; ++i)
            {
                RecurseStats(obj.transform.GetChild(i).gameObject, ref ret);
            }

            /* TODO : Recurse on importers and assets. */
        }