Exemplo n.º 1
0
        private static void CollectSources(List <NavMeshBuildSource> sources, NavMeshModifier modifier, int area, NavMeshBuilderNBLDWrapper builder)
        {
            var collider = modifier.GetComponent <Collider2D>();

            if (collider == null)
            {
                return;
            }

            if (collider.usedByComposite)
            {
                collider = collider.GetComponent <CompositeCollider2D>();
            }

            var src = new NavMeshBuildSource();

            src.shape = NavMeshBuildSourceShape.Mesh;
            src.area  = area;

            Mesh mesh;

            mesh = builder.GetMesh(collider);
            if (mesh == null)
            {
                Debug.Log($"{collider.name} mesh is null");
                return;
            }
            if (collider.attachedRigidbody)
            {
                src.transform = Matrix4x4.TRS(Vector3.Scale(collider.transform.position, builder.overrideVector), collider.transform.rotation, Vector3.one);
            }
            else
            {
                src.transform = Matrix4x4.identity;
            }
            src.sourceObject = mesh;
            sources.Add(src);
        }
Exemplo n.º 2
0
        private static void CollectSources(List <NavMeshBuildSource> sources, SpriteRenderer sprite, int area, NavMeshBuilderNBLDWrapper builder)
        {
            if (sprite == null)
            {
                return;
            }
            var src = new NavMeshBuildSource();

            src.shape = NavMeshBuildSourceShape.Mesh;
            src.area  = area;

            Mesh mesh;

            mesh = builder.GetMesh(sprite.sprite);
            if (mesh == null)
            {
                Debug.Log($"{sprite.name} mesh is null");
                return;
            }
            src.transform    = Matrix4x4.TRS(Vector3.Scale(sprite.transform.position, builder.overrideVector), sprite.transform.rotation, sprite.transform.lossyScale);
            src.sourceObject = mesh;
            sources.Add(src);
        }