// Handles adding new visualizers to the scene public void AddVisualizer(VisualizerModule visualizer) { // Create an empty to group the visualizer's particles GameObject parent = visualizer.Scale ? _scaledEmpty : _unscaledEmpty; GameObject empty = new GameObject(visualizer.Name); empty.transform.SetParent(parent.transform, false); visualizer.Spawn(empty.transform); _activeVisualizers.Add(visualizer, empty); }
private VisualizersManager _visualizersManager; // Used to tell the parent which visualizers to use // Can't use Start since we need to set the variables first public void Init(VisualizersManager visualizersManager, VisualizerModule visualizerModule) { _visualizersManager = visualizersManager; _visualizer = visualizerModule; _toggle = GetComponent <Toggle>(); _toggle.onValueChanged .AddListener(OnValueChanged); // OnValueChanged will run every time the toggle is clicked // Set the text attached to this toggle _toggle.GetComponentInChildren <Text>().text = _visualizer.Name; _image = GetComponent <Image>(); }
// Handles removing visualizers from the scene public void RemoveVisualizer(VisualizerModule visualizer) { Destroy(_activeVisualizers[visualizer]); _activeVisualizers.Remove(visualizer); }