Q:

Unity problem activating a function with parameters in camera from another script in GameObject Enemy

I have a script that makes the camera do a shake by putting a button because
 It is a public access function, if I do it that way when placing a button it works well but what I cannot achieve is to call the function so that every time my player collides with an enemy he makes the shake. I hope you can help me.
The shake code in camera is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScreenShaker : MonoBehaviour {

    private float shakeAmount = 0.5f;

    private float shakeTime = 0.0f;
    private Vector3 initialPosition;
    private bool isScreenShaking = false;

    void Update () {
        if(shakeTime > 0)
        {
            this.transform.position = Random.insideUnitSphere * shakeAmount + initialPosition;
            shakeTime -= Time.deltaTime;
        }
        else if(isScreenShaking)
        {
            isScreenShaking = false;
            shakeTime = 0.0f;
            this.transform.position = initialPosition;
        }
    }

    public void ScreenShakeForTime(float time)
    {
        initialPosition = this.transform.position;
        shakeTime = time;
        isScreenShaking = true;
    }
}

The enemy code is:
   using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class ControladorEnemigoCirculoMediano : MonoBehaviour
    {
        void OnTriggerEnter2D(Collider2D other)
        {
            if (other.tag == "Player") 
            {
            Here I don't know what to call the public void function ScreenShakeForTime (float time); 
            I already tried many things online but when my character comes into contact with the character, I don't do the shake in the camera.
            }
        }
    }

A:

You can create Unity-singleton in your ScreenShaker class like:
class ScreenShaker
{
  public static ScreenShaker Instance {private set; get;};

  void Awake() {
    Instance = this;
  }
}

And than from any place to call like:
ScreenShaker.Instance.ScreenShakeForTime(2f);

This is the easiest way, but maybe it's better to create standard singeleton(it's up to you).
And also don;t forget to destroy it on OnDestroy()

