Exemplo n.º 1
0
    private void BakeAGameObject(GameObject go)
    {
        ShadowVolumeObject svo = go.GetComponent <ShadowVolumeObject>();

        if (svo != null)
        {
            go = svo.source;
        }

        PrefabType type = PrefabUtility.GetPrefabType(go);

        if (type == PrefabType.Prefab)
        {
            Debug.LogError("Skip a Shadow Volume Baking, because of it is a Prefab. " + go.name, go);
            return;
        }

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

        if (mf == null)
        {
            Debug.LogError("Skip a Shadow Volume Baking, becase of there is no MeshFilter. " + go.name, go);
            return;
        }
        if (mf.sharedMesh == null)
        {
            Debug.LogError("Skip a Shadow Volume Baking, becase of there is no Mesh. " + go.name, go);
            return;
        }
        if (!mf.sharedMesh.isReadable)
        {
            Debug.LogError("Skip a Shadow Volume Baking, becase of Mesh is not readable. " + go.name, go);
            return;
        }

        Transform transform = go.transform;

        ABakingTask task = new ABakingTask();

        task.Init(transform, transform.localToWorldMatrix, transform.worldToLocalMatrix, dirLight.transform.forward, mf.sharedMesh, capsOffset, groundLayer, twoSubMeshes);
        bakingTaskManager.AddTask(task);
    }