AddComponent not working

Hello,

I use probuildermesh shape generator to create an arch shape. I use that shape as gates in my game. After i create arch with properties that i wanted i assign its game object as gate then change its features like transform position, scale and material. These are successful but when i wanted to add component like rigidbody, colliders and the class i created for gate these are not shown in the inspector so they didnt added. Also there is no error message in console. What i am doing wrong? Function for creating gate is below.

Thx in advance.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.ProBuilder;
    using UnityEngine.ProBuilder.MeshOperations;
    
        public class LevelGenerator : MonoBehaviour
        {

private void Start()
    {
        GenerateGate();
    }
        void GenerateGate()
            {
                int randomWidthIndex = Random.Range(0, 11);
                float[] gateWidths = { 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f};
                float randomWidth = gateWidths[randomWidthIndex];
        
                ProBuilderMesh arch = ShapeGenerator.GenerateArch(
                pivotType: PivotLocation.Center,
                angle: 180,
                radius: 3,
                width: randomWidth,
                depth: 0.5f,
                radialCuts: 12,
                insideFaces: true,
                outsideFaces: true,
                frontFaces: true,
                backFaces: true,
                endCaps: false);
        
                
        
                GameObject gate = arch.gameObject;
                gate.transform.localScale = gate.transform.localScale * 100f;
                gate.transform.position = new Vector3(0f, 150f, 1200f);
                gate.GetComponent<MeshRenderer>().material = gateMat;
                gate.GetComponent<MeshCollider>().enabled = false;
                gate.AddComponent<Rigidbody>();
                Rigidbody gateRb = gate.GetComponent<Rigidbody>();
                gateRb.useGravity = false;
                gateRb.isKinematic = true;
                gateRb.constraints = RigidbodyConstraints.FreezeAll;
                BoxCollider topCol = gate.AddComponent<BoxCollider>();
                topCol.center = new Vector3(0f, randomWidth / 2, 0f);
                topCol.size = new Vector3(6f, randomWidth / 2, 0.5f);
                BoxCollider rightCol = gate.AddComponent<BoxCollider>();
                rightCol.center = new Vector3((randomWidth +3) / 2, (randomWidth - 3) / 2, 0f);
                rightCol.size = new Vector3(3 - randomWidth, randomWidth, 0.5f);
                BoxCollider leftCol = gate.AddComponent<BoxCollider>();
                leftCol.center = new Vector3(-rightCol.center.x, rightCol.center.y, rightCol.center.z);
                leftCol.size = rightCol.size;
                BoxCollider botCol = gate.AddComponent<BoxCollider>();
                botCol.center = new Vector3(0, (randomWidth - 3) / 2, 0);
                botCol.size = new Vector3(randomWidth * 2 , randomWidth, 0.5f);
                Gate gateScript = gate.AddComponent<Gate>();
                gateScript.target = randomWidth * 100;
        
            }
        }

I tried your code and the Rigid Body and the 4 Box Colliders all appeared in the Inspector. That means your part of that code is OK, as far as I can see. The code did fail on GateMat and the Gate Class but I assume they are other parts of your project so I just commented them out. I’m running version 2021.3.5 (LTS) on a Mac.