Esempio n. 1
0
        public VlmBakeData()
        {
            Light[] allLights = Object.FindObjectsOfType <Light>();

            DirectionalLights = allLights.Where(l => l.type == LightType.Directional).ToList();
            Lights            = allLights.Where(l => l.type != LightType.Directional).ToList();

            LightSponges = Object.FindObjectsOfType <LightSponge>().ToList();

            Meshes = new List <VlmMeshObject>();
            MeshFilter[] meshes = Object.FindObjectsOfType <MeshFilter>();

            foreach (MeshFilter mesh in meshes)
            {
                if (!GameObjectUtility.AreStaticEditorFlagsSet(mesh.gameObject, StaticEditorFlags.LightmapStatic))
                {
                    continue;
                }

                VlmBakeOptionsComponent bakeOptions = mesh.GetComponent <VlmBakeOptionsComponent>();
                if (!bakeOptions || !bakeOptions.IgnoreLightmapper)
                {
                    Meshes.Add(new VlmMeshObject(mesh.gameObject, bakeOptions));
                }
            }
        }
        public VlmMeshObject(GameObject go, VlmBakeOptionsComponent bakeOptions = null)
        {
            MeshCollider = go.GetComponent <MeshCollider>();

            if (!MeshCollider)
            {
                MeshCollider           = go.AddComponent <MeshCollider>();
                MeshCollider.hideFlags = HideFlags.HideAndDontSave;
                _attachedCollider      = true;
            }
            else
            {
                _attachedCollider = false;
            }

            MeshBakeOptions = bakeOptions ? bakeOptions.BakeOptions : null;
            Transform       = go.transform;

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

            Mesh = mf ? mf.sharedMesh : null;
        }