⛽
Generator System - Doc
  • Generator System - Introduction
  • ⭐Getting Started
    • Quick Start
    • Detailed Setup
  • ❓Support
    • FAQ
    • Power Event
    • System Namespace
    • Missing UI Text?
    • Adding Audio Clips
    • Where are the Inputs?
    • Adding New Sprites
  • 🌀Development
    • Patch Notes - V1.5
    • Roadmap
  • 📧Contacts
    • Contact Me
    • My Other Assets
Powered by GitBook
On this page

Was this helpful?

  1. Support

Power Event

PreviousFAQNextSystem Namespace

Last updated 1 year ago

Was this helpful?

Using the UnityEvent feature on each controller will allow you to add multiple event types, see the demo scene for a clear example on this.

void ActivateGenerator()
{
     rumbling = true;
     activateGenerator.Invoke();
}

void DeactivateGenerator()
{
     rumbling = false;
     deactivateGenerator.Invoke();
}
  • The events below run the:

    • Activate Generator script

    • Start an audio effect parented to the object (3D generator sound)

    • Turns the red light off

    • Turns the green light on

The opposite happens in the deactivate section

  • Below is the script that gets activated by the event

    public class ActivateGenerator : MonoBehaviour
    {
        [SerializeField] private Renderer[] thisMaterial = null;
        private string emissionName = "_EMISSION";

        [SerializeField] private GameObject[] lights = null;

        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);
            }
        }
❓