Realtime mesh triangles do not appear depending on camera angle

I am creating a mesh that is a cube with two vertices of the same edge removed. This makes it a prism. The problem is that after clearing the mesh then setting the new vertices and triangles, only half of the triangles appear at the same time. The other half appear when changing the scene camera’s angle. Here are some screenshots to show the problem :



As you can see the triangle to the right does not appear in the first screenshot but appears through a missing triangle in the second screenshot. Here is my code :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class createPrism : MonoBehaviour {

    public Mesh mesh;

	void Start () {
        mesh = GetComponent<MeshFilter>().mesh;
        Vector3[] vertices = {
            new Vector3(-0.5f,-0.5f,-0.5f),
            new Vector3(0.5f,-0.5f,-0.5f),
            new Vector3(-0.5f,0.5f,-0.5f),
            new Vector3(0.5f,0.5f,-0.5f),
            new Vector3(-0.5f,-0.5f,0.5f),
            new Vector3(0.5f,-0.5f,0.5f)

        int[] triangles = {

        mesh.vertices = vertices;
        mesh.triangles = triangles;

This is probably an easy fix but I couldn’t find anything like this online.

Triangles have a direction they face. They have a front side (which is visible) and a back side (which is not visible). The side depends on the winding order of your vertices. In Unity by default a clockwise winding denotes the front face. If the winding order is counter clockwise it will be a backface and (due to backface culling) not visible.

I did not go through your triangle list to figure out which one you have inverted. However note that in order to change the winding order you just have to swap any two vertices of a triangle. I would start by first adding comments to your vertices to keep track which one is which. I highly recommend you create a drawing of your mesh on paper and label your vertices. Then it’s much easier to figure out the correct winding order. I also recommend to add comments to each triangle tripple to know which side / face it belongs to. Your prism has 3 quads (6 tirangles) and 2 triangle faces.