Is this a proper way to assign a Trigger a string tag?

Since I reuse scripts alot. I was tired of creating a new script for each trigger. I am using the following; Is this a method preferred, or is there some other way? This avoids forcing me to copy, recreate, change string to the new tag. This gives me the option to type (enter) the “tag” string via public declaration in the inspector. Then added a delay to spawn and destroy with reference to a sub directory where the instantiation is placed. Otherwise it is placed at root and gets messy. I can delete the instantiated prefab from the parent declared folder. Thoughts?

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


public class ShowBeacon : MonoBehaviour

{
    //declare the items

    //Item to spawn
    public string _tag;
    public GameObject Prefab;

    //The location of where to spawn.
    public Transform _TransformSpot;

    //This is added to delete the spawned objects, this directory is the container.
    public Transform _TransformParentDirectory;

    //How long to wait before spawning.
    // examples
    // 0 = immediate
    // 1 = 1 second
    // 2 = 2 seconds etc..
    public float _DelayTime;


    void Start()
    {
       
        
    }

    // Use this for initialization
    IEnumerator OnTriggerEnter (Collider trigger)
    {
        if (trigger.gameObject.tag == _tag) {
            yield return new WaitForSeconds (_DelayTime);
            GameObject _PrefabCopy = Instantiate (Prefab, _TransformSpot.position, _TransformSpot.rotation) as GameObject;
            _PrefabCopy.transform.SetParent (_TransformParentDirectory);
        }
           

    }
       
    /*void OnTriggerExit(Collider trigger)
    {
        //Destroy (gameObject);
        int childs = transform.childCount;
        for (int i = childs - 1; i >= 0; i--)
        {
            GameObject.Destroy (transform.GetChild (i).gameObject);
        }
   
    }*/


}

Can you explain why you need to create a new script for each trigger that behaves in a similar manner? That seems like a fundamental flaw in your design.

If using Tags for OnTriggers, Exits etc… I would need to declare the tag in script. Save, copy into new script and repeat. Using this would avoid this process and allow me to reuse the code. Based on your comment. What would you do if you need to trigger based on tags. How would you use the same code for each separate trigger?

This is the correct way to do it. Duplicating a script whose purpose is redundant just because you didn’t expose a string as public is a terrible design path.

You’ve got a full inspector for public variables, serialization in scenes, prefabs, scriptableobject asset potential, etc. There’s really no reason not to make generic scripts for everything wherever possible so keep looking for ways to continue doing that. Otherwise, you’ll end up with a nightmare down the line trying to update dozens of scripts that do the exact same thing.