Esempio n. 1
0
        public KAPProfile(GameObject obj)
        {
            this.name          = obj.name;
            this.polys         = 0;
            this.boneamount    = 0;
            this.dynboneamount = 0;
            SkinnedMeshRenderer[] meshes = obj.GetComponentsInChildren <SkinnedMeshRenderer>();
            foreach (SkinnedMeshRenderer smr in meshes)
            {
                this.polys = this.polys + (smr.sharedMesh.triangles.Length / 3);
                foreach (Transform bone in smr.bones)
                {
                    this.boneamount = this.boneamount + 1;
                    DynamicBone dyn = bone.gameObject.GetComponent <DynamicBone>();
                    if (dyn)
                    {
                        this.dynboneamount = this.dynboneamount + dyn.m_Root.GetComponentsInChildren <Transform>().Length;
                    }
                }
            }
            this.meshrenderers    = obj.GetComponentsInChildren <SkinnedMeshRenderer>().Length;
            this.particle_systems = obj.GetComponentsInChildren <ParticleSystem>().Length;
            this.dynbonecolliders = obj.GetComponentsInChildren <DynamicBoneCollider>().Length;
            this.cloth            = obj.GetComponentsInChildren <Cloth>().Length;
            this.animators        = obj.GetComponentsInChildren <Animator>().Length - 1;
            this.audio_sources    = obj.GetComponentsInChildren <AudioSource>().Length;
            this.lights           = obj.GetComponentsInChildren <Light>().Length;

            this.perfP = new PerformanceProfile(this);
            this.perfP.saveFile(Application.dataPath + "/KAPAvatars/" + name + "/");
            saveFile();
        }
Esempio n. 2
0
        ///<summary>
        ///It returns you a KAPProfile of the given name through searching for its file
        ///</summary>
        ///<param name='name'>The name of the KAPProfile you want to get</param>
        public static KAPProfile fromFile(string name)
        {
            string     json   = File.ReadAllText(Application.dataPath + "/KAPAvatars/" + name + "/" + name + ".KAPprofile");
            KAPProfile result = JsonUtility.FromJson <KAPProfile>(json);

            result.perfP = PerformanceProfile.fromFile(Application.dataPath + "/KAPAvatars/" + name + "/");
            return(result);
        }