how to assign 2d physics material through script

Code Example - how to assign 2d physics material through script

                
                        public PhysicsMaterial2D mat;

GetComponent<Collider2D>().sharedMaterial = mat; // Sets material to mat