Power Up Event

  • This is the power up event. I have created a basic script called "ActivateLights", which is a public method to change emission and activate some GameObjects.

  • You can add whatever you want here, whether that's opening a door, turning on a generator or more!

public class ActivateLights : MonoBehaviour
    {
        [Header("Array of Mesh renderer for objects we want to change the emission")]
        [SerializeField] private Renderer[] thisMaterial = null;
        private string emissionName = "_EMISSION";

        [SerializeField] private GameObject[] lights = null;

        //This is just a sample example of a type of action you could do after the generator is filled, this simulated turning on lights
        public void PowerLights()
        {
            foreach (GameObject lightObjects in lights)
            {
                lightObjects.SetActive(true);
            }

            foreach (Renderer emissiveMaterial in thisMaterial)
            {
                emissiveMaterial.material.EnableKeyword(emissionName);
            }
        }

        public void DeactivateLights()
        {
            foreach (GameObject lightObjects in lights)
            {
                lightObjects.SetActive(false);
            }

            foreach (Renderer emissiveMaterial in thisMaterial)
            {
                emissiveMaterial.material.DisableKeyword(emissionName);
            }
        }
    }

Last updated