Example #1
0
    ////////////////////////////////////////////////////////////////

    public void AddPlatform(PlatformData platformData)
    {
        AssetDataPlayer assetDataPlayer = AssetManager.GetAssetData <AssetDataPlayer>();

        GameObject gameObject = new GameObject("~ Platform");

        gameObject.layer                      = (int)GameLayer.Platform;
        gameObject.transform.parent           = m_PlatformCoreObject.transform;
        (Mesh mesh, Vector2[] collisionVerts) = platformData.Create();

        MeshFilter filter = gameObject.AddComponent <MeshFilter>();

        filter.sharedMesh = mesh;

        MeshRenderer renderer = gameObject.AddComponent <MeshRenderer>();

        renderer.sharedMaterial = assetDataPlayer.PlatformMaterial;

        PolygonCollider2D collider = gameObject.AddComponent <PolygonCollider2D>();

        collider.points = collisionVerts;

        m_Platforms.Add(new Platform {
            _Data = platformData, _GameObject = gameObject
        });
    }